Submission #970511

#TimeUsernameProblemLanguageResultExecution timeMemory
970511NoMercyLightning Rod (NOI18_lightningrod)C++14
66 / 100
2037 ms43256 KiB
#include <bits/stdc++.h> using namespace std; int TIME = clock(); #define file \ freopen("in.txt" , "r" , stdin); \ freopen("out.txt" , "w" , stdout); void test_case () { int n; cin >> n; stack<pair<int , int>> st; for (int i = 0;i < n;i ++) { int x , y; cin >> x >> y; pair<int , int> tmp = {x , y}; if (st.size() == 0) { st.push({x , y}); continue; } if (abs(x - st.top().first) <= st.top().second - y) { continue; } while ((int)st.size() > 0 && abs(st.top().first - x) <= y - st.top().second) { st.pop(); } st.push({x , y}); } cout << (int)st.size() << "\n"; } int32_t main () { /// file int t = 1; // cin >> t; while (t --) { test_case(); } return 0; }

Compilation message (stderr)

lightningrod.cpp: In function 'void test_case()':
lightningrod.cpp:20:25: warning: variable 'tmp' set but not used [-Wunused-but-set-variable]
   20 |         pair<int , int> tmp = {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...