Submission #743087

#TimeUsernameProblemLanguageResultExecution timeMemory
743087JooLightning Rod (NOI18_lightningrod)C++17
100 / 100
397 ms79684 KiB
#include <bits/stdc++.h> using namespace std; bool isContain(pair<int, int> &a, pair<int, int> &b) { return (abs(a.first - b.first) <= a.second - b.second); } inline void read(int &x) { x = 0; char ch = getchar_unlocked(); while (ch & 16) { x = (x << 3) + (x << 1) + (ch & 15); ch = getchar_unlocked(); } } int main() { cin.tie(0)->sync_with_stdio(0); int n; read(n); stack<pair<int, int>> st; for (int i = 1; i <= n; i++) { pair<int, int> tmp; int x, y; read(x), read(y); tmp = {x, y}; while (!st.empty() and isContain(tmp, st.top())) st.pop(); if (st.empty() or !isContain(st.top(), tmp)) st.push(tmp); } cout << st.size() << "\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...