結果

問題 No.161 制限ジャンケン
ユーザー kaffelunkaffelun
提出日時 2018-11-04 14:56:16
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 718 bytes
コンパイル時間 1,182 ms
コンパイル使用メモリ 145,032 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-13 03:20:42
合計ジャッジ時間 2,054 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int A[3], B[3] = {0}, C;
    cin >> A[0] >> A[1] >> A[2];
    string S;
    cin >> S;
    int ans = 0;
    for(int i = 0; i < S.length(); i++) {
        if(S[i] == 'G') B[0]++;
        if(S[i] == 'C') B[1]++;
        if(S[i] == 'P') B[2]++;
    }
    for(int j = 0; j < 3; j++) {
        for (int i = 0; i < 3; i++) {
            int k = (i - j + 4) % 3;
            C = min(A[i], B[k]);
            A[i] -= C, B[k] -= C;
            if(j == 0) ans += C * 3;
            if(j == 1) ans += C;
        }
    }
    cout << ans << endl;
    return 0;
}
0