/*
TASK:
LANG: CPP
AUTHOR: WasreK
ALGO:
TYPE: BATCH
SCORE:
*/
#include<bits/stdc++.h>
using namespace std;
int a[200010],lis1[200010],lis2[200010],L[200010],R[200010];
int main()
{
int idx,n,x,cnt=0,ans=0;
scanf("%d %d",&n,&x);
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
idx=lower_bound(lis1,lis1+cnt,a[i])-lis1;
if(idx==cnt) cnt++;
lis1[idx]=a[i];
L[i]=idx+1;
}
ans=cnt;
cnt=0;
int tor;
for(int i=n;i>=1;i--){
a[i]*=-1;
tor=lower_bound(lis2,lis2+cnt,a[i]+x)-lis2;
ans=max(ans,L[i]+tor);
idx=lower_bound(lis2,lis2+cnt,a[i])-lis2;
if(idx==cnt) cnt++;
lis2[idx]=a[i];
}
printf("%d\n",ans);
return 0;
}
Compilation message
glo.cpp: In function 'int main()':
glo.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
15 | scanf("%d %d",&n,&x);
| ~~~~~^~~~~~~~~~~~~~~
glo.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
17 | scanf("%d",&a[i]);
| ~~~~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
316 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
316 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
316 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
312 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
312 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
1876 KB |
Output is correct |
2 |
Correct |
52 ms |
3788 KB |
Output is correct |
3 |
Correct |
53 ms |
3680 KB |
Output is correct |
4 |
Correct |
56 ms |
3772 KB |
Output is correct |
5 |
Correct |
32 ms |
3812 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
596 KB |
Output is correct |
2 |
Correct |
13 ms |
1108 KB |
Output is correct |
3 |
Correct |
12 ms |
1088 KB |
Output is correct |
4 |
Correct |
8 ms |
1092 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
8 ms |
1092 KB |
Output is correct |
7 |
Correct |
13 ms |
1164 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
992 KB |
Output is correct |
2 |
Correct |
24 ms |
1112 KB |
Output is correct |
3 |
Correct |
50 ms |
1752 KB |
Output is correct |
4 |
Correct |
31 ms |
2604 KB |
Output is correct |
5 |
Correct |
14 ms |
1496 KB |
Output is correct |
6 |
Correct |
24 ms |
2532 KB |
Output is correct |
7 |
Correct |
30 ms |
2492 KB |
Output is correct |
8 |
Correct |
19 ms |
1108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
316 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
312 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
312 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
54 ms |
1876 KB |
Output is correct |
28 |
Correct |
52 ms |
3788 KB |
Output is correct |
29 |
Correct |
53 ms |
3680 KB |
Output is correct |
30 |
Correct |
56 ms |
3772 KB |
Output is correct |
31 |
Correct |
32 ms |
3812 KB |
Output is correct |
32 |
Correct |
12 ms |
596 KB |
Output is correct |
33 |
Correct |
13 ms |
1108 KB |
Output is correct |
34 |
Correct |
12 ms |
1088 KB |
Output is correct |
35 |
Correct |
8 ms |
1092 KB |
Output is correct |
36 |
Correct |
1 ms |
212 KB |
Output is correct |
37 |
Correct |
8 ms |
1092 KB |
Output is correct |
38 |
Correct |
13 ms |
1164 KB |
Output is correct |
39 |
Correct |
23 ms |
992 KB |
Output is correct |
40 |
Correct |
24 ms |
1112 KB |
Output is correct |
41 |
Correct |
50 ms |
1752 KB |
Output is correct |
42 |
Correct |
31 ms |
2604 KB |
Output is correct |
43 |
Correct |
14 ms |
1496 KB |
Output is correct |
44 |
Correct |
24 ms |
2532 KB |
Output is correct |
45 |
Correct |
30 ms |
2492 KB |
Output is correct |
46 |
Correct |
19 ms |
1108 KB |
Output is correct |
47 |
Correct |
28 ms |
2052 KB |
Output is correct |
48 |
Correct |
29 ms |
1996 KB |
Output is correct |
49 |
Correct |
54 ms |
3800 KB |
Output is correct |
50 |
Correct |
30 ms |
3784 KB |
Output is correct |
51 |
Correct |
25 ms |
3028 KB |
Output is correct |
52 |
Correct |
30 ms |
3900 KB |
Output is correct |
53 |
Correct |
25 ms |
3788 KB |
Output is correct |
54 |
Correct |
36 ms |
4580 KB |
Output is correct |
55 |
Correct |
44 ms |
3828 KB |
Output is correct |