#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll wej[200003][2];
void init(ll &n, ll &x){
cin >> n >> x;
set<ll> s;
map<ll,ll> mp;
ll iter=0;
for (ll i = 1; i<=n; i++){
cin >> wej[i][0];
s.insert(wej[i][0]);
wej[i][1]=wej[i][0]+x;
s.insert(wej[i][1]);
}
for (auto u : s)mp[u]=++iter;
for (ll i = 1; i<=n; i++){
wej[i][0]=mp[wej[i][0]];
wej[i][1]=mp[wej[i][1]];
}
}
const ll base=1<<19;
ll tree[2*base][2];
void change(ll v, ll x, ll ind){
v+=base;
tree[v][ind]=x;
v>>=1;
while(v){
tree[v][ind]=max(tree[2*v][ind],tree[2*v+1][ind]);
v>>=1;
}
}
ll check(ll zas, ll ind){
zas+=base+1;
ll ans=0;
while(zas){
if (zas&1)ans=max(ans,tree[zas-1][ind]);
zas>>=1;
}
return ans;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n,x;
init(n,x);
for (ll i = 1; i<=n; i++){
change(wej[i][0],max(check(wej[i][0]-1,1),check(wej[i][1]-1,0))+1,1);
change(wej[i][0],check(wej[i][0]-1,0)+1,0);
}
cout << max(check(base-2,0),check(base-2,1)) << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4564 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4568 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4564 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4568 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
6492 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
2512 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
0 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4564 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4568 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
6492 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
2512 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
0 ms |
2396 KB |
Output is correct |
19 |
Correct |
2 ms |
6748 KB |
Output is correct |
20 |
Correct |
1 ms |
2652 KB |
Output is correct |
21 |
Correct |
1 ms |
2652 KB |
Output is correct |
22 |
Correct |
1 ms |
4700 KB |
Output is correct |
23 |
Correct |
1 ms |
2652 KB |
Output is correct |
24 |
Correct |
1 ms |
2652 KB |
Output is correct |
25 |
Correct |
1 ms |
2652 KB |
Output is correct |
26 |
Correct |
1 ms |
2652 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
303 ms |
37276 KB |
Output is correct |
2 |
Correct |
296 ms |
37968 KB |
Output is correct |
3 |
Correct |
287 ms |
38612 KB |
Output is correct |
4 |
Correct |
269 ms |
36552 KB |
Output is correct |
5 |
Correct |
123 ms |
26192 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
79 ms |
19028 KB |
Output is correct |
2 |
Correct |
77 ms |
20560 KB |
Output is correct |
3 |
Correct |
67 ms |
20408 KB |
Output is correct |
4 |
Correct |
36 ms |
13648 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
37 ms |
11900 KB |
Output is correct |
7 |
Correct |
62 ms |
16728 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
227 ms |
32340 KB |
Output is correct |
2 |
Correct |
207 ms |
32284 KB |
Output is correct |
3 |
Correct |
465 ms |
57936 KB |
Output is correct |
4 |
Correct |
166 ms |
35168 KB |
Output is correct |
5 |
Correct |
139 ms |
30036 KB |
Output is correct |
6 |
Correct |
239 ms |
57332 KB |
Output is correct |
7 |
Correct |
246 ms |
57936 KB |
Output is correct |
8 |
Correct |
161 ms |
30548 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4564 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4568 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
6492 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
2512 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
0 ms |
2396 KB |
Output is correct |
19 |
Correct |
2 ms |
6748 KB |
Output is correct |
20 |
Correct |
1 ms |
2652 KB |
Output is correct |
21 |
Correct |
1 ms |
2652 KB |
Output is correct |
22 |
Correct |
1 ms |
4700 KB |
Output is correct |
23 |
Correct |
1 ms |
2652 KB |
Output is correct |
24 |
Correct |
1 ms |
2652 KB |
Output is correct |
25 |
Correct |
1 ms |
2652 KB |
Output is correct |
26 |
Correct |
1 ms |
2652 KB |
Output is correct |
27 |
Correct |
303 ms |
37276 KB |
Output is correct |
28 |
Correct |
296 ms |
37968 KB |
Output is correct |
29 |
Correct |
287 ms |
38612 KB |
Output is correct |
30 |
Correct |
269 ms |
36552 KB |
Output is correct |
31 |
Correct |
123 ms |
26192 KB |
Output is correct |
32 |
Correct |
79 ms |
19028 KB |
Output is correct |
33 |
Correct |
77 ms |
20560 KB |
Output is correct |
34 |
Correct |
67 ms |
20408 KB |
Output is correct |
35 |
Correct |
36 ms |
13648 KB |
Output is correct |
36 |
Correct |
0 ms |
2396 KB |
Output is correct |
37 |
Correct |
37 ms |
11900 KB |
Output is correct |
38 |
Correct |
62 ms |
16728 KB |
Output is correct |
39 |
Correct |
227 ms |
32340 KB |
Output is correct |
40 |
Correct |
207 ms |
32284 KB |
Output is correct |
41 |
Correct |
465 ms |
57936 KB |
Output is correct |
42 |
Correct |
166 ms |
35168 KB |
Output is correct |
43 |
Correct |
139 ms |
30036 KB |
Output is correct |
44 |
Correct |
239 ms |
57332 KB |
Output is correct |
45 |
Correct |
246 ms |
57936 KB |
Output is correct |
46 |
Correct |
161 ms |
30548 KB |
Output is correct |
47 |
Correct |
163 ms |
33616 KB |
Output is correct |
48 |
Correct |
162 ms |
34396 KB |
Output is correct |
49 |
Correct |
408 ms |
64960 KB |
Output is correct |
50 |
Correct |
168 ms |
34784 KB |
Output is correct |
51 |
Correct |
125 ms |
26708 KB |
Output is correct |
52 |
Correct |
184 ms |
36192 KB |
Output is correct |
53 |
Correct |
267 ms |
59732 KB |
Output is correct |
54 |
Correct |
304 ms |
60448 KB |
Output is correct |
55 |
Correct |
303 ms |
55020 KB |
Output is correct |