結果

問題 No.161 制限ジャンケン
ユーザー TLwiegehttTLwiegehtt
提出日時 2015-07-12 01:15:50
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 994 bytes
コンパイル時間 766 ms
コンパイル使用メモリ 24,132 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-20 04:38:32
合計ジャッジ時間 1,501 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>

int main(void){
	int i,j,k;
	int total = 0;
	int hand[4] = {0};
	char s[310];
	
	scanf("%d %d %d", &hand[0], &hand[1], &hand[2]);
	scanf("%s", s);
	for(i=0;i<3;i++){	// 0 win, 1 even, 2 lose
		for(j=0;j<3;j++){ // 0 G, 1 C, 2 P
			for(k=0;s[k] != '\0';k++){
				if(i == 0){
					if(hand[j] != 0){
						if(j==0 && s[k] == 'C'){
							hand[j]--;
							s[k] = '-';
							total += 3;
						}else if(j==1 && s[k] == 'P'){
							hand[j]--;
							s[k] = '-';
							total += 3;
						}else if(j==2 && s[k] == 'G'){
							hand[j]--;
							s[k] = '-';
							total += 3;
						}
					}
				}else if(i == 1){
					if(hand[j] != 0){
						if(j==0 && s[k] == 'G'){
							hand[j]--;
							s[k] = '-';
							total += 1;
						}else if(j==1 && s[k] == 'C'){
							hand[j]--;
							s[k] = '-';
							total += 1;
						}else if(j==2 && s[k] == 'P'){
							hand[j]--;
							s[k] = '-';
							total += 1;
						}
					}
				}
			}
		}
	}
	
	printf("%d\n", total);
	return 0;
}
0