답안 #906216

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
906216 2024-01-13T17:49:43 Z LucaIlie Chorus (JOI23_chorus) C++17
40 / 100
7000 ms 35536 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 5e3;
int a[MAX_N + 1], dp[MAX_N + 1][MAX_N + 1];

int main() {
    int n, k;

    cin >> n >> k;

    int countB = 0, countA = 0;
    for ( int i = 0; i < 2 * n; i++ ) {
        char ch;
        cin >> ch;
        if ( ch == 'A' )
            countA++;
        else {
            countB++;
            a[countB] = countA;
        }
    }

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

    cout << dp[n][k];

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 484 KB Output is correct
6 Correct 1 ms 448 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2648 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 484 KB Output is correct
6 Correct 1 ms 448 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2648 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 2 ms 4556 KB Output is correct
18 Correct 17 ms 10740 KB Output is correct
19 Correct 39 ms 10588 KB Output is correct
20 Correct 3 ms 10588 KB Output is correct
21 Correct 2 ms 10588 KB Output is correct
22 Correct 87 ms 10744 KB Output is correct
23 Correct 70 ms 10580 KB Output is correct
24 Correct 4 ms 10588 KB Output is correct
25 Correct 85 ms 10580 KB Output is correct
26 Correct 62 ms 10744 KB Output is correct
27 Correct 24 ms 10580 KB Output is correct
28 Correct 25 ms 10580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 484 KB Output is correct
6 Correct 1 ms 448 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2648 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 2 ms 4556 KB Output is correct
18 Correct 17 ms 10740 KB Output is correct
19 Correct 39 ms 10588 KB Output is correct
20 Correct 3 ms 10588 KB Output is correct
21 Correct 2 ms 10588 KB Output is correct
22 Correct 87 ms 10744 KB Output is correct
23 Correct 70 ms 10580 KB Output is correct
24 Correct 4 ms 10588 KB Output is correct
25 Correct 85 ms 10580 KB Output is correct
26 Correct 62 ms 10744 KB Output is correct
27 Correct 24 ms 10580 KB Output is correct
28 Correct 25 ms 10580 KB Output is correct
29 Execution timed out 7094 ms 35536 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 484 KB Output is correct
6 Correct 1 ms 448 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2648 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 2 ms 4556 KB Output is correct
18 Correct 17 ms 10740 KB Output is correct
19 Correct 39 ms 10588 KB Output is correct
20 Correct 3 ms 10588 KB Output is correct
21 Correct 2 ms 10588 KB Output is correct
22 Correct 87 ms 10744 KB Output is correct
23 Correct 70 ms 10580 KB Output is correct
24 Correct 4 ms 10588 KB Output is correct
25 Correct 85 ms 10580 KB Output is correct
26 Correct 62 ms 10744 KB Output is correct
27 Correct 24 ms 10580 KB Output is correct
28 Correct 25 ms 10580 KB Output is correct
29 Execution timed out 7094 ms 35536 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 484 KB Output is correct
6 Correct 1 ms 448 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2648 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 2 ms 4556 KB Output is correct
18 Correct 17 ms 10740 KB Output is correct
19 Correct 39 ms 10588 KB Output is correct
20 Correct 3 ms 10588 KB Output is correct
21 Correct 2 ms 10588 KB Output is correct
22 Correct 87 ms 10744 KB Output is correct
23 Correct 70 ms 10580 KB Output is correct
24 Correct 4 ms 10588 KB Output is correct
25 Correct 85 ms 10580 KB Output is correct
26 Correct 62 ms 10744 KB Output is correct
27 Correct 24 ms 10580 KB Output is correct
28 Correct 25 ms 10580 KB Output is correct
29 Execution timed out 7094 ms 35536 KB Time limit exceeded
30 Halted 0 ms 0 KB -