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>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define F first
#define S second
#define pb push_back
using namespace std;
stack<pair<int, int > > st;
int check(pair<int, int > a, pair<int, int > b) {
int c = b.F - a.F;
if (a.S - b.S >= c) return 1;
if (b.S - a.S >= c) return 2;
return 0;
}
void solve() {
int n; cin >> n;
for (int i = 0; i < n; i++) {
int a, b; cin >> a >> b;
if (i == 0) {st.push({a, b}); continue ;}
while (!st.empty()) {
if (st.size() == 1) break ;
int x = check(st.top(), {a, b});
if (x == 2) st.pop();
else if (x == 1) break ;
else {st.push({a, b}); break ;}
}
}
cout << st.size();
}
signed main(){IOS solve(); return 0;}
# | 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... |