#include<bits/stdc++.h>
using namespace std;
const int N = 1e7+9;
int per[N] , suf[N];
int aa[N], bb[N];
int main() {
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int n;cin>>n;
for(int i = 0;i<n;i++){
cin>>aa[i]>>bb[i];
if(i==0){
per[0] = aa[0]+bb[0];
}else{
per[i] = max(per[i-1],aa[i]+bb[i]);
}
}
suf[n-1] = bb[n-1]-aa[n-1];
for(int i = n-2;i>=0;i--){
suf[i] = max(suf[i+1],bb[i]-aa[i]);
}
int ans = 0;
for(int i = 0;i<n;i++){
if(i==0){
if(suf[i+1]<bb[i]-aa[i]){
ans++;
}
}else if(i==n-1){
if(per[i-1]<aa[i]+bb[i])ans++;
}else{
if(suf[i+1]<bb[i]-aa[i]&&per[i-1]<aa[i]+bb[i])ans++;
}
}
cout<<ans<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1403 ms |
152452 KB |
Output is correct |
2 |
Correct |
1393 ms |
151816 KB |
Output is correct |
3 |
Correct |
1394 ms |
147776 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
380 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
380 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
37 ms |
3292 KB |
Output is correct |
15 |
Correct |
37 ms |
3428 KB |
Output is correct |
16 |
Correct |
35 ms |
3272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1411 ms |
156928 KB |
Output is correct |
2 |
Correct |
1355 ms |
156340 KB |
Output is correct |
3 |
Correct |
1340 ms |
152692 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1403 ms |
152452 KB |
Output is correct |
2 |
Correct |
1393 ms |
151816 KB |
Output is correct |
3 |
Correct |
1394 ms |
147776 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
380 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
37 ms |
3292 KB |
Output is correct |
18 |
Correct |
37 ms |
3428 KB |
Output is correct |
19 |
Correct |
35 ms |
3272 KB |
Output is correct |
20 |
Correct |
1411 ms |
156928 KB |
Output is correct |
21 |
Correct |
1355 ms |
156340 KB |
Output is correct |
22 |
Correct |
1340 ms |
152692 KB |
Output is correct |
23 |
Correct |
1670 ms |
142492 KB |
Output is correct |
24 |
Correct |
1705 ms |
178928 KB |
Output is correct |
25 |
Correct |
1720 ms |
262144 KB |
Output is correct |