Submission #743830

#TimeUsernameProblemLanguageResultExecution timeMemory
743830vjudge1Lightning Rod (NOI18_lightningrod)C++17
100 / 100
1688 ms82124 KiB
#include <bits/stdc++.h> #define x first #define y second using namespace std; stack<pair<int,int>> st; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; while (n--) { int a,b; cin >> a >> b; if (!st.empty() && abs(a - st.top().x) <= st.top().y - b) continue; while (!st.empty() && abs(a - st.top().x) <= b - st.top().y) st.pop(); st.push({a, b}); } cout << st.size(); 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...