#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
const long long MAXN = 2e5+5;
long long arr[MAXN];
long long d[MAXN];
int main(){
long long n,k;
cin>>n>>k;
const long long INF = 1e18;
vector<long long> d(n+2, -INF);
d[n+1] = 0;
for(long long i=1;i<=n;i++){
cin>>arr[i];
arr[i]-=(k*i);
}
for(long long i=1;i<=n;i++){
long long j = lower_bound(d.begin(), d.end(), arr[i]) - d.begin();
if(j<=(n+1) && d[j-1]<=arr[i] && d[j]>=arr[i]){
d[j-1] = arr[i];
}
// cout<<arr[i]<<" "<<j<<endl;
}
long long ans = 0;
for(long long i=1;i<=n;i++){
if(d[i]!=-1e18){
ans = max(ans,n-i+1);
}
}
cout<<n-ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correctzzz |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
276 KB |
Output is correctzzz |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correctzzz |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
228 KB |
Output is correctzzz |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
216 KB |
Output is correctzzz |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correctzzz |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
280 KB |
Output is correctzzz |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correctzzz |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correctzzz |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
276 KB |
Output is correctzzz |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correctzzz |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
228 KB |
Output is correctzzz |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
216 KB |
Output is correctzzz |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correctzzz |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
280 KB |
Output is correctzzz |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correctzzz |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correctzzz |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correctzzz |
21 |
Correct |
2 ms |
332 KB |
Output is correct |
22 |
Correct |
2 ms |
360 KB |
Output is correctzzz |
23 |
Correct |
3 ms |
332 KB |
Output is correct |
24 |
Correct |
2 ms |
332 KB |
Output is correctzzz |
25 |
Correct |
2 ms |
332 KB |
Output is correct |
26 |
Correct |
2 ms |
332 KB |
Output is correctzzz |
27 |
Correct |
3 ms |
332 KB |
Output is correct |
28 |
Correct |
3 ms |
332 KB |
Output is correctzzz |
29 |
Correct |
2 ms |
332 KB |
Output is correct |
30 |
Correct |
2 ms |
332 KB |
Output is correctzzz |
31 |
Correct |
2 ms |
332 KB |
Output is correct |
32 |
Correct |
2 ms |
332 KB |
Output is correctzzz |
33 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correctzzz |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correctzzz |
5 |
Correct |
2 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
360 KB |
Output is correctzzz |
7 |
Correct |
3 ms |
332 KB |
Output is correct |
8 |
Correct |
2 ms |
332 KB |
Output is correctzzz |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correctzzz |
11 |
Correct |
3 ms |
332 KB |
Output is correct |
12 |
Correct |
3 ms |
332 KB |
Output is correctzzz |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
2 ms |
332 KB |
Output is correctzzz |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
332 KB |
Output is correctzzz |
17 |
Correct |
2 ms |
332 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correctzzz |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
276 KB |
Output is correctzzz |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
1 ms |
204 KB |
Output is correctzzz |
24 |
Correct |
1 ms |
204 KB |
Output is correct |
25 |
Correct |
1 ms |
228 KB |
Output is correctzzz |
26 |
Correct |
0 ms |
204 KB |
Output is correct |
27 |
Correct |
0 ms |
216 KB |
Output is correctzzz |
28 |
Correct |
1 ms |
204 KB |
Output is correct |
29 |
Correct |
0 ms |
204 KB |
Output is correctzzz |
30 |
Correct |
1 ms |
204 KB |
Output is correct |
31 |
Correct |
0 ms |
280 KB |
Output is correctzzz |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Correct |
0 ms |
204 KB |
Output is correctzzz |
34 |
Correct |
3 ms |
332 KB |
Output is correct |
35 |
Correct |
4 ms |
332 KB |
Output is correct |
36 |
Correct |
3 ms |
332 KB |
Output is correct |
37 |
Correct |
2 ms |
332 KB |
Output is correct |
38 |
Correct |
3 ms |
332 KB |
Output is correct |
39 |
Correct |
2 ms |
348 KB |
Output is correct |
40 |
Correct |
2 ms |
332 KB |
Output is correct |
41 |
Correct |
2 ms |
332 KB |
Output is correct |
42 |
Correct |
2 ms |
332 KB |
Output is correct |
43 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
332 KB |
Output is correct |
2 |
Correct |
4 ms |
332 KB |
Output is correct |
3 |
Correct |
3 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
3 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
2 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correctzzz |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correctzzz |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
360 KB |
Output is correctzzz |
17 |
Correct |
3 ms |
332 KB |
Output is correct |
18 |
Correct |
2 ms |
332 KB |
Output is correctzzz |
19 |
Correct |
2 ms |
332 KB |
Output is correct |
20 |
Correct |
2 ms |
332 KB |
Output is correctzzz |
21 |
Correct |
3 ms |
332 KB |
Output is correct |
22 |
Correct |
3 ms |
332 KB |
Output is correctzzz |
23 |
Correct |
2 ms |
332 KB |
Output is correct |
24 |
Correct |
2 ms |
332 KB |
Output is correctzzz |
25 |
Correct |
2 ms |
332 KB |
Output is correct |
26 |
Correct |
2 ms |
332 KB |
Output is correctzzz |
27 |
Correct |
2 ms |
332 KB |
Output is correct |
28 |
Correct |
0 ms |
204 KB |
Output is correct |
29 |
Correct |
1 ms |
204 KB |
Output is correctzzz |
30 |
Correct |
0 ms |
204 KB |
Output is correct |
31 |
Correct |
1 ms |
276 KB |
Output is correctzzz |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Correct |
1 ms |
204 KB |
Output is correctzzz |
34 |
Correct |
1 ms |
204 KB |
Output is correct |
35 |
Correct |
1 ms |
228 KB |
Output is correctzzz |
36 |
Correct |
0 ms |
204 KB |
Output is correct |
37 |
Correct |
0 ms |
216 KB |
Output is correctzzz |
38 |
Correct |
1 ms |
204 KB |
Output is correct |
39 |
Correct |
0 ms |
204 KB |
Output is correctzzz |
40 |
Correct |
1 ms |
204 KB |
Output is correct |
41 |
Correct |
0 ms |
280 KB |
Output is correctzzz |
42 |
Correct |
1 ms |
204 KB |
Output is correct |
43 |
Correct |
0 ms |
204 KB |
Output is correctzzz |
44 |
Correct |
38 ms |
3376 KB |
Output is correct |
45 |
Correct |
87 ms |
3376 KB |
Output is correctzzz |
46 |
Correct |
89 ms |
3432 KB |
Output is correct |
47 |
Correct |
95 ms |
3320 KB |
Output is correctzzz |
48 |
Correct |
53 ms |
3420 KB |
Output is correct |
49 |
Correct |
59 ms |
3396 KB |
Output is correctzzz |
50 |
Correct |
88 ms |
3320 KB |
Output is correct |
51 |
Correct |
80 ms |
3424 KB |
Output is correctzzz |
52 |
Correct |
58 ms |
3492 KB |
Output is correct |
53 |
Correct |
67 ms |
3300 KB |
Output is correctzzz |
54 |
Correct |
55 ms |
3336 KB |
Output is correct |
55 |
Correct |
80 ms |
3300 KB |
Output is correctzzz |