Submission #785524

#TimeUsernameProblemLanguageResultExecution timeMemory
78552412345678Lightning Rod (NOI18_lightningrod)C++17
100 / 100
1501 ms191652 KiB
#include <bits/stdc++.h> using namespace std; int n, x, y, h; stack<pair<int, int>> s; int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n; for (int i=1; i<=n; i++) { cin>>x>>y; if (s.empty()) { s.push({x, y}); continue; } if (s.top().second-y>=x-s.top().first) continue; while (!s.empty()&&y-s.top().second>=x-s.top().first) s.pop(); s.push({x, y}); } cout<<s.size(); }
#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...