Submission #586485

#TimeUsernameProblemLanguageResultExecution timeMemory
586485M_WLightning Rod (NOI18_lightningrod)C++17
100 / 100
1937 ms81128 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int N; stack<pair<int, int>> stk; scanf("%d", &N); while(N--){ int x, y; scanf("%d %d", &x, &y); if(!stk.empty() && stk.top().second > y && x - stk.top().first <= stk.top().second - y) continue; while(!stk.empty()){ auto [xx, yy] = stk.top(); if(y > yy && x - xx <= y - yy) stk.pop(); else break; } stk.push({x, y}); } printf("%d", stk.size()); }

Compilation message (stderr)

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:19: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=]
   19 |  printf("%d", stk.size());
      |          ~^   ~~~~~~~~~~
      |           |           |
      |           int         std::stack<std::pair<int, int> >::size_type {aka long unsigned int}
      |          %ld
lightningrod.cpp:6:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |  scanf("%d", &N);
      |  ~~~~~^~~~~~~~~~
lightningrod.cpp:8:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |   int x, y; 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...