#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define two pair<int,int>
#define pb push_front
#define f first
#define s second
#define sz(container) (int)(container.size())
inline int bin(int &x){
x=0;
char ch=getchar_unlocked();
while (ch<'0'||ch>'9') ch=getchar_unlocked();
while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar_unlocked();
return x;
}
int n,x,y;
deque<two>st;
int main(){
bin(n);
while(n--){
bin(x);
y=bin(y);
bool ok=1;
while(!st.empty()){
int a=st.front().f;
int b=st.front().s;
if(x-a<=b-y){
ok=0;
break;
}
if(x-a<=y-b){
st.pop_front();
}else{
break;
}
}
if(ok){
st.pb({x,y});
}
}
printf("%d\n",sz(st));
// you should actually read the stuff at the bottom
}
/* stuff you should look for
* int overflow, array bounds
* special cases (n=1?), slow multiset operations
* do smth instead of nothing and stay organized
* unordered_map, hash_map, scanf, calculate answer instead of ans*K
*/
/*
* *
* * * *
* * * *
* * * *
* * * * *
* * * *
* * * *
* * *
* *
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
444 ms |
191108 KB |
Output is correct |
2 |
Correct |
459 ms |
189516 KB |
Output is correct |
3 |
Correct |
429 ms |
186664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
356 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
356 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
276 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
356 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
276 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
356 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
276 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
400 KB |
Output is correct |
14 |
Correct |
15 ms |
4048 KB |
Output is correct |
15 |
Correct |
13 ms |
3632 KB |
Output is correct |
16 |
Correct |
14 ms |
3796 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
443 ms |
147584 KB |
Output is correct |
2 |
Correct |
437 ms |
147476 KB |
Output is correct |
3 |
Correct |
429 ms |
143776 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
444 ms |
191108 KB |
Output is correct |
2 |
Correct |
459 ms |
189516 KB |
Output is correct |
3 |
Correct |
429 ms |
186664 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
364 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
356 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
276 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
400 KB |
Output is correct |
17 |
Correct |
15 ms |
4048 KB |
Output is correct |
18 |
Correct |
13 ms |
3632 KB |
Output is correct |
19 |
Correct |
14 ms |
3796 KB |
Output is correct |
20 |
Correct |
443 ms |
147584 KB |
Output is correct |
21 |
Correct |
437 ms |
147476 KB |
Output is correct |
22 |
Correct |
429 ms |
143776 KB |
Output is correct |
23 |
Correct |
583 ms |
175492 KB |
Output is correct |
24 |
Correct |
514 ms |
156072 KB |
Output is correct |
25 |
Correct |
480 ms |
140336 KB |
Output is correct |