結果

問題 No.161 制限ジャンケン
ユーザー jp_stejp_ste
提出日時 2015-03-16 07:59:34
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 765 bytes
コンパイル時間 2,495 ms
コンパイル使用メモリ 73,364 KB
実行使用メモリ 56,164 KB
最終ジャッジ日時 2023-09-11 08:29:46
合計ジャッジ時間 5,958 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 124 ms
56,084 KB
testcase_02 AC 122 ms
55,808 KB
testcase_03 AC 122 ms
55,676 KB
testcase_04 WA -
testcase_05 AC 127 ms
55,404 KB
testcase_06 AC 127 ms
55,576 KB
testcase_07 AC 124 ms
55,656 KB
testcase_08 AC 128 ms
55,896 KB
testcase_09 AC 125 ms
55,612 KB
testcase_10 AC 125 ms
55,876 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 128 ms
55,896 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int G = sc.nextInt();
		int C = sc.nextInt();
		int P = sc.nextInt();
		String S = sc.next();
		int ans = 0;
		
		for(int i=0; i<S.length(); i++) {
			
			if(G==0 && C==0 && P==0) break;
			
			char look = S.charAt(i);
			
			if(look == 'G') {
				if     (P>0) { P--; ans+=3; }
				else if(G>0) { G--; ans+=1; }
				else if(C>0) { C--; }	
				
			} else if(look == 'C') {
				if     (G>0) { G--; ans+=3; }
				else if(C>0) { C--; ans+=1; }
				else if(P>0) { P--; }
				
			} else if(look == 'P') {
				if     (C>0) { C--; ans+=3; }
				else if(P>0) { P--; ans+=1; }
				else if(G>0) { G--; }	
			}
		}
		System.out.println(ans);
	}
}
0