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[10000010], n, mx;
stack<int> s;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
int x, y; cin >> x >> y;
if (i == 1) {
mx = x + y;
s.push(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';
}
# | 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... |