結果

問題 No.161 制限ジャンケン
ユーザー Daigo HIROOKADaigo HIROOKA
提出日時 2018-05-22 01:15:46
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 823 bytes
コンパイル時間 5,280 ms
コンパイル使用メモリ 72,012 KB
実行使用メモリ 55,800 KB
最終ジャッジ日時 2023-09-11 01:09:56
合計ジャッジ時間 6,655 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 116 ms
55,600 KB
testcase_02 AC 119 ms
55,476 KB
testcase_03 AC 117 ms
55,564 KB
testcase_04 WA -
testcase_05 AC 119 ms
55,636 KB
testcase_06 AC 121 ms
55,760 KB
testcase_07 AC 118 ms
55,352 KB
testcase_08 AC 123 ms
55,588 KB
testcase_09 AC 121 ms
55,568 KB
testcase_10 AC 122 ms
55,800 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 121 ms
55,680 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No161{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int num_G = sc.nextInt();
		int num_C = sc.nextInt();
		int num_P = sc.nextInt();
		String[] S = sc.next().split("");

		int score = 0;
		for(int i = 0; i < S.length; i++){
			if(S[i].equals("G")){
				if(num_P > 0){
					num_P--;
					score += 3;
				}else if(num_G > 0){
					num_G--;
					score += 1;
				}else{
					num_C--;
				}
			}else if(S[i].equals("C")){
				if(num_G > 0){
					num_G--;
					score += 3;
				}else if(num_C > 0){
					num_C--;
					score += 1;
				}else{
					num_P--;
				}
			}else{
				if(num_C > 0){
					num_C--;
					score += 3;
				}else if(num_P > 0){
					num_P--;
					score += 1;
				}else{
					num_G--;
				}
			}
		}
		System.out.println(score);
	}
}
0