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 main(){
cin.tie(NULL)->sync_with_stdio(false);
int n; cin >> n;
stack<pair<int,int>> s;
int a,b; cin >> a >> b;
s.push({a,b});
for(int ti=2 ; ti<=n ; ti++){
int a,b; cin >> a >> b;
bool bo=false;
while(!s.empty() && a-s.top().first<=b-s.top().second){
s.pop();
b=true;
}
if(bo){
s.push({a,b});
continue;
}
if(abs(s.top().first-a)<=s.top().second-b){
continue;
}
s.push({a,b});
}
cout << s.size() << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |