結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
4,376 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;
    ans += min(G, oc) * 3;
    G -= min(G, oc);
    ans += min(C, op) * 3;
    C -= min(C, op);
    ans += min(P, og) * 3;
    P -= min(P, og);
    ans += min(G, og);
    ans += min(C, oc);
    ans += min(P, op);
    cout << ans << endl;
    return 0;
}
0