結果

問題 No.161 制限ジャンケン
ユーザー eve__fuyuki
提出日時 2018-03-14 03:15:32
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 831 bytes
コンパイル時間 474 ms
コンパイル使用メモリ 56,680 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-24 18:13:24
合計ジャッジ時間 1,237 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
using namespace std;
int main(){
    string S;
    int yuki[3];
    int aite[3] = {};
    int ans = 0;
    cin >> yuki[0] >> yuki[1] >> yuki[2];
    cin >> S;
    for(int i=0;i<S.length();i++){
        if(S[i] == 'G') aite[0]++;
        else if(S[i] == 'C') aite[1]++;
        else  aite[2]++;
    }
    for(int i=0;i<3;i++){
        if(yuki[i] >= aite[(i+1)%3]){
            ans += 3*aite[(i+1)%3];
            yuki[i] -= aite[(i+1)%3];
            aite[(i+1)%3]=0;
        }
        else{
            ans += 3*yuki[i];
            aite[(i+1)%3] -= yuki[i];
            yuki[i] = 0;
        }
    }
    for(int i=0;i<3;i++){
        if(yuki[i] >= aite[i]){
            ans += aite[i];
        }
        else{
            ans += yuki[i];
        }
    }
    cout << ans << endl;
    return 0;
}
0