Submission #1187480

#TimeUsernameProblemLanguageResultExecution timeMemory
1187480nxdxmeLightning Rod (NOI18_lightningrod)C++20
66 / 100
1097 ms27288 KiB
#include<bits/stdc++.h> using namespace std; int n, x, y; stack<pair<int, int>> st; int main() { // cin.tie(nullptr)->sync_with_stdio(false); cin >> n; for (int i = 0; i < n; ++i) { cin >> x >> y; if (st.empty()) { st.emplace(x, y); continue; } auto [tx, ty] = st.top(); if (abs(tx - x) <= ty - y) { continue; } while (not st.empty() and abs(x - st.top().first) <= y - st.top().second) { st.pop(); } st.emplace(x, y); } cout << st.size() << '\n'; while (not st.empty()) { auto [tx, ty] = st.top(); st.pop(); // cout << tx << ' ' << ty << '\n'; } }
#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...