Submission #712098

#TimeUsernameProblemLanguageResultExecution timeMemory
712098PherokungLightning Rod (NOI18_lightningrod)C++14
80 / 100
2062 ms153816 KiB
#include<bits/stdc++.h> using namespace std; #define MAXN 10000005 #define F first #define S second int n,x[MAXN],y[MAXN],rod[MAXN],ans=0; deque<int> dq; int main(){ scanf("%d",&n); ans = n; for(int i=1;i<=n;i++){ scanf("%d%d",&x[i],&y[i]); rod[i] = 1; while(!dq.empty()){ int p = dq.front(); if(y[i] - x[i] >= y[p] - x[p]){ if(rod[p] == 1){ rod[p] = 0; ans--; } dq.pop_front(); } else break; } dq.push_front(i); } while(!dq.empty()) dq.pop_front(); for(int i=n;i>=1;i--){ while(!dq.empty()){ int p = dq.front(); if(y[i] + x[i] >= y[p] + x[p]){ if(rod[p] == 1){ rod[p] = 0; ans--; } dq.pop_front(); } else break; } dq.push_front(i); } printf("%d",ans); }

Compilation message (stderr)

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
lightningrod.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   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...