Submission #425457

#TimeUsernameProblemLanguageResultExecution timeMemory
425457errorgornLightning Rod (NOI18_lightningrod)C++17
100 / 100
794 ms192252 KiB
#include <bits/stdc++.h> #include <cstdio> #include <stack> using namespace std; inline void read(int& x) { x = 0; char ch = getchar_unlocked(); while (ch&16){ //this will break when ‘\n’ or ‘ ‘ is encountered x = (x << 3) + (x << 1) + (ch&15); ch = getchar_unlocked(); } } int x,y; typedef pair<int,int> ii; stack<ii> s; int main(){ int N; read(N); read(x),read(y); s.push(ii(x,y)); for(int i = 1; i < N; i++) { read(x),read(y); if (x-s.top().first>s.top().second-y){ while (!s.empty() && x-s.top().first<=y-s.top().second){ s.pop(); } s.push(ii (x,y)); } } printf("%d",s.size()); return 0; }

Compilation message (stderr)

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:31:11: 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=]
   31 |  printf("%d",s.size());
      |          ~^  ~~~~~~~~
      |           |        |
      |           int      std::stack<std::pair<int, int> >::size_type {aka long unsigned int}
      |          %ld
#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...