結果

問題 No.161 制限ジャンケン
ユーザー MeloNMeloN
提出日時 2015-03-06 17:26:14
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 1,129 bytes
コンパイル時間 515 ms
コンパイル使用メモリ 24,352 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-20 04:24:00
合計ジャッジ時間 1,434 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <string.h>
#define MAX 300

int main(void)
{
    int point = 0, G,C,P,count,i;
    char S[MAX];

    scanf("%d%d%d",&G,&C,&P);
    scanf("%s",S);

    count = G+C+P;

    for (i = 0; i < count; i++) {
        if (S[i] == 'G') {
            if (P > 0) {
                P--;
                point += 3;
                S[i] = 0;
            }
        } else if (S[i] == 'C') {
            if (G > 0) {
                G--;
                point += 3;
                S[i] = 0;
            }
        } else if (S[i] == 'P') {
            if (C > 0) {
                C--;
                point += 3;
                S[i] = 0;
            }
        }
    }

    for (i = 0; i < count; i++) {
        if (S[i] == 'G') {
            if (G > 0) {
                G--;
                point++;
            }
        } else if (S[i] == 'C') {
            if (C > 0) {
                C--;
                point++;
            }
        } else if (S[i] == 'P') {
            if (P > 0) {
                P--;
                point++;
            }
        }
    }

    printf("%d\n",point);

    return (0);
}
0