Submission #770884

# Submission time Handle Problem Language Result Execution time Memory
770884 2023-07-02T05:39:24 Z The_Samurai Rabbit Carrot (LMIO19_triusis) C++17
63 / 100
1000 ms 2252 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] = min(dp[n], dp[i] + n - i);
        for (int j = i + 1; j <= n; j++) {
            if (a[j] <= a[i] + m * (j - i)) {
                dp[j] = min(dp[j], dp[i] + (j - i - 1));
            }
        }
//        cout << i << " -> " << dp[i] << endl;
    }
    cout << 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 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 320 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 0 ms 212 KB Output is correct
12 Correct 0 ms 320 KB Output is correct
13 Correct 0 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 0 ms 212 KB Output is correct
# Verdict Execution time Memory 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 320 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 0 ms 212 KB Output is correct
12 Correct 0 ms 320 KB Output is correct
13 Correct 0 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 0 ms 212 KB Output is correct
17 Correct 0 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 360 KB Output is correct
21 Correct 14 ms 372 KB Output is correct
22 Correct 40 ms 360 KB Output is correct
23 Correct 14 ms 380 KB Output is correct
24 Correct 14 ms 340 KB Output is correct
25 Correct 14 ms 384 KB Output is correct
26 Correct 14 ms 384 KB Output is correct
27 Correct 17 ms 340 KB Output is correct
28 Correct 14 ms 380 KB Output is correct
29 Correct 14 ms 368 KB Output is correct
30 Correct 14 ms 340 KB Output is correct
31 Correct 14 ms 332 KB Output is correct
32 Correct 14 ms 340 KB Output is correct
33 Correct 14 ms 384 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 10 ms 360 KB Output is correct
5 Correct 14 ms 372 KB Output is correct
6 Correct 40 ms 360 KB Output is correct
7 Correct 14 ms 380 KB Output is correct
8 Correct 14 ms 340 KB Output is correct
9 Correct 14 ms 384 KB Output is correct
10 Correct 14 ms 384 KB Output is correct
11 Correct 17 ms 340 KB Output is correct
12 Correct 14 ms 380 KB Output is correct
13 Correct 14 ms 368 KB Output is correct
14 Correct 14 ms 340 KB Output is correct
15 Correct 14 ms 332 KB Output is correct
16 Correct 14 ms 340 KB Output is correct
17 Correct 14 ms 384 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 320 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 0 ms 212 KB Output is correct
29 Correct 0 ms 320 KB Output is correct
30 Correct 0 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 0 ms 212 KB Output is correct
34 Correct 39 ms 340 KB Output is correct
35 Correct 40 ms 340 KB Output is correct
36 Correct 41 ms 404 KB Output is correct
37 Correct 14 ms 340 KB Output is correct
38 Correct 17 ms 340 KB Output is correct
39 Correct 14 ms 332 KB Output is correct
40 Correct 15 ms 384 KB Output is correct
41 Correct 14 ms 340 KB Output is correct
42 Correct 15 ms 388 KB Output is correct
43 Correct 14 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 340 KB Output is correct
2 Correct 40 ms 340 KB Output is correct
3 Correct 41 ms 404 KB Output is correct
4 Correct 14 ms 340 KB Output is correct
5 Correct 17 ms 340 KB Output is correct
6 Correct 14 ms 332 KB Output is correct
7 Correct 15 ms 384 KB Output is correct
8 Correct 14 ms 340 KB Output is correct
9 Correct 15 ms 388 KB Output is correct
10 Correct 14 ms 332 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 10 ms 360 KB Output is correct
15 Correct 14 ms 372 KB Output is correct
16 Correct 40 ms 360 KB Output is correct
17 Correct 14 ms 380 KB Output is correct
18 Correct 14 ms 340 KB Output is correct
19 Correct 14 ms 384 KB Output is correct
20 Correct 14 ms 384 KB Output is correct
21 Correct 17 ms 340 KB Output is correct
22 Correct 14 ms 380 KB Output is correct
23 Correct 14 ms 368 KB Output is correct
24 Correct 14 ms 340 KB Output is correct
25 Correct 14 ms 332 KB Output is correct
26 Correct 14 ms 340 KB Output is correct
27 Correct 14 ms 384 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 320 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 0 ms 212 KB Output is correct
39 Correct 0 ms 320 KB Output is correct
40 Correct 0 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 0 ms 212 KB Output is correct
44 Execution timed out 1078 ms 2252 KB Time limit exceeded
45 Halted 0 ms 0 KB -