#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5, M = 11, inf = 1e9 + 5, mod = 1e9 + 7;
long long dp[N];
long long n, m;
long long arr[N];
int main()
{
cin >> n >> m;
dp[0] = 0;
long long mx = 0;
for (long long i = 1; i <= n; i++)
dp[i] = -inf;
for (long long i = 1; i <= n; i++)
{
cin >> arr[i];
for (long long j = i - 1; j >= 0; j--)
{
if (arr[j] + m * (i - j) >= arr[i])
{
dp[i] = max(dp[i], dp[j] + 1), mx = max(mx, dp[i]);
// cout << i << " " << j << "\n";
}
}
}
cout << n - mx;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
308 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
308 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
304 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
308 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
308 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
304 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
304 KB |
Output is correct |
19 |
Correct |
1 ms |
308 KB |
Output is correct |
20 |
Correct |
13 ms |
308 KB |
Output is correct |
21 |
Correct |
17 ms |
388 KB |
Output is correct |
22 |
Correct |
36 ms |
396 KB |
Output is correct |
23 |
Correct |
17 ms |
320 KB |
Output is correct |
24 |
Correct |
17 ms |
408 KB |
Output is correct |
25 |
Correct |
17 ms |
324 KB |
Output is correct |
26 |
Correct |
17 ms |
400 KB |
Output is correct |
27 |
Correct |
17 ms |
396 KB |
Output is correct |
28 |
Correct |
18 ms |
320 KB |
Output is correct |
29 |
Correct |
17 ms |
340 KB |
Output is correct |
30 |
Correct |
17 ms |
392 KB |
Output is correct |
31 |
Correct |
13 ms |
340 KB |
Output is correct |
32 |
Correct |
17 ms |
340 KB |
Output is correct |
33 |
Correct |
17 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
308 KB |
Output is correct |
4 |
Correct |
13 ms |
308 KB |
Output is correct |
5 |
Correct |
17 ms |
388 KB |
Output is correct |
6 |
Correct |
36 ms |
396 KB |
Output is correct |
7 |
Correct |
17 ms |
320 KB |
Output is correct |
8 |
Correct |
17 ms |
408 KB |
Output is correct |
9 |
Correct |
17 ms |
324 KB |
Output is correct |
10 |
Correct |
17 ms |
400 KB |
Output is correct |
11 |
Correct |
17 ms |
396 KB |
Output is correct |
12 |
Correct |
18 ms |
320 KB |
Output is correct |
13 |
Correct |
17 ms |
340 KB |
Output is correct |
14 |
Correct |
17 ms |
392 KB |
Output is correct |
15 |
Correct |
13 ms |
340 KB |
Output is correct |
16 |
Correct |
17 ms |
340 KB |
Output is correct |
17 |
Correct |
17 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
308 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
0 ms |
212 KB |
Output is correct |
25 |
Correct |
0 ms |
212 KB |
Output is correct |
26 |
Correct |
1 ms |
308 KB |
Output is correct |
27 |
Correct |
0 ms |
212 KB |
Output is correct |
28 |
Correct |
0 ms |
212 KB |
Output is correct |
29 |
Correct |
0 ms |
304 KB |
Output is correct |
30 |
Correct |
0 ms |
212 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Correct |
0 ms |
212 KB |
Output is correct |
33 |
Correct |
0 ms |
212 KB |
Output is correct |
34 |
Correct |
37 ms |
424 KB |
Output is correct |
35 |
Correct |
37 ms |
424 KB |
Output is correct |
36 |
Correct |
37 ms |
404 KB |
Output is correct |
37 |
Correct |
17 ms |
340 KB |
Output is correct |
38 |
Correct |
18 ms |
432 KB |
Output is correct |
39 |
Correct |
18 ms |
428 KB |
Output is correct |
40 |
Correct |
13 ms |
320 KB |
Output is correct |
41 |
Correct |
17 ms |
396 KB |
Output is correct |
42 |
Correct |
17 ms |
400 KB |
Output is correct |
43 |
Correct |
17 ms |
408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
424 KB |
Output is correct |
2 |
Correct |
37 ms |
424 KB |
Output is correct |
3 |
Correct |
37 ms |
404 KB |
Output is correct |
4 |
Correct |
17 ms |
340 KB |
Output is correct |
5 |
Correct |
18 ms |
432 KB |
Output is correct |
6 |
Correct |
18 ms |
428 KB |
Output is correct |
7 |
Correct |
13 ms |
320 KB |
Output is correct |
8 |
Correct |
17 ms |
396 KB |
Output is correct |
9 |
Correct |
17 ms |
400 KB |
Output is correct |
10 |
Correct |
17 ms |
408 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
304 KB |
Output is correct |
13 |
Correct |
1 ms |
308 KB |
Output is correct |
14 |
Correct |
13 ms |
308 KB |
Output is correct |
15 |
Correct |
17 ms |
388 KB |
Output is correct |
16 |
Correct |
36 ms |
396 KB |
Output is correct |
17 |
Correct |
17 ms |
320 KB |
Output is correct |
18 |
Correct |
17 ms |
408 KB |
Output is correct |
19 |
Correct |
17 ms |
324 KB |
Output is correct |
20 |
Correct |
17 ms |
400 KB |
Output is correct |
21 |
Correct |
17 ms |
396 KB |
Output is correct |
22 |
Correct |
18 ms |
320 KB |
Output is correct |
23 |
Correct |
17 ms |
340 KB |
Output is correct |
24 |
Correct |
17 ms |
392 KB |
Output is correct |
25 |
Correct |
13 ms |
340 KB |
Output is correct |
26 |
Correct |
17 ms |
340 KB |
Output is correct |
27 |
Correct |
17 ms |
340 KB |
Output is correct |
28 |
Correct |
0 ms |
212 KB |
Output is correct |
29 |
Correct |
0 ms |
212 KB |
Output is correct |
30 |
Correct |
1 ms |
212 KB |
Output is correct |
31 |
Correct |
0 ms |
308 KB |
Output is correct |
32 |
Correct |
0 ms |
212 KB |
Output is correct |
33 |
Correct |
1 ms |
212 KB |
Output is correct |
34 |
Correct |
0 ms |
212 KB |
Output is correct |
35 |
Correct |
0 ms |
212 KB |
Output is correct |
36 |
Correct |
1 ms |
308 KB |
Output is correct |
37 |
Correct |
0 ms |
212 KB |
Output is correct |
38 |
Correct |
0 ms |
212 KB |
Output is correct |
39 |
Correct |
0 ms |
304 KB |
Output is correct |
40 |
Correct |
0 ms |
212 KB |
Output is correct |
41 |
Correct |
0 ms |
212 KB |
Output is correct |
42 |
Correct |
0 ms |
212 KB |
Output is correct |
43 |
Correct |
0 ms |
212 KB |
Output is correct |
44 |
Execution timed out |
1074 ms |
2348 KB |
Time limit exceeded |
45 |
Halted |
0 ms |
0 KB |
- |