結果

問題 No.161 制限ジャンケン
ユーザー 37zigen37zigen
提出日時 2016-05-20 12:53:08
言語 Java21
(openjdk 21)
結果
AC  
実行時間 127 ms / 5,000 ms
コード長 723 bytes
コンパイル時間 4,595 ms
コンパイル使用メモリ 73,556 KB
実行使用メモリ 56,084 KB
最終ジャッジ日時 2023-08-20 04:51:25
合計ジャッジ時間 7,089 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,772 KB
testcase_01 AC 123 ms
55,476 KB
testcase_02 AC 123 ms
55,936 KB
testcase_03 AC 125 ms
55,788 KB
testcase_04 AC 124 ms
56,084 KB
testcase_05 AC 124 ms
55,808 KB
testcase_06 AC 126 ms
55,292 KB
testcase_07 AC 126 ms
55,752 KB
testcase_08 AC 127 ms
55,516 KB
testcase_09 AC 125 ms
55,772 KB
testcase_10 AC 127 ms
55,680 KB
testcase_11 AC 126 ms
55,832 KB
testcase_12 AC 124 ms
55,868 KB
testcase_13 AC 126 ms
55,656 KB
testcase_14 AC 125 ms
55,984 KB
testcase_15 AC 125 ms
55,796 KB
testcase_16 AC 127 ms
55,804 KB
testcase_17 AC 124 ms
55,600 KB
testcase_18 AC 126 ms
55,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;
import java.util.Scanner;
public class Main{
	public static void main(String[] args)throws Exception{
		new Main().solve();
	}
	void solve(){
		Scanner sc=new Scanner(System.in);
		int[] me=new int[3];
		for(int i=0;i<3;i++)me[i]=sc.nextInt();

		String s=sc.next();
		int[] enemy=new int[3];
		for(int i=0;i<s.length();i++){
			if(s.charAt(i)=='G')enemy[0]++;
			else if(s.charAt(i)=='C')enemy[1]++;
			else if(s.charAt(i)=='P')enemy[2]++;
		}
		int c=0;
		for(int i=0;i<3;i++){
			int a=Math.min(me[i],enemy[(i+1)%3]);
			c+=3*a;
			me[i]-=a;
			enemy[(i+1)%3]-=a;
		}
		for(int i=0;i<3;i++){
			int a=Math.min(me[i], enemy[i]);
			c+=a;
			me[i]-=a;
			enemy[i]-=a;
		}
		System.out.println(c);
	}
}

0