Submission #970497

#TimeUsernameProblemLanguageResultExecution timeMemory
970497NoMercyLightning Rod (NOI18_lightningrod)C++14
7 / 100
2029 ms105904 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> fi , array<int , 2> se) -> bool { return (abs(fi[0] - se[0]) <= abs(fi[1] - se[1])); }; for (int i = 0;i < n;i ++) { int x , y; cin >> x >> y; while (st.size() > 0 && check(st.top() , {x , y})) { st.pop(); } if (st.size() == 0 || check(st.top() , {x, y}) == false) { st.push({x , y}); } } cout << st.size() << "\n"; } int32_t main () { ///// 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...