Submission #41751343


Source Code Expand

#include <iostream>
#include <climits>

using namespace std;
const int Max = 300005;

long long x, y, z, f[Max][2], n;
string s;

int main() {
    ios::sync_with_stdio(false);
    cin >> x >> y >> z >> s;

    f[0][1] = INT_MAX;
    f[0][0] = 0;
    n = (int) s.size();

    for (int i = 1; i <= n; i++)
        if (s[i - 1] == 'a') {
            f[i][0] = min(f[i - 1][0] + min(x, z + y + z), f[i - 1][1] + min(y + z, z + x));
            f[i][1] = min(f[i - 1][1] + min(y, z + x + z), f[i - 1][0] + min(x + z, z + y));
        } else {
            f[i][0] = min(f[i - 1][0] + min(y, z + x + z), f[i - 1][1] + min(x + z, z + y));
            f[i][1] = min(f[i - 1][1] + min(x, z + y + z), f[i - 1][0] + min(y + z, z + x));
        }

    cout << min(f[n][0], f[n][1]);
    return 0;
}

Submission Info

Submission Time
Task D - Shift vs. CapsLock
User x_x_
Language C++ (GCC 9.2.1)
Score 400
Code Size 815 Byte
Status AC
Exec Time 16 ms
Memory 8444 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 31
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_small_00.txt, 01_small_01.txt, 01_small_02.txt, 01_small_03.txt, 01_small_04.txt, 01_small_05.txt, 01_small_06.txt, 01_small_07.txt, 01_small_08.txt, 01_small_09.txt, 02_rnd_00.txt, 02_rnd_01.txt, 02_rnd_02.txt, 02_rnd_03.txt, 02_rnd_04.txt, 02_rnd_05.txt, 02_rnd_06.txt, 02_rnd_07.txt, 02_rnd_08.txt, 02_rnd_09.txt, 03_max_00.txt, 03_max_01.txt, 03_max_02.txt, 03_max_03.txt, 04_border_00.txt, 04_border_01.txt, 04_border_02.txt, 04_border_03.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 6 ms 3512 KiB
00_sample_01.txt AC 2 ms 3508 KiB
00_sample_02.txt AC 2 ms 3604 KiB
01_small_00.txt AC 3 ms 3496 KiB
01_small_01.txt AC 2 ms 3548 KiB
01_small_02.txt AC 2 ms 3600 KiB
01_small_03.txt AC 2 ms 3500 KiB
01_small_04.txt AC 2 ms 3532 KiB
01_small_05.txt AC 2 ms 3512 KiB
01_small_06.txt AC 2 ms 3504 KiB
01_small_07.txt AC 2 ms 3500 KiB
01_small_08.txt AC 3 ms 3504 KiB
01_small_09.txt AC 2 ms 3456 KiB
02_rnd_00.txt AC 15 ms 8188 KiB
02_rnd_01.txt AC 12 ms 7888 KiB
02_rnd_02.txt AC 12 ms 7748 KiB
02_rnd_03.txt AC 9 ms 6928 KiB
02_rnd_04.txt AC 9 ms 7028 KiB
02_rnd_05.txt AC 7 ms 6632 KiB
02_rnd_06.txt AC 8 ms 7056 KiB
02_rnd_07.txt AC 7 ms 6284 KiB
02_rnd_08.txt AC 8 ms 7552 KiB
02_rnd_09.txt AC 7 ms 6092 KiB
03_max_00.txt AC 10 ms 8408 KiB
03_max_01.txt AC 9 ms 8248 KiB
03_max_02.txt AC 11 ms 8320 KiB
03_max_03.txt AC 16 ms 8316 KiB
04_border_00.txt AC 8 ms 8348 KiB
04_border_01.txt AC 13 ms 8252 KiB
04_border_02.txt AC 9 ms 8312 KiB
04_border_03.txt AC 8 ms 8444 KiB