Submission #970523

#TimeUsernameProblemLanguageResultExecution timeMemory
970523NoMercyLightning Rod (NOI18_lightningrod)C++14
100 / 100
1352 ms135916 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 <array <int , 2>> st; auto check = [&](array<int , 2> se , array<int , 2> fi) -> bool { return (abs(fi[0] - se[0]) <= fi[1] - se[1]); }; for (int i = 0;i < n;i ++) { int x , y; cin >> x >> y; array<int , 2> tmp = {x , y}; if (st.size() == 0) { st.push(tmp); continue; } if (check(tmp , st.top()) == true) { continue; } while (st.size() > 0 && check(st.top() , tmp) == true) { st.pop(); } st.push({x , y}); } cout << (int)st.size() << "\n"; } int32_t main () { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ///// file int t = 1; // cin >> t; while (t --) { test_case(); } return 0; }
#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...