# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
865350 | 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 dp[10000005], n, mx;
stack<int> s;
int main(){
cin >> n;
for(int i = 0; i < n; i++){
int x, y; cin >> x >> y;
if(i == 0){
mx = x + y;
s.push_back(x - y);
}else if(mx < x + y){
while(!s.empty() && s.top() >= (x - y)) s.pop();
s.push(x - y);
mx = x + y;
}
cout << s.size() << '\n';
}
}