結果

問題 No.161 制限ジャンケン
ユーザー Mcpu3Mcpu3
提出日時 2018-08-28 20:45:00
言語 Java21
(openjdk 21)
結果
AC  
実行時間 132 ms / 5,000 ms
コード長 868 bytes
コンパイル時間 2,155 ms
コンパイル使用メモリ 73,968 KB
実行使用メモリ 57,392 KB
最終ジャッジ日時 2023-09-25 04:05:14
合計ジャッジ時間 6,114 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
56,044 KB
testcase_01 AC 126 ms
55,728 KB
testcase_02 AC 125 ms
55,988 KB
testcase_03 AC 125 ms
57,392 KB
testcase_04 AC 125 ms
55,412 KB
testcase_05 AC 127 ms
55,488 KB
testcase_06 AC 128 ms
56,220 KB
testcase_07 AC 127 ms
55,680 KB
testcase_08 AC 128 ms
55,404 KB
testcase_09 AC 126 ms
55,404 KB
testcase_10 AC 129 ms
55,640 KB
testcase_11 AC 128 ms
55,964 KB
testcase_12 AC 127 ms
55,708 KB
testcase_13 AC 129 ms
55,944 KB
testcase_14 AC 128 ms
55,684 KB
testcase_15 AC 127 ms
55,856 KB
testcase_16 AC 126 ms
55,752 KB
testcase_17 AC 132 ms
55,808 KB
testcase_18 AC 129 ms
55,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int g=sc.nextInt(),c=sc.nextInt(),p=sc.nextInt(),a=0,t[]=new int[300],i;
		String s=sc.next();
		sc.close();
		for(i=0;i<s.length();i++) {
			if(s.charAt(i)=='G') {
				if(p>0) {
					t[i]=1;
					p--;
					a+=3;
				}
			}
			else if(s.charAt(i)=='C') {
				if(g>0) {
					t[i]=1;
					g--;
					a+=3;
				}
			}
			else {
				if(c>0) {
					t[i]=1;
					c--;
					a+=3;
				}
			}
		}
		for(i=0;i<s.length();i++) {
			if(s.charAt(i)=='G'&&1>t[i]) {
				if(g>0) {
					g--;
					a++;
				}
			}
			else if(s.charAt(i)=='C'&&1>t[i]) {
				if(c>0) {
					c--;
					a++;
				}
			}
			else if(s.charAt(i)=='P'&&1>t[i]) {
				if(p>0) {
					p--;
					a++;
				}
			}
		}
		System.out.print(a);
	}
}
0