結果

問題 No.161 制限ジャンケン
ユーザー jp_stejp_ste
提出日時 2015-03-16 08:32:26
言語 Java21
(openjdk 21)
結果
AC  
実行時間 180 ms / 5,000 ms
コード長 971 bytes
コンパイル時間 2,397 ms
コンパイル使用メモリ 75,540 KB
実行使用メモリ 56,764 KB
最終ジャッジ日時 2023-08-20 04:26:27
合計ジャッジ時間 6,850 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 180 ms
56,324 KB
testcase_01 AC 126 ms
55,492 KB
testcase_02 AC 161 ms
56,580 KB
testcase_03 AC 154 ms
56,736 KB
testcase_04 AC 160 ms
56,552 KB
testcase_05 AC 122 ms
55,636 KB
testcase_06 AC 167 ms
56,624 KB
testcase_07 AC 177 ms
56,448 KB
testcase_08 AC 180 ms
56,504 KB
testcase_09 AC 168 ms
56,388 KB
testcase_10 AC 163 ms
56,552 KB
testcase_11 AC 163 ms
56,588 KB
testcase_12 AC 168 ms
56,584 KB
testcase_13 AC 178 ms
56,412 KB
testcase_14 AC 177 ms
56,564 KB
testcase_15 AC 165 ms
56,576 KB
testcase_16 AC 164 ms
56,708 KB
testcase_17 AC 172 ms
56,396 KB
testcase_18 AC 160 ms
56,764 KB
権限があれば一括ダウンロードができます

ソースコード

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;
		String nextS = "";
		
		//勝てる手
		for(int i=0; i<S.length(); i++) {
			
			char look = S.charAt(i);
			boolean find = false;
			
			if(look == 'G') {
				if(P>0) { P--; ans+=3; find=true; }
				
			} else if(look == 'C') {
				if(G>0) { G--; ans+=3; find=true; }
				
			} else if(look == 'P') {
				if(C>0) { C--; ans+=3; find=true; }
			}
		
			if(find==false) {
				nextS += look;
			}
		}
		
		S = nextS;
		
		//あいこの手
		for(int i=0; i<S.length(); i++) {
			
			char look = S.charAt(i);
			
			if(look == 'G') {
				if(G>0) { G--; ans+=1; }
				
			} else if(look == 'C') {
				if(C>0) { C--; ans+=1; }
				
			} else if(look == 'P') {
				if(P>0) { P--; ans+=1; }
			}	
		}
		System.out.println(ans);
	}
}
0