結果

問題 No.161 制限ジャンケン
コンテスト
ユーザー GOTKAKO
提出日時 2025-11-07 20:20:40
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 520 bytes
コンパイル時間 1,942 ms
コンパイル使用メモリ 195,128 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-11-07 20:20:43
合計ジャッジ時間 2,951 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int G,C,P; cin >> G >> C >> P;
    int g = 0,c = 0,p = 0;
    string s; cin >> s;
    for(auto ss : s) g += ss=='G',c += ss=='C',p += ss=='P';

    int win = min(G,c),answer = win*3;
    G -= win,c -= win;
    win = min(C,p),answer += win*3;
    C -= win,p -= win;
    win = min(P,g),answer += win*3;
    P -= win,g -= win;
    answer += min(G,g)+min(C,c)+min(P,p);
    cout << answer << endl;
}
0