Submission #712100

#TimeUsernameProblemLanguageResultExecution timeMemory
712100PherokungLightning Rod (NOI18_lightningrod)C++14
80 / 100
2032 ms153912 KiB
#include<bits/stdc++.h> using namespace std; #define MAXN 10000005 #define F first #define S second int n,a,b,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",&a,&b); rod[i] = 1; x[i] = b-a; y[i] = b+a; } for(int i=1;i<=n;i++){ while(!dq.empty()){ int p = dq.front(); if(x[i] >= 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] >= y[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",&a,&b);
      |   ~~~~~^~~~~~~~~~~~~~
#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...