結果

問題 No.161 制限ジャンケン
ユーザー 4885rhkA4885rhkA
提出日時 2015-07-10 08:30:52
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,813 bytes
コンパイル時間 812 ms
コンパイル使用メモリ 52,808 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 09:47:38
合計ジャッジ時間 1,363 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

//
//  main.cpp
//  Q256
//
//  Created by AkihiroKOBAYASHI on 7/10/15.
//  Copyright (c) 2015 Akhr5884. All rights reserved.
//

#include <iostream>
#include <string.h>
int main(int argc, const char * argv[]) {
    int te[3];
    int count = 0;
    int sum = 0;
    int point = 0;
    
    std::string aite;
    char* moji;
    
    while(count < 3) {
        std::cin >> te[count];
        sum += te[count];
        count++;
    }
    
    std::cin >> aite;
    moji = (char *)malloc( strlen(aite.c_str()) + 1 );
    std::sprintf(moji, "%s", aite.c_str());

    count = 0;
    while (count < sum) {
        switch(moji[count]) {
            case 'G' :
                if(te[2] > 0) {
                    point += 3;
                    te[2]--;
                }
                else if(te[0] > 0) {
                    point += 1;
                    te[0]--;
                }
                else {
                    te[1]--;
                }
                break;
                
            case 'C' :
                if(te[0] > 0) {
                    point += 3;
                    te[0]--;
                }
                else if(te[1] > 0) {
                    point += 1;
                    te[1]--;
                }
                else {
                    te[2]--;
                }
                break;

            case 'P' :
                if(te[1] > 0) {
                    point += 3;
                    te[1]--;
                }
                else if(te[2] > 0) {
                    point += 1;
                    te[2]--;
                }
                else {
                    te[0]--;
                }
                break;
            default:
                break;
        }
        count++;
    }
    
    std::cout << point << "\n";
    
    return 0;
}
0