結果

問題 No.161 制限ジャンケン
ユーザー krotonkroton
提出日時 2015-03-05 15:59:03
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 644 bytes
コンパイル時間 1,192 ms
コンパイル使用メモリ 158,712 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-30 04:23:56
合計ジャッジ時間 1,812 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    int G, C, P;
    cin >> G >> C >> P;

    string S;
    cin >> S;

    int g = 0, c = 0, p = 0;
    for(char t : S){
        if(t == 'G')++g;
        if(t == 'C')++c;
        if(t == 'P')++p;
	}
	
    int res = 0;
    {
        int k = min(G, c);
        res += k * 3;
        G -= k;
        c -= k;
    }
    {
        int k = min(C, p);
        res += k * 3;
        C -= k;
        p -= k;
    }
    {
        int k = min(P, g);
        res += k * 3;
        P -= k;
        g -= k;
    }

    res += min(G, g) + min(C, c) + min(P, p);

    cout << res << endl;
    return 0;
}
0