結果

問題 No.161 制限ジャンケン
ユーザー spacia
提出日時 2016-01-04 16:02:06
言語 Java
(openjdk 23)
結果
AC  
実行時間 51 ms / 5,000 ms
コード長 1,220 bytes
コンパイル時間 2,192 ms
コンパイル使用メモリ 77,980 KB
実行使用メモリ 37,236 KB
最終ジャッジ日時 2024-11-30 04:47:24
合計ジャッジ時間 3,566 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

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