結果

問題 No.161 制限ジャンケン
ユーザー k_kadorak_kadora
提出日時 2015-06-14 20:27:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 129 ms / 5,000 ms
コード長 880 bytes
コンパイル時間 3,962 ms
コンパイル使用メモリ 74,564 KB
実行使用メモリ 56,104 KB
最終ジャッジ日時 2023-08-20 04:33:24
合計ジャッジ時間 6,913 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
55,524 KB
testcase_01 AC 127 ms
55,580 KB
testcase_02 AC 126 ms
55,424 KB
testcase_03 AC 127 ms
55,540 KB
testcase_04 AC 127 ms
55,556 KB
testcase_05 AC 125 ms
55,344 KB
testcase_06 AC 128 ms
55,748 KB
testcase_07 AC 123 ms
55,856 KB
testcase_08 AC 126 ms
55,708 KB
testcase_09 AC 125 ms
55,804 KB
testcase_10 AC 126 ms
54,052 KB
testcase_11 AC 128 ms
55,716 KB
testcase_12 AC 124 ms
55,576 KB
testcase_13 AC 126 ms
55,748 KB
testcase_14 AC 125 ms
55,656 KB
testcase_15 AC 124 ms
55,932 KB
testcase_16 AC 123 ms
56,104 KB
testcase_17 AC 124 ms
55,980 KB
testcase_18 AC 123 ms
55,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class Yuki161{
	public static void main(String[] arg){
		Scanner sc = new Scanner(System.in);
		int[] me = new int[3];
		int[] you = new int[3];
		int res=0;
		me[0] = sc.nextInt();
		me[1] = sc.nextInt();
		me[2] = sc.nextInt();
		String s = sc.next();
		for(int i = 0;i<s.length();i++){
			if(s.charAt(i) == 'G'){
				you[0]++;
			}else if(s.charAt(i) == 'C'){
				you[1]++;
			}else{
				you[2]++;
			}
		}
		for(int i = 0;i<3;i++){
			if(me[i] >= you[(i+1) % 3]){
				res += you[(i+1) % 3] * 3;
				me[i] -= you[(i+1) % 3];
				you[(i+1) % 3] = 0;
			}else{
				res += me[i] * 3;
				you[(i+1) % 3] -= me[i];
				me[i] = 0;
			}
		}
		for(int i = 0;i<3;i++){
			if(me[i] >= you[i]){
				res += you[i];
				me[i] -= you[i];
				you[i] = 0;
			}else{
				res += me[i];
				you[i] -= me[i];
				me[i] = 0;
			}
		}
		System.out.println(res);
	}
}
0