Submission #147295

#TimeUsernameProblemLanguageResultExecution timeMemory
147295JovanK26Lightning Rod (NOI18_lightningrod)C++14
66 / 100
2062 ms238080 KiB
#include <bits/stdc++.h> using namespace std; int x[10000001]; int y[10000001]; int pref[10000001]; int suf[10000001]; int rez=0; 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 >> x[i] >> y[i]; } pref[0]=x[0]+y[0]; for(int i=1;i<n;i++) { pref[i]=max(pref[i-1],x[i]+y[i]); } suf[n-1]=y[n-1]-x[n-1]; for(int i=n-2;i>=0;i--) { suf[i]=max(suf[i+1],y[i]-x[i]); } for(int i=0;i<n;i++) { if(!i && suf[i]>suf[i+1])rez++; else if(i==n-1 && pref[i]>pref[i-1])rez++; else if(pref[i]>pref[i-1] && suf[i]>suf[i+1]) { rez++; } } cout << rez; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...