提出 #41770473


ソースコード 拡げる

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int X, Y, Z;
    cin >> X >> Y >> Z;

    string S;
    cin >> S;

    int n = S.length();

    vector<vector<int>> dp(n + 1, vector<int>(2, 1e9));
    // dp[i][j]: i番目の文字まで入力した時、最後がj(0:小文字, 1:大文字)であるときの最短時間

    dp[0][0] = dp[0][1] = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 2; j++) {
            // aキーを押す
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + X);

            // Shiftキーとaキーを同時に押す
            int nj = j ^ 1; // jの反転
            dp[i + 1][nj] = min(dp[i + 1][nj], dp[i][j] + Y);

            // CapsLockキーを押す
            if (S[i] == 'a' && j == 1) {
                dp[i + 1][0] = min(dp[i + 1][0], dp[i][j] + Z);
            }
        }
    }

    int answer = min(dp[n][0], dp[n][1]);
    cout << answer << endl;

    return 0;
}

提出情報

提出日時
問題 D - Shift vs. CapsLock
ユーザ chacoder
言語 C++ (GCC 9.2.1)
得点 0
コード長 1049 Byte
結果 WA
実行時間 40 ms
メモリ 19876 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 400
結果
AC × 1
WA × 2
AC × 6
WA × 25
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
00_sample_00.txt WA 8 ms 3584 KiB
00_sample_01.txt AC 3 ms 3468 KiB
00_sample_02.txt WA 3 ms 3480 KiB
01_small_00.txt WA 2 ms 3428 KiB
01_small_01.txt AC 3 ms 3412 KiB
01_small_02.txt AC 2 ms 3568 KiB
01_small_03.txt WA 2 ms 3428 KiB
01_small_04.txt AC 2 ms 3592 KiB
01_small_05.txt AC 2 ms 3596 KiB
01_small_06.txt WA 3 ms 3488 KiB
01_small_07.txt WA 3 ms 3568 KiB
01_small_08.txt AC 2 ms 3512 KiB
01_small_09.txt WA 1 ms 3408 KiB
02_rnd_00.txt WA 37 ms 19784 KiB
02_rnd_01.txt WA 31 ms 17896 KiB
02_rnd_02.txt WA 32 ms 17592 KiB
02_rnd_03.txt WA 33 ms 14568 KiB
02_rnd_04.txt WA 30 ms 15208 KiB
02_rnd_05.txt WA 25 ms 13852 KiB
02_rnd_06.txt WA 31 ms 15680 KiB
02_rnd_07.txt WA 22 ms 12548 KiB
02_rnd_08.txt WA 32 ms 17052 KiB
02_rnd_09.txt WA 25 ms 12264 KiB
03_max_00.txt WA 40 ms 19808 KiB
03_max_01.txt WA 36 ms 19788 KiB
03_max_02.txt WA 37 ms 19816 KiB
03_max_03.txt WA 34 ms 19644 KiB
04_border_00.txt WA 37 ms 19876 KiB
04_border_01.txt WA 35 ms 19748 KiB
04_border_02.txt WA 36 ms 19760 KiB
04_border_03.txt WA 39 ms 19808 KiB