This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |