Submission #712097

#TimeUsernameProblemLanguageResultExecution timeMemory
712097PherokungLightning Rod (NOI18_lightningrod)C++14
0 / 100
1586 ms153964 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; stack<int> dq; bool oper(pair<int,int> i,pair<int,int> j){ return i.F > j.F; } int main(){ scanf("%d",&n); ans = n; for(int i=1;i<=n;i++){ scanf("%d%d",&x[i],&y[i]); rod[i] = 1; } for(int i=1;i<=n;i++){ while(!dq.empty()){ int p = dq.top(); if(y[i] - x[i] >= y[p] - x[p]){ if(rod[p] == 1){ rod[p] = 0; ans--; } dq.pop(); } else break; } dq.push(i); } for(int i=n;i>=1;i--){ while(!dq.empty()){ int p = dq.top(); if(y[i] + x[i] >= y[p] + x[p]){ if(rod[p] == 1){ rod[p] = 0; ans--; } dq.pop(); } else break; } dq.push(i); } printf("%d",ans); }

Compilation message (stderr)

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