結果

問題 No.161 制限ジャンケン
ユーザー spaciaspacia
提出日時 2016-01-04 16:02:06
言語 Java21
(openjdk 21)
結果
AC  
実行時間 44 ms / 5,000 ms
コード長 1,220 bytes
コンパイル時間 3,445 ms
コンパイル使用メモリ 73,852 KB
実行使用メモリ 49,744 KB
最終ジャッジ日時 2023-08-20 04:44:04
合計ジャッジ時間 5,158 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,152 KB
testcase_01 AC 43 ms
49,444 KB
testcase_02 AC 42 ms
49,272 KB
testcase_03 AC 41 ms
49,204 KB
testcase_04 AC 42 ms
49,360 KB
testcase_05 AC 42 ms
49,360 KB
testcase_06 AC 43 ms
49,500 KB
testcase_07 AC 42 ms
49,536 KB
testcase_08 AC 44 ms
49,176 KB
testcase_09 AC 43 ms
49,292 KB
testcase_10 AC 42 ms
49,404 KB
testcase_11 AC 42 ms
49,372 KB
testcase_12 AC 42 ms
49,252 KB
testcase_13 AC 43 ms
49,460 KB
testcase_14 AC 42 ms
49,172 KB
testcase_15 AC 41 ms
47,192 KB
testcase_16 AC 41 ms
49,316 KB
testcase_17 AC 41 ms
49,216 KB
testcase_18 AC 43 ms
49,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.math.*;

class Main {
	
	public static void out (Object o) {
		System.out.println(o);
	}
	
	public static void main (String[] args) throws IOException {
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		String[] line = br.readLine().split(" ");
		int g = Integer.parseInt(line[0]);
		int c = Integer.parseInt(line[1]);
		int p = Integer.parseInt(line[2]);
		String s = br.readLine();
		int[] h = new int[3];
		
		for (int i = 0; i < s.length(); i++) {
			char t = s.charAt(i);
			if (t == 'G')
				h[0]++;
			else if (t == 'C')
				h[1]++;
			else
				h[2]++;
		}
		
		int winPoint = (Math.min(g , h[1]) + Math.min(c , h[2]) + Math.min(p , h[0])) * 3;
		//out("w : " + winPoint);
		//out("g = " + g + " , c = " + c + " , p = " + p + "\th = " + Arrays.toString(h));
		int sub = Math.min(g , h[1]);
		g -= sub;
		h[1] -= sub;
		sub = Math.min(c , h[2]);
		c -= sub;
		h[2] -= sub;
		sub = Math.min(p , h[0]);
		p -= sub;
		h[0] -= sub;
		int drawPoint = Math.min(g , h[0]) + Math.min(c , h[1]) + Math.min(p , h[2]);
		
		//out("g = " + g + " , c = " + c + " , p = " + p + "\th = " + Arrays.toString(h));
		out(winPoint + drawPoint);
	}
}
0