結果

問題 No.161 制限ジャンケン
ユーザー hhgfhn1hhgfhn1
提出日時 2018-10-31 14:01:00
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 611 bytes
コンパイル時間 3,190 ms
コンパイル使用メモリ 74,764 KB
実行使用メモリ 41,808 KB
最終ジャッジ日時 2024-04-30 01:30:34
合計ジャッジ時間 6,485 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 119 ms
40,136 KB
testcase_02 AC 132 ms
41,520 KB
testcase_03 AC 132 ms
41,388 KB
testcase_04 WA -
testcase_05 AC 131 ms
41,244 KB
testcase_06 AC 134 ms
41,200 KB
testcase_07 AC 132 ms
41,400 KB
testcase_08 AC 136 ms
41,264 KB
testcase_09 AC 136 ms
41,588 KB
testcase_10 AC 132 ms
41,488 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 120 ms
40,056 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int g=scanner.nextInt();
		int c=scanner.nextInt();
		int p=scanner.nextInt();
		String s=scanner.next();
		int x[]= {g,c,p};
		int sc=0;
		for(int i=0;i<s.length();i++) {
			char y=s.charAt(i);
			int tar=0;
			if(y=='G')tar=2;
			else if(y=='C')tar=0;
			else tar=1;
			int cnt=0;
			while(x[tar]==0) {
				tar++;
				if(tar==3)tar=0;
				cnt++;
			}
			x[tar]--;
			if(cnt==0)sc+=3;
			else if(cnt==1)sc++;
		}
		System.out.println(sc);
	}
}
0