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;
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define pii pair<int, int>
#define f first
#define s second
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int n; cin >> n;
bool covered[n] = {}; pii A[n]; int H = -1; vector<pii> S;
FOR(i, 0, n){
cin >> A[i].f >> A[i].s;
while (!S.empty() and S.back().f >= A[i].f - A[i].s){
covered[S.back().s] = 1;
S.pop_back();
}
if (A[i].f + A[i].s > H){
S.push_back({A[i].f - A[i].s, i});
H = max(H, A[i].f + A[i].s);
}
}
cout<<S.size()<<endl;
}
# | 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... |