QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#709396 | #5082. Frog Jump | OOBMABTRAMS# | WA | 1ms | 7596kb | C++17 | 879b | 2024-11-04 14:34:28 | 2024-11-04 14:34:28 |
Judging History
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'