Submission #937248

# Submission time Handle Problem Language Result Execution time Memory
937248 2024-03-03T17:01:34 Z Andrey Chorus (JOI23_chorus) C++14
40 / 100
532 ms 2528 KB
#include <bits/stdc++.h>
using namespace std;

int dp[501][501];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,x,br = 0;
    cin >> n >> x;
    string s;
    cin >> s;
    vector<int> bruh(0);
    for(int i = 0; i < 2*n; i++) {
        if(s[i] == 'A') {
            br++;
        }
        else {
            bruh.push_back(br);
        }
    }
    for(int i = 0; i <= n; i++) {
        dp[0][i] = 0;
    }
    for(int i = 1; i <= n; i++) {
        for(int k = 0; k <= n; k++) {
            dp[i][k] = 1e9;
        }
        int sb = 0;
        for(int j = i-1; j >= 0; j--) {
            sb+=max(0,i-bruh[j]);
            for(int k = 0; k < n; k++) {
                dp[i][k+1] = min(dp[i][k+1],dp[j][k]+sb);
            }
        }
    }
    cout << dp[n][x];
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 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 344 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 344 KB Output is correct
9 Correct 0 ms 516 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 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 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 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 344 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 344 KB Output is correct
9 Correct 0 ms 516 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 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 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 3 ms 600 KB Output is correct
18 Correct 62 ms 1264 KB Output is correct
19 Correct 64 ms 1484 KB Output is correct
20 Correct 55 ms 1360 KB Output is correct
21 Correct 55 ms 1268 KB Output is correct
22 Correct 56 ms 1244 KB Output is correct
23 Correct 64 ms 1180 KB Output is correct
24 Correct 62 ms 1256 KB Output is correct
25 Correct 56 ms 1360 KB Output is correct
26 Correct 56 ms 1408 KB Output is correct
27 Correct 55 ms 1364 KB Output is correct
28 Correct 56 ms 1372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 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 344 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 344 KB Output is correct
9 Correct 0 ms 516 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 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 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 3 ms 600 KB Output is correct
18 Correct 62 ms 1264 KB Output is correct
19 Correct 64 ms 1484 KB Output is correct
20 Correct 55 ms 1360 KB Output is correct
21 Correct 55 ms 1268 KB Output is correct
22 Correct 56 ms 1244 KB Output is correct
23 Correct 64 ms 1180 KB Output is correct
24 Correct 62 ms 1256 KB Output is correct
25 Correct 56 ms 1360 KB Output is correct
26 Correct 56 ms 1408 KB Output is correct
27 Correct 55 ms 1364 KB Output is correct
28 Correct 56 ms 1372 KB Output is correct
29 Runtime error 532 ms 2528 KB Execution killed with signal 11
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 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 344 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 344 KB Output is correct
9 Correct 0 ms 516 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 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 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 3 ms 600 KB Output is correct
18 Correct 62 ms 1264 KB Output is correct
19 Correct 64 ms 1484 KB Output is correct
20 Correct 55 ms 1360 KB Output is correct
21 Correct 55 ms 1268 KB Output is correct
22 Correct 56 ms 1244 KB Output is correct
23 Correct 64 ms 1180 KB Output is correct
24 Correct 62 ms 1256 KB Output is correct
25 Correct 56 ms 1360 KB Output is correct
26 Correct 56 ms 1408 KB Output is correct
27 Correct 55 ms 1364 KB Output is correct
28 Correct 56 ms 1372 KB Output is correct
29 Runtime error 532 ms 2528 KB Execution killed with signal 11
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 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 344 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 344 KB Output is correct
9 Correct 0 ms 516 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 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 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 3 ms 600 KB Output is correct
18 Correct 62 ms 1264 KB Output is correct
19 Correct 64 ms 1484 KB Output is correct
20 Correct 55 ms 1360 KB Output is correct
21 Correct 55 ms 1268 KB Output is correct
22 Correct 56 ms 1244 KB Output is correct
23 Correct 64 ms 1180 KB Output is correct
24 Correct 62 ms 1256 KB Output is correct
25 Correct 56 ms 1360 KB Output is correct
26 Correct 56 ms 1408 KB Output is correct
27 Correct 55 ms 1364 KB Output is correct
28 Correct 56 ms 1372 KB Output is correct
29 Runtime error 532 ms 2528 KB Execution killed with signal 11
30 Halted 0 ms 0 KB -