Submission #131267

#TimeUsernameProblemLanguageResultExecution timeMemory
131267FedericoSLightning Rod (NOI18_lightningrod)C++14
100 / 100
740 ms254816 KiB
#include <iostream> #include <algorithm> using namespace std; int N; int X[10000007]; int Y[10000007]; bool B[10000007]; int ans,a; int readInt(){ int res = 0; char ch = 0; while(ch < '0') ch = getchar_unlocked(); for(; ch >= '0'; ch = getchar_unlocked()) res = res * 10 + ch - '0'; return res; } void writeInt(int v){ char buf[14]; int p = 0; if(v == 0) buf[p++] = 0; for(; v; v /= 10) buf[p++] = v % 10; while(p--) putchar_unlocked(buf[p] + '0'); } int main(){ N=readInt(); for(int i=0;i<N;i++){ X[i]=readInt(); Y[i]=readInt(); } a=-2e9-5; for(int i=0;i<N;i++){ if(a<X[i]+Y[i]) a=X[i]+Y[i]; else B[i]=true; } a=-2e9-5; for(int i=N-1;i>=0;i--){ if(a<-X[i]+Y[i]) a=-X[i]+Y[i]; else B[i]=true; } for(int i=0;i<N;i++) ans+=!B[i]; writeInt(ans); }
#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...