結果

問題 No.161 制限ジャンケン
コンテスト
ユーザー spacia
提出日時 2016-01-04 15:44:43
言語 Java
(openjdk 26.0.2.1 + ACL)
コンパイル:
javac -J-Duser.language=en -encoding UTF8 -cp /opt/aclib/ac_library.jar _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true -cp .:/opt/aclib/ac_library.jar _class_
結果
WA  
実行時間 -
コード長 961 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,378 ms
コンパイル使用メモリ 84,660 KB
実行使用メモリ 43,688 KB
最終ジャッジ日時 2026-08-31 00:44:00
合計ジャッジ時間 3,195 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 3 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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;
		g = g - h[1] >= 0 ? g - h[1] : 0;
		c = c - h[2] >= 0 ? c - h[2] : 0;
		p = p - h[0] >= 0 ? p - h[0] : 0;
		int drawPoint = Math.min(g , h[0]) + Math.min(c , h[1]) + Math.min(p , h[2]);
		
		out(winPoint + drawPoint);
	}
}
0