QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#709404 | #5082. Frog Jump | OOBMABTRAMS# | WA | 485ms | 17408kb | C++17 | 892b | 2024-11-04 14:37:02 | 2024-11-04 14:37:10 |
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;
g[0]=1;
for(int i=1;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';
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5640kb
input:
4 3 0 2 0 3 3 5 6 7 4 2 3
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 5584kb
input:
4 3 0 2 0 3 3 5 6 7 2 3 2
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 1ms
memory: 7688kb
input:
8 5 1 8 2 4 5 11 13 15 15 17 16 18 19 22 20 22 3 7 4 6 3
output:
6
result:
ok single line: '6'
Test #4:
score: 0
Accepted
time: 1ms
memory: 5640kb
input:
8 5 1 5 5 10 10 15 15 20 20 25 25 30 30 35 35 40 3 7 4 6 3
output:
0
result:
ok single line: '0'
Test #5:
score: 0
Accepted
time: 1ms
memory: 5804kb
input:
10 7 1 5 5 10 10 15 15 20 20 25 25 30 30 35 35 40 41 50 50 60 3 7 4 6 3 9 10
output:
1
result:
ok single line: '1'
Test #6:
score: 0
Accepted
time: 0ms
memory: 5552kb
input:
10 10 1 5 5 10 10 15 15 20 20 25 25 30 30 35 35 40 41 50 50 60 3 7 4 6 3 9 10 5 1 9
output:
3
result:
ok single line: '3'
Test #7:
score: 0
Accepted
time: 0ms
memory: 5840kb
input:
6 11 0 1 2 3 4 5 6 7 8 9 10 11 1 2 3 4 5 6 5 4 3 2 1
output:
10
result:
ok single line: '10'
Test #8:
score: 0
Accepted
time: 1ms
memory: 5876kb
input:
13 14 0 2 1 3 2 4 4 6 10 15 11 13 12 15 20 25 27 29 28 30 33 35 34 36 35 37 3 4 8 11 13 8 6 10 4 7 9 10 9 9
output:
53
result:
ok single line: '53'
Test #9:
score: 0
Accepted
time: 1ms
memory: 5584kb
input:
14 25 0 22 1 5 5 10 12 16 14 20 20 24 27 33 30 38 34 40 34 45 47 53 49 55 55 60 60 65 2 5 4 6 10 8 7 9 12 11 14 13 9 10 7 8 4 5 1 2 6 5 3 8 10
output:
13
result:
ok single line: '13'
Test #10:
score: 0
Accepted
time: 1ms
memory: 5844kb
input:
14 25 0 22 1 5 5 10 12 16 14 20 20 24 27 33 30 38 34 40 34 45 47 53 49 55 55 60 60 65 2 5 4 6 5 1 3 2 6 5 1 1 3 2 2 5 6 6 1 2 3 4 4 5 2
output:
0
result:
ok single line: '0'
Test #11:
score: 0
Accepted
time: 110ms
memory: 15708kb
input:
100000 100000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...
output:
99999
result:
ok single line: '99999'
Test #12:
score: -100
Wrong Answer
time: 485ms
memory: 17408kb
input:
100000 1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 ...
output:
-19
result:
wrong answer 1st lines differ - expected: '1899981', found: '-19'