Submission #941046

# Submission time Handle Problem Language Result Execution time Memory
941046 2024-03-08T05:49:09 Z juliany2 Chorus (JOI23_chorus) C++17
40 / 100
57 ms 2524 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()

const int N = 507;
int n, k;
string s;
int a[N];
int dp[N][N];

int main() {
    cin.tie(0)->sync_with_stdio(false);

    cin >> n >> k >> s;
    s = " " + s;

    int idx = 1, cnt = 1;
    for (int i = 1; i <= 2 * n; i++) {
        if (s[i] == 'A')
            cnt++;
        else
            a[idx++] = cnt;
    }

    memset(dp, 0x3f, sizeof(dp));
    dp[1][0] = 0;

    for (int i = 2; i <= n + 1; i++) {
        int sum = 0;
        for (int j = i - 1; j >= 1; j--) {
            sum += max(0, i - a[j]);
            for (int c = 1; c <= k; c++)
                dp[i][c] = min(dp[i][c], dp[j][c - 1] + sum);
        }
    }

    cout << *min_element(dp[n + 1], dp[n + 1] + k + 1) << '\n';

    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 1368 KB Output is correct
2 Correct 1 ms 1372 KB Output is correct
3 Correct 1 ms 1372 KB Output is correct
4 Correct 1 ms 1372 KB Output is correct
5 Correct 1 ms 1372 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 1 ms 1372 KB Output is correct
8 Correct 1 ms 1368 KB Output is correct
9 Correct 1 ms 1372 KB Output is correct
10 Correct 1 ms 1372 KB Output is correct
11 Correct 1 ms 1372 KB Output is correct
12 Correct 1 ms 1372 KB Output is correct
13 Correct 1 ms 1372 KB Output is correct
14 Correct 1 ms 1368 KB Output is correct
15 Correct 1 ms 1372 KB Output is correct
16 Correct 1 ms 1368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1368 KB Output is correct
2 Correct 1 ms 1372 KB Output is correct
3 Correct 1 ms 1372 KB Output is correct
4 Correct 1 ms 1372 KB Output is correct
5 Correct 1 ms 1372 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 1 ms 1372 KB Output is correct
8 Correct 1 ms 1368 KB Output is correct
9 Correct 1 ms 1372 KB Output is correct
10 Correct 1 ms 1372 KB Output is correct
11 Correct 1 ms 1372 KB Output is correct
12 Correct 1 ms 1372 KB Output is correct
13 Correct 1 ms 1372 KB Output is correct
14 Correct 1 ms 1368 KB Output is correct
15 Correct 1 ms 1372 KB Output is correct
16 Correct 1 ms 1368 KB Output is correct
17 Correct 2 ms 1228 KB Output is correct
18 Correct 12 ms 1476 KB Output is correct
19 Correct 31 ms 1476 KB Output is correct
20 Correct 1 ms 1372 KB Output is correct
21 Correct 1 ms 1372 KB Output is correct
22 Correct 56 ms 1372 KB Output is correct
23 Correct 55 ms 1452 KB Output is correct
24 Correct 2 ms 1372 KB Output is correct
25 Correct 56 ms 1372 KB Output is correct
26 Correct 54 ms 1368 KB Output is correct
27 Correct 20 ms 1368 KB Output is correct
28 Correct 20 ms 1372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1368 KB Output is correct
2 Correct 1 ms 1372 KB Output is correct
3 Correct 1 ms 1372 KB Output is correct
4 Correct 1 ms 1372 KB Output is correct
5 Correct 1 ms 1372 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 1 ms 1372 KB Output is correct
8 Correct 1 ms 1368 KB Output is correct
9 Correct 1 ms 1372 KB Output is correct
10 Correct 1 ms 1372 KB Output is correct
11 Correct 1 ms 1372 KB Output is correct
12 Correct 1 ms 1372 KB Output is correct
13 Correct 1 ms 1372 KB Output is correct
14 Correct 1 ms 1368 KB Output is correct
15 Correct 1 ms 1372 KB Output is correct
16 Correct 1 ms 1368 KB Output is correct
17 Correct 2 ms 1228 KB Output is correct
18 Correct 12 ms 1476 KB Output is correct
19 Correct 31 ms 1476 KB Output is correct
20 Correct 1 ms 1372 KB Output is correct
21 Correct 1 ms 1372 KB Output is correct
22 Correct 56 ms 1372 KB Output is correct
23 Correct 55 ms 1452 KB Output is correct
24 Correct 2 ms 1372 KB Output is correct
25 Correct 56 ms 1372 KB Output is correct
26 Correct 54 ms 1368 KB Output is correct
27 Correct 20 ms 1368 KB Output is correct
28 Correct 20 ms 1372 KB Output is correct
29 Runtime error 57 ms 2524 KB Execution killed with signal 11
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1368 KB Output is correct
2 Correct 1 ms 1372 KB Output is correct
3 Correct 1 ms 1372 KB Output is correct
4 Correct 1 ms 1372 KB Output is correct
5 Correct 1 ms 1372 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 1 ms 1372 KB Output is correct
8 Correct 1 ms 1368 KB Output is correct
9 Correct 1 ms 1372 KB Output is correct
10 Correct 1 ms 1372 KB Output is correct
11 Correct 1 ms 1372 KB Output is correct
12 Correct 1 ms 1372 KB Output is correct
13 Correct 1 ms 1372 KB Output is correct
14 Correct 1 ms 1368 KB Output is correct
15 Correct 1 ms 1372 KB Output is correct
16 Correct 1 ms 1368 KB Output is correct
17 Correct 2 ms 1228 KB Output is correct
18 Correct 12 ms 1476 KB Output is correct
19 Correct 31 ms 1476 KB Output is correct
20 Correct 1 ms 1372 KB Output is correct
21 Correct 1 ms 1372 KB Output is correct
22 Correct 56 ms 1372 KB Output is correct
23 Correct 55 ms 1452 KB Output is correct
24 Correct 2 ms 1372 KB Output is correct
25 Correct 56 ms 1372 KB Output is correct
26 Correct 54 ms 1368 KB Output is correct
27 Correct 20 ms 1368 KB Output is correct
28 Correct 20 ms 1372 KB Output is correct
29 Runtime error 57 ms 2524 KB Execution killed with signal 11
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1368 KB Output is correct
2 Correct 1 ms 1372 KB Output is correct
3 Correct 1 ms 1372 KB Output is correct
4 Correct 1 ms 1372 KB Output is correct
5 Correct 1 ms 1372 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 1 ms 1372 KB Output is correct
8 Correct 1 ms 1368 KB Output is correct
9 Correct 1 ms 1372 KB Output is correct
10 Correct 1 ms 1372 KB Output is correct
11 Correct 1 ms 1372 KB Output is correct
12 Correct 1 ms 1372 KB Output is correct
13 Correct 1 ms 1372 KB Output is correct
14 Correct 1 ms 1368 KB Output is correct
15 Correct 1 ms 1372 KB Output is correct
16 Correct 1 ms 1368 KB Output is correct
17 Correct 2 ms 1228 KB Output is correct
18 Correct 12 ms 1476 KB Output is correct
19 Correct 31 ms 1476 KB Output is correct
20 Correct 1 ms 1372 KB Output is correct
21 Correct 1 ms 1372 KB Output is correct
22 Correct 56 ms 1372 KB Output is correct
23 Correct 55 ms 1452 KB Output is correct
24 Correct 2 ms 1372 KB Output is correct
25 Correct 56 ms 1372 KB Output is correct
26 Correct 54 ms 1368 KB Output is correct
27 Correct 20 ms 1368 KB Output is correct
28 Correct 20 ms 1372 KB Output is correct
29 Runtime error 57 ms 2524 KB Execution killed with signal 11
30 Halted 0 ms 0 KB -