Submission #668631

#TimeUsernameProblemLanguageResultExecution timeMemory
668631600MihneaLightning Rod (NOI18_lightningrod)C++17
100 / 100
1585 ms76896 KiB
#include <bits/stdc++.h> using namespace std; struct T { int x; int y; }; bool eat(T a, T b) { return a.x <= b.x && a.y <= b.y; } signed main() { #ifdef ONPC freopen ("input.txt", "r", stdin); #endif // ONPC #ifndef ONPC ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #endif // ONPC int n; cin >> n; vector<T> stk; stk.reserve(n); for (int i = 1; i <= n; i++) { int x, y; cin >> x >> y; T cur = {-x - y, x - y}; if (stk.empty()) { stk.push_back(cur); } else { if (eat(stk.back(), cur)) { continue; } while (!stk.empty() && eat(cur, stk.back())) { stk.pop_back(); } stk.push_back(cur); } } cout << (int) stk.size() << "\n"; 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...