Submission #219587

#TimeUsernameProblemLanguageResultExecution timeMemory
219587GioChkhaidzeLightning Rod (NOI18_lightningrod)C++14
80 / 100
2089 ms228236 KiB
#include <bits/stdc++.h> using namespace std; const int N=1e7+7; bool f[N]; int n,x[N],y[N]; stack < int > st; void fastscan(int &number) { register int c; number = 0; c = getchar(); for (; (c>47 && c<58); c=getchar()) number = number *10 + c - 48; } main () { fastscan(n); for (int i=1; i<=n; i++) { fastscan(x[i]); fastscan(y[i]); } int ans=n; for (int i=1; i<=n; i++) { if (st.size()) { while (st.size() && x[st.top()]-y[st.top()]>=x[i]-y[i]) { f[st.top()]=1; --ans; st.pop(); } } st.push(i); } while (st.size()) st.pop(); for (int i=n; i>=1; i--) { if (f[i]) continue; if (st.size()) { while (st.size() && x[st.top()]+y[st.top()]<=x[i]+y[i]) { f[st.top()]=1; --ans; st.pop(); } } st.push(i); } printf("%d\n",ans); }

Compilation message (stderr)

lightningrod.cpp:16:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main () {
       ^
#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...