結果

問題 No.161 制限ジャンケン
ユーザー fjafjafjafjafjafja
提出日時 2017-09-19 19:02:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 127 ms / 5,000 ms
コード長 854 bytes
コンパイル時間 3,254 ms
コンパイル使用メモリ 73,844 KB
実行使用メモリ 57,572 KB
最終ジャッジ日時 2023-08-20 05:11:57
合計ジャッジ時間 6,502 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
56,360 KB
testcase_01 AC 121 ms
55,964 KB
testcase_02 AC 123 ms
55,980 KB
testcase_03 AC 121 ms
55,780 KB
testcase_04 AC 118 ms
56,248 KB
testcase_05 AC 120 ms
56,132 KB
testcase_06 AC 122 ms
56,192 KB
testcase_07 AC 123 ms
56,084 KB
testcase_08 AC 125 ms
55,932 KB
testcase_09 AC 120 ms
55,748 KB
testcase_10 AC 124 ms
55,392 KB
testcase_11 AC 123 ms
54,240 KB
testcase_12 AC 121 ms
55,480 KB
testcase_13 AC 125 ms
55,848 KB
testcase_14 AC 127 ms
55,824 KB
testcase_15 AC 123 ms
55,672 KB
testcase_16 AC 122 ms
53,312 KB
testcase_17 AC 123 ms
57,572 KB
testcase_18 AC 125 ms
56,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.util.Scanner;

public class N161
{
	static int score=0;
	static int[] gcp=new int[3];
	static int[] ygcp=new int[3];
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		for(int i=0;i<3;i++)
		{
			gcp[i]=sc.nextInt();
		}
		String you=sc.next();
		for(int i=0;i<you.length();i++)
		{
			switch(you.substring(i, i+1))
			{
				case "G":
					ygcp[0]++;
					break;
				case "C":
					ygcp[1]++;
					break;
				case "P":
					ygcp[2]++;
					break;
			}
		}
		for(int i=0;i<3;i++)
		{
			if(ygcp[(i+1)%3]>=gcp[i])
			{
				ygcp[(i+1)%3]-=gcp[i];score+=3*gcp[i];gcp[i]=0;
			}
			else
			{
				gcp[i]-=ygcp[(i+1)%3];score+=3*ygcp[(i+1)%3];ygcp[(i+1)%3]=0;
			}
		}
		for(int i=0;i<3;i++)
		{
			score=(ygcp[i]>=gcp[i])?score+gcp[i]:score+ygcp[i];
		}
		
		
		System.out.println(score);
	}

}
0