結果

問題 No.161 制限ジャンケン
ユーザー machymachy
提出日時 2015-06-13 13:34:35
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 718 bytes
コンパイル時間 849 ms
コンパイル使用メモリ 73,600 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-20 21:20:16
合計ジャッジ時間 2,004 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
4,380 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:14:17: warning: ‘op’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     int og, oc, op;
                 ^~
main.cpp:14:13: warning: ‘oc’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     int og, oc, op;
             ^~
main.cpp:14:9: warning: ‘og’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     int og, oc, op;
         ^~

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
using namespace std;
typedef long long LL;

int main(){
    int G, C, P;
    cin >> G >> C >> P;
    int og, oc, op;
    string S;
    cin >> S;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == 'G') og++;
        if(S[i] == 'C') oc++;
        if(S[i] == 'P') op++;
    }
    LL ans = 0;

    int v = min(G, oc);
    ans += v * 3;
    G -= v; oc -= v;

    v = min(C, op);
    ans += v * 3;
    C -= v; op -= v;

    v = min(P, og);
    ans += v * 3;
    P -= v; og -= v;
    ans += min(G, og);
    ans += min(C, oc);
    ans += min(P, op);
    cout << ans << endl;
    return 0;
}
0