Submission #770402

# Submission time Handle Problem Language Result Execution time Memory
770402 2023-07-01T07:17:29 Z Plurm Copy and Paste 3 (JOI22_copypaste3) C++11
1 / 100
9 ms 324 KB
#include <bits/stdc++.h>
using namespace std;

int 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]);
                dp[i] = min(dp[i], dp[j] + b + c * (i / j) + dp[i % j]);
            }
        }
        cout << dp[n] << endl;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 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 304 KB Output is correct
8 Correct 0 ms 304 KB Output is correct
9 Correct 0 ms 308 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 304 KB Output is correct
3 Correct 8 ms 212 KB Output is correct
4 Incorrect 9 ms 324 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 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 304 KB Output is correct
8 Correct 0 ms 304 KB Output is correct
9 Correct 0 ms 308 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Incorrect 0 ms 304 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 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 304 KB Output is correct
8 Correct 0 ms 304 KB Output is correct
9 Correct 0 ms 308 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Incorrect 0 ms 304 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 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 304 KB Output is correct
8 Correct 0 ms 304 KB Output is correct
9 Correct 0 ms 308 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Incorrect 0 ms 304 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 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 304 KB Output is correct
8 Correct 0 ms 304 KB Output is correct
9 Correct 0 ms 308 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 304 KB Output is correct
13 Correct 8 ms 212 KB Output is correct
14 Incorrect 9 ms 324 KB Output isn't correct
15 Halted 0 ms 0 KB -