#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 |
1 |
Correct |
1356 ms |
88484 KB |
Output is correct |
2 |
Correct |
1378 ms |
82956 KB |
Output is correct |
3 |
Correct |
1289 ms |
66316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1358 ms |
43812 KB |
Output is correct |
2 |
Correct |
1349 ms |
92696 KB |
Output is correct |
3 |
Correct |
1383 ms |
87184 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1356 ms |
88484 KB |
Output is correct |
2 |
Correct |
1378 ms |
82956 KB |
Output is correct |
3 |
Correct |
1289 ms |
66316 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |