Submission #986929

# Submission time Handle Problem Language Result Execution time Memory
986929 2024-05-21T15:17:34 Z alextodoran Sparklers (JOI17_sparklers) C++17
50 / 100
21 ms 1372 KB
/**
 _  _   __  _ _ _  _  _ _
 |a  ||t  ||o    d | |o  |
| __    _| | _ | __|  _ |
| __ |/_  | __  /__\ / _\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

const int N_MAX = 1000;

int N, K, T;
int X[N_MAX + 2];

bool dp[N_MAX + 2][N_MAX + 2];

bool check (int speed) {
    dp[1][N] = true;
    for (int l = 1; l <= K; l++) {
        for (int r = N - (l == 1); r >= K; r--) {
            dp[l][r] = false;
            if (l > 1 && X[r] - X[l - 1] <= (ll) speed * (r - l + 1) * 2 * T) {
                dp[l][r] |= dp[l - 1][r];
            }
            if (r < N && X[r + 1] - X[l] <= (ll) speed * (r - l + 1) * 2 * T) {
                dp[l][r] |= dp[l][r + 1];
            }
        }
    }
    return dp[K][K];
}

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

    cin >> N >> K >> T;
    for (int i = 1; i <= N; i++) {
        cin >> X[i];
    }
    int l = 0, r = (int) 1e9 / T + 1;
    while (l < r) {
        int mid = (l + r) / 2;
        if (check(mid) == true) {
            r = mid;
        } else {
            l = mid + 1;
        }
    }
    cout << l << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 11 ms 604 KB Output is correct
23 Correct 7 ms 604 KB Output is correct
24 Correct 3 ms 348 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 11 ms 608 KB Output is correct
27 Correct 12 ms 644 KB Output is correct
28 Correct 19 ms 860 KB Output is correct
29 Correct 18 ms 1112 KB Output is correct
30 Correct 13 ms 1264 KB Output is correct
31 Correct 15 ms 1116 KB Output is correct
32 Correct 21 ms 860 KB Output is correct
33 Correct 19 ms 860 KB Output is correct
34 Correct 10 ms 1116 KB Output is correct
35 Correct 17 ms 1116 KB Output is correct
36 Correct 6 ms 348 KB Output is correct
37 Correct 6 ms 348 KB Output is correct
38 Correct 20 ms 1116 KB Output is correct
39 Correct 5 ms 1372 KB Output is correct
40 Correct 20 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 11 ms 604 KB Output is correct
23 Correct 7 ms 604 KB Output is correct
24 Correct 3 ms 348 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 11 ms 608 KB Output is correct
27 Correct 12 ms 644 KB Output is correct
28 Correct 19 ms 860 KB Output is correct
29 Correct 18 ms 1112 KB Output is correct
30 Correct 13 ms 1264 KB Output is correct
31 Correct 15 ms 1116 KB Output is correct
32 Correct 21 ms 860 KB Output is correct
33 Correct 19 ms 860 KB Output is correct
34 Correct 10 ms 1116 KB Output is correct
35 Correct 17 ms 1116 KB Output is correct
36 Correct 6 ms 348 KB Output is correct
37 Correct 6 ms 348 KB Output is correct
38 Correct 20 ms 1116 KB Output is correct
39 Correct 5 ms 1372 KB Output is correct
40 Correct 20 ms 604 KB Output is correct
41 Runtime error 1 ms 604 KB Execution killed with signal 11
42 Halted 0 ms 0 KB -