Submission #138933

#TimeUsernameProblemLanguageResultExecution timeMemory
138933thebesLightning Rod (NOI18_lightningrod)C++14
66 / 100
2041 ms175676 KiB
#include <bits/stdc++.h> using namespace std; stack<pair<int,int>> mono; int n, i, x, y, f; int main(){ for(scanf("%d",&n),i=1;i<=n;i++){ scanf("%d%d",&x,&y); f=0; while(mono.size()){ if(x-mono.top().first<=mono.top().second-y) break; else if(y-mono.top().second>=x-mono.top().first) mono.pop(); else{f=1; break;} } if(mono.empty()||f) mono.push({x,y}); } printf("%d\n",mono.size()); return 0; }

Compilation message (stderr)

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:17:30: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::stack<std::pair<int, int> >::size_type {aka long unsigned int}' [-Wformat=]
     printf("%d\n",mono.size());
                   ~~~~~~~~~~~^
lightningrod.cpp:8:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(scanf("%d",&n),i=1;i<=n;i++){
         ~~~~~~~~~~~~~~^~~~
lightningrod.cpp:9:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&x,&y); f=0;
         ~~~~~^~~~~~~~~~~~~~
#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...