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 ll long long
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n;
int a,b;
map<int,int> mp;
int mx = -1;
int ans;
stack<int> s;
int main(){
IOS
cin >> n;
for(int i = 0; i < n; i++){
cin >> a >> b;
if(a + b <= mx){
continue;
}
mx = max(mx,a+b);
int val = max(a,b) - min(a,b);
while(s.size()>0){
if(s.top() >= val){
s.pop();
}
else break;
}
s.push(val);
}
cout << s.size();
}
# | 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... |