結果

問題 No.161 制限ジャンケン
ユーザー butsurizukibutsurizuki
提出日時 2016-11-15 21:16:38
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 528 bytes
コンパイル時間 953 ms
コンパイル使用メモリ 24,148 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-20 04:57:23
合計ジャッジ時間 1,210 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<stdio.h>

int main(void){
	int g,c,p,eg=0,ec=0,ep=0,l,i,r = 0;
	char s[512];
	scanf("%d%d%d%s",&g,&c,&p,s);
	l = g+c+p;
	for(i = 0;i < l;i++){
		if(s[i] == 'G'){eg++;}
		if(s[i] == 'C'){ec++;}
		if(s[i] == 'P'){ep++;}
	}
	if(eg<=p){r+=(3*eg);p-=eg;eg=0;}else{r+=(3*p);eg-=p;p=0;}
	if(ec<=g){r+=(3*ec);g-=ec;ec=0;}else{r+=(3*g);ec-=g;g=0;}
	if(ep<=c){r+=(3*ep);c-=ep;ep=0;}else{r+=(3*c);ep-=c;c=0;}
	if(eg<=g){r+=eg;}else{r+=g;}
	if(ec<=c){r+=ec;}else{r+=c;}
	if(ep<=p){r+=ep;}else{r+=p;}
	printf("%d\n",r);
	return 0;
}
0