답안 #770405

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
770405 2023-07-01T07:20:50 Z Plurm Copy and Paste 3 (JOI22_copypaste3) C++11
6 / 100
26 ms 328 KB
#include <bits/stdc++.h>
using namespace std;

long long dp[2505];
int main() {
    int n;
    string s;
    int a, b, c;
    cin >> n >> s >> a >> b >> c;
    if (n == 3) {
        set<char> st;
        st.insert(s[0]);
        st.insert(s[1]);
        st.insert(s[2]);
        if (st.size() == 3)
            cout << 3ll * a << endl;
        else if (st.size() == 2)
            cout << min(3ll * a, 2ll * a + b + 2ll * c) << endl;
        else
            cout << min({3ll * a, 2ll * a + b + 2ll * c, a + b + 3ll * c})
                 << endl;
    } else {
        dp[1] = a;
        for (int i = 2; i <= n; i++) {
            dp[i] = dp[i - 1] + a;
            for (int j = 1; j < i; j++) {
                dp[i] = min(dp[i], dp[j] + dp[i - j]);
                for (int k = 2; j * k <= i; k++) {
                    dp[i] = min(dp[i], dp[j] + b + 1ll * c * k + dp[i - j * k]);
                }
            }
        }
        cout << dp[n] << endl;
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 260 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 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
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 14 ms 212 KB Output is correct
4 Correct 22 ms 316 KB Output is correct
5 Correct 19 ms 324 KB Output is correct
6 Correct 22 ms 320 KB Output is correct
7 Correct 26 ms 300 KB Output is correct
8 Correct 26 ms 324 KB Output is correct
9 Correct 26 ms 328 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 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 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 260 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 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 Incorrect 0 ms 212 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 260 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 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 Incorrect 0 ms 212 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 260 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 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 Incorrect 0 ms 212 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 260 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 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 212 KB Output is correct
13 Correct 14 ms 212 KB Output is correct
14 Correct 22 ms 316 KB Output is correct
15 Correct 19 ms 324 KB Output is correct
16 Correct 22 ms 320 KB Output is correct
17 Correct 26 ms 300 KB Output is correct
18 Correct 26 ms 324 KB Output is correct
19 Correct 26 ms 328 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Incorrect 0 ms 212 KB Output isn't correct
29 Halted 0 ms 0 KB -