Submission #265322

#TimeUsernameProblemLanguageResultExecution timeMemory
265322T0p_Lightning Rod (NOI18_lightningrod)C++14
100 / 100
714 ms192028 KiB
#include<bits/stdc++.h> using namespace std; stack<pair<int, int>> stk; int fi() { int ret = 0; while(true) { char c = getchar_unlocked(); if('0' <= c && c <= '9') { ret *= 10; ret += (c-'0'); } else return ret; } } int main() { int n = fi(); while(n--) { int x = fi(), y = fi(); if(stk.empty()) stk.push({x, y}); else { int h = stk.top().second - x + stk.top().first; if(h >= y) continue ; while(!stk.empty()) { int h = y - x + stk.top().first; if(h >= stk.top().second) stk.pop(); else break ; } stk.push({x, y}); } } printf("%d\n",stk.size()); return 0; }

Compilation message (stderr)

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:42: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=]
   42 |  printf("%d\n",stk.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...