QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#709396#5082. Frog JumpOOBMABTRAMS#WA 1ms7596kbC++17879b2024-11-04 14:34:282024-11-04 14:34:28

Judging History

你现在查看的是最新测评结果

  • [2024-11-04 14:34:28]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7596kb
  • [2024-11-04 14:34:28]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=400013;
int a[N],b[N];

int g[N];

int main(){
    int n,k;
    cin>>n>>k;
    vector<pair<int,int>>v;
    for(int i=1,x,y;i<=n;i++) {
        cin>>x>>y,a[i]=x,b[i]=y;
        if(v.empty())v.emplace_back(x,y);
        else {
            auto&[l,r]=v.back();
            if(r<x)v.emplace_back(x,y);
            else r=max(r,y);
        }
    }
    int tt=0;
    map<int,int>p;
    for(auto[l,r]:v) {
        p[l]=tt;
        tt+=r-l;
        p[r]=tt;
    }
    for(int i=1;i<=k;i++) {
        cin>>g[i];
    }
    ll ans=0;
    for(int i=2;i<=k;i++) {
        int f=g[i-1],t=g[i];
        if(f<t)swap(f,t);
        ans+=(p.lower_bound(a[f])->first-p.lower_bound(a[t])->first)-(p.lower_bound(a[f])->second-p.lower_bound(a[t])->second);
    }
    cout<<ans<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 7596kb

input:

4 3
0 2
0 3
3 5
6 7
4 2 3

output:

1

result:

wrong answer 1st lines differ - expected: '2', found: '1'