結果

問題 No.161 制限ジャンケン
ユーザー 4885rhkA4885rhkA
提出日時 2015-07-10 10:56:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 2,323 bytes
コンパイル時間 426 ms
コンパイル使用メモリ 52,544 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-20 04:38:30
合計ジャッジ時間 1,369 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;
    char moji[1000];
    int already[1000];

    
    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[2] > 0) {
                        te[2]--;
                        point += 1;
                        already[count] = 1;
                    }
                    break;
            }
        }
        count++;
    }
    
    std::cout << point << "\n";
    
    return 0;
}
0