結果

問題 No.161 制限ジャンケン
ユーザー 4885rhkA4885rhkA
提出日時 2015-07-10 10:48:15
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 2,275 bytes
コンパイル時間 361 ms
コンパイル使用メモリ 52,804 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-22 09:48:03
合計ジャッジ時間 2,959 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;
    int *already;
    
    while(count < 3) {
        std::cin >> te[count];
        sum += te[count];
        count++;
    }
    
    std::cin >> aite;
    moji = (char *)malloc( strlen(aite.c_str()) + 1 );
    already = (int*)malloc( strlen(aite.c_str()) + 1  );
    std::sprintf(moji, "%s", aite.c_str());
    
    // win
    count = 0;
    while (count < sum) {
        already[count] = 0;
        switch(aite[count]) {
            case 'G':
                if(te[2] > 0) {
                    te[2]--;
                    point += 3;
                    already[count] = 1;
                }
                break;
            case 'C':
                if(te[0] > 0) {
                    te[0]--;
                    point += 3;
                    already[count] = 1;
                }
                break;
            case 'P':
                if(te[1] > 0) {
                    te[1]--;
                    point += 3;
                    already[count] = 1;
                }
                break;
        }
        count++;
    }


    // draw
    count = 0;
    while (count < sum) {
        if(already[count != 1]) {
            switch(aite[count]) {
                case 'G':
                    if(te[0] > 0) {
                        te[0]--;
                        point += 1;
                        already[count] = 1;
                    }
                    break;
                case 'C':
                    if(te[1] > 0) {
                        te[1]--;
                        point += 1;
                        already[count] = 1;
                    }
                    break;
                case 'P':
                    if(te[0] > 0) {
                        te[0]--;
                        point += 1;
                        already[count] = 1;
                    }
                    break;
            }
        }
        count++;
    }
    
    
    std::cout << point << "\n";
    
    return 0;
}
0