#include <bits/stdc++.h>
#define lop(i,a,b) for(ll i = a; i < b; i++)
#define alop(i,v) for(auto &i: v)
#define in(v) for(auto &i: v) cin >> i;
#define ll long long
#define endl '\n'
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(p, x) memset(p, x, sizeof(p))
using namespace std;
ll mod = 1e9 + 7;
int main(){
ll n, m; cin >> n >> m;
ll arr[n + 1] = {}, dp[n + 1] = {};
lop(i, 0, n) cin >> arr[i + 1];
ll ans = -1;
for(int i = 1; i <= n; i++){
dp[i] = (m * i) >= arr[i];
for(int j = 1; j < i; j++){
if(arr[j] + m * (i - j) >= arr[i] && dp[j]) dp[i] = max(dp[i], dp[j] + 1);
}
ans = max(ans, dp[i]);
}
cout << n - ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 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 |
0 ms |
212 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 |
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 |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 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 |
0 ms |
212 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 |
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 |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
10 ms |
364 KB |
Output is correct |
21 |
Correct |
14 ms |
340 KB |
Output is correct |
22 |
Correct |
40 ms |
340 KB |
Output is correct |
23 |
Correct |
14 ms |
340 KB |
Output is correct |
24 |
Correct |
14 ms |
340 KB |
Output is correct |
25 |
Correct |
17 ms |
308 KB |
Output is correct |
26 |
Correct |
15 ms |
396 KB |
Output is correct |
27 |
Correct |
21 ms |
384 KB |
Output is correct |
28 |
Correct |
15 ms |
316 KB |
Output is correct |
29 |
Correct |
14 ms |
340 KB |
Output is correct |
30 |
Correct |
15 ms |
388 KB |
Output is correct |
31 |
Correct |
12 ms |
388 KB |
Output is correct |
32 |
Correct |
16 ms |
396 KB |
Output is correct |
33 |
Correct |
14 ms |
312 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
10 ms |
364 KB |
Output is correct |
5 |
Correct |
14 ms |
340 KB |
Output is correct |
6 |
Correct |
40 ms |
340 KB |
Output is correct |
7 |
Correct |
14 ms |
340 KB |
Output is correct |
8 |
Correct |
14 ms |
340 KB |
Output is correct |
9 |
Correct |
17 ms |
308 KB |
Output is correct |
10 |
Correct |
15 ms |
396 KB |
Output is correct |
11 |
Correct |
21 ms |
384 KB |
Output is correct |
12 |
Correct |
15 ms |
316 KB |
Output is correct |
13 |
Correct |
14 ms |
340 KB |
Output is correct |
14 |
Correct |
15 ms |
388 KB |
Output is correct |
15 |
Correct |
12 ms |
388 KB |
Output is correct |
16 |
Correct |
16 ms |
396 KB |
Output is correct |
17 |
Correct |
14 ms |
312 KB |
Output is correct |
18 |
Correct |
1 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 |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
0 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 |
0 ms |
212 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 |
212 KB |
Output is correct |
30 |
Correct |
1 ms |
212 KB |
Output is correct |
31 |
Correct |
1 ms |
212 KB |
Output is correct |
32 |
Correct |
1 ms |
212 KB |
Output is correct |
33 |
Correct |
1 ms |
212 KB |
Output is correct |
34 |
Correct |
36 ms |
400 KB |
Output is correct |
35 |
Correct |
37 ms |
412 KB |
Output is correct |
36 |
Correct |
36 ms |
340 KB |
Output is correct |
37 |
Correct |
17 ms |
320 KB |
Output is correct |
38 |
Correct |
21 ms |
340 KB |
Output is correct |
39 |
Correct |
15 ms |
412 KB |
Output is correct |
40 |
Correct |
14 ms |
388 KB |
Output is correct |
41 |
Correct |
17 ms |
340 KB |
Output is correct |
42 |
Correct |
18 ms |
340 KB |
Output is correct |
43 |
Correct |
15 ms |
396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
400 KB |
Output is correct |
2 |
Correct |
37 ms |
412 KB |
Output is correct |
3 |
Correct |
36 ms |
340 KB |
Output is correct |
4 |
Correct |
17 ms |
320 KB |
Output is correct |
5 |
Correct |
21 ms |
340 KB |
Output is correct |
6 |
Correct |
15 ms |
412 KB |
Output is correct |
7 |
Correct |
14 ms |
388 KB |
Output is correct |
8 |
Correct |
17 ms |
340 KB |
Output is correct |
9 |
Correct |
18 ms |
340 KB |
Output is correct |
10 |
Correct |
15 ms |
396 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 |
10 ms |
364 KB |
Output is correct |
15 |
Correct |
14 ms |
340 KB |
Output is correct |
16 |
Correct |
40 ms |
340 KB |
Output is correct |
17 |
Correct |
14 ms |
340 KB |
Output is correct |
18 |
Correct |
14 ms |
340 KB |
Output is correct |
19 |
Correct |
17 ms |
308 KB |
Output is correct |
20 |
Correct |
15 ms |
396 KB |
Output is correct |
21 |
Correct |
21 ms |
384 KB |
Output is correct |
22 |
Correct |
15 ms |
316 KB |
Output is correct |
23 |
Correct |
14 ms |
340 KB |
Output is correct |
24 |
Correct |
15 ms |
388 KB |
Output is correct |
25 |
Correct |
12 ms |
388 KB |
Output is correct |
26 |
Correct |
16 ms |
396 KB |
Output is correct |
27 |
Correct |
14 ms |
312 KB |
Output is correct |
28 |
Correct |
1 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 |
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 |
0 ms |
212 KB |
Output is correct |
35 |
Correct |
0 ms |
212 KB |
Output is correct |
36 |
Correct |
0 ms |
212 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 |
212 KB |
Output is correct |
40 |
Correct |
1 ms |
212 KB |
Output is correct |
41 |
Correct |
1 ms |
212 KB |
Output is correct |
42 |
Correct |
1 ms |
212 KB |
Output is correct |
43 |
Correct |
1 ms |
212 KB |
Output is correct |
44 |
Execution timed out |
1082 ms |
3772 KB |
Time limit exceeded |
45 |
Halted |
0 ms |
0 KB |
- |