Submission #710126

#TimeUsernameProblemLanguageResultExecution timeMemory
710126ToroTNLightning Rod (NOI18_lightningrod)C++14
100 / 100
1941 ms247216 KiB
#include<bits/stdc++.h> using namespace std; #define X first #define Y second int n,x[10000005],y[10000005],hsh[10000005],ans=0; stack<pair<int,int> > stk; int main() { scanf("%d",&n); for(int i=1;i<=n;i++)scanf("%d%d",&x[i],&y[i]); for(int i=1;i<=n;i++) { while(!stk.empty()) { if(y[i]-x[i]>=stk.top().X) { stk.pop(); }else { break; } } stk.push({y[i]-x[i],i}); } while(!stk.empty()) { ++hsh[stk.top().Y]; stk.pop(); } for(int i=n;i>=1;i--) { while(!stk.empty()) { if(y[i]+x[i]>=stk.top().X) { stk.pop(); }else { break; } } stk.push({y[i]+x[i],i}); } while(!stk.empty()) { if(hsh[stk.top().Y]==1)++ans; stk.pop(); } printf("%d\n",ans); }

Compilation message (stderr)

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