Submission #586368

#TimeUsernameProblemLanguageResultExecution timeMemory
586368hibikiLightning Rod (NOI18_lightningrod)C++11
80 / 100
2012 ms166340 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back #define f first #define s second stack<int> s; vector<pair<int,int> > v; int main() { int n; scanf("%d",&n); for(int i = 0; i < n; i++) { int x, y; scanf("%d %d",&x,&y); v.pb({x,y}); while(!s.empty() && x - v[s.top()].f <= abs(y - v[s.top()].s) && y > v[s.top()].s) s.pop(); if(s.empty() || x - v[s.top()].f > abs(y - v[s.top()].s)) s.push(i); } printf("%d\n",s.size()); }

Compilation message (stderr)

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:25:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::stack<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   25 |     printf("%d\n",s.size());
      |             ~^
      |              |
      |              int
      |             %ld
lightningrod.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
lightningrod.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         scanf("%d %d",&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~~
#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...