Submission #219586

#TimeUsernameProblemLanguageResultExecution timeMemory
219586GioChkhaidzeLightning Rod (NOI18_lightningrod)C++14
66 / 100
2080 ms171132 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; main () { scanf("%d",&n); for (int i=1; i<=n; i++) { scanf("%d%d",&x[i],&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:7:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main () {
       ^
lightningrod.cpp: In function 'int main()':
lightningrod.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
lightningrod.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&x[i],&y[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~
#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...