# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
865380 | Trisanu_Das | Lightning Rod (NOI18_lightningrod) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int n;
stack<pair<int, int> > s;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
int x, y; cin >> x >> y;
int mx = x + y, mn = x - y;
while(!s.empty() && s.top().ff >= mn) s.pop();
if(s.empty() || s.top().ss < mx) s.push({mn, mx});
}
cout << s.size() << '\n';
}