Submission #770893

# Submission time Handle Problem Language Result Execution time Memory
770893 2023-07-02T05:50:12 Z The_Samurai Rabbit Carrot (LMIO19_triusis) C++17
63 / 100
1000 ms 2260 KB
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const int inf = 1e9;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n + 1), dp(n + 1, -inf);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        dp[n] = max(dp[n], dp[i]);
        for (int j = i + 1; j <= n; j++) {
            if (a[j] <= a[i] + m * (j - i)) {
                dp[j] = max(dp[j], dp[i] + 1);
            }
        }
    }
    cout << n - dp[n];
}

int main() {
    ios_base::sync_with_stdio(false);
    cout.tie(nullptr);
    cin.tie(nullptr);

    int queries = 1;
#ifdef test_cases
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    cin >> queries;
#else
    //    cin >> queries;
#endif

    for (int test_case = 1; test_case <= queries; test_case++) {
        solve();
        cout << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 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 1 ms 212 KB Output is correct
12 Correct 1 ms 212 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 320 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 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 1 ms 212 KB Output is correct
12 Correct 1 ms 212 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 320 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 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 10 ms 356 KB Output is correct
21 Correct 14 ms 340 KB Output is correct
22 Correct 37 ms 336 KB Output is correct
23 Correct 16 ms 384 KB Output is correct
24 Correct 14 ms 324 KB Output is correct
25 Correct 14 ms 380 KB Output is correct
26 Correct 23 ms 340 KB Output is correct
27 Correct 17 ms 340 KB Output is correct
28 Correct 15 ms 384 KB Output is correct
29 Correct 14 ms 372 KB Output is correct
30 Correct 14 ms 340 KB Output is correct
31 Correct 12 ms 376 KB Output is correct
32 Correct 25 ms 332 KB Output is correct
33 Correct 14 ms 380 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 10 ms 356 KB Output is correct
5 Correct 14 ms 340 KB Output is correct
6 Correct 37 ms 336 KB Output is correct
7 Correct 16 ms 384 KB Output is correct
8 Correct 14 ms 324 KB Output is correct
9 Correct 14 ms 380 KB Output is correct
10 Correct 23 ms 340 KB Output is correct
11 Correct 17 ms 340 KB Output is correct
12 Correct 15 ms 384 KB Output is correct
13 Correct 14 ms 372 KB Output is correct
14 Correct 14 ms 340 KB Output is correct
15 Correct 12 ms 376 KB Output is correct
16 Correct 25 ms 332 KB Output is correct
17 Correct 14 ms 380 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 316 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 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 1 ms 212 KB Output is correct
29 Correct 1 ms 212 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 320 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 38 ms 340 KB Output is correct
35 Correct 38 ms 340 KB Output is correct
36 Correct 47 ms 388 KB Output is correct
37 Correct 15 ms 340 KB Output is correct
38 Correct 16 ms 340 KB Output is correct
39 Correct 14 ms 340 KB Output is correct
40 Correct 14 ms 340 KB Output is correct
41 Correct 15 ms 340 KB Output is correct
42 Correct 15 ms 340 KB Output is correct
43 Correct 21 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 340 KB Output is correct
2 Correct 38 ms 340 KB Output is correct
3 Correct 47 ms 388 KB Output is correct
4 Correct 15 ms 340 KB Output is correct
5 Correct 16 ms 340 KB Output is correct
6 Correct 14 ms 340 KB Output is correct
7 Correct 14 ms 340 KB Output is correct
8 Correct 15 ms 340 KB Output is correct
9 Correct 15 ms 340 KB Output is correct
10 Correct 21 ms 340 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 10 ms 356 KB Output is correct
15 Correct 14 ms 340 KB Output is correct
16 Correct 37 ms 336 KB Output is correct
17 Correct 16 ms 384 KB Output is correct
18 Correct 14 ms 324 KB Output is correct
19 Correct 14 ms 380 KB Output is correct
20 Correct 23 ms 340 KB Output is correct
21 Correct 17 ms 340 KB Output is correct
22 Correct 15 ms 384 KB Output is correct
23 Correct 14 ms 372 KB Output is correct
24 Correct 14 ms 340 KB Output is correct
25 Correct 12 ms 376 KB Output is correct
26 Correct 25 ms 332 KB Output is correct
27 Correct 14 ms 380 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 316 KB Output is correct
31 Correct 0 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 1 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 1 ms 212 KB Output is correct
39 Correct 1 ms 212 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 320 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Execution timed out 1071 ms 2260 KB Time limit exceeded
45 Halted 0 ms 0 KB -