結果

問題 No.161 制限ジャンケン
ユーザー m2543315647m2543315647
提出日時 2015-05-14 10:26:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 125 ms / 5,000 ms
コード長 824 bytes
コンパイル時間 3,705 ms
コンパイル使用メモリ 77,352 KB
実行使用メモリ 56,328 KB
最終ジャッジ日時 2023-08-20 04:30:19
合計ジャッジ時間 6,447 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
55,784 KB
testcase_01 AC 121 ms
56,032 KB
testcase_02 AC 117 ms
55,776 KB
testcase_03 AC 119 ms
56,328 KB
testcase_04 AC 118 ms
56,124 KB
testcase_05 AC 119 ms
55,976 KB
testcase_06 AC 122 ms
56,124 KB
testcase_07 AC 120 ms
55,660 KB
testcase_08 AC 121 ms
55,688 KB
testcase_09 AC 118 ms
55,704 KB
testcase_10 AC 119 ms
56,000 KB
testcase_11 AC 123 ms
56,148 KB
testcase_12 AC 117 ms
55,700 KB
testcase_13 AC 125 ms
55,992 KB
testcase_14 AC 119 ms
56,176 KB
testcase_15 AC 122 ms
55,752 KB
testcase_16 AC 123 ms
55,816 KB
testcase_17 AC 120 ms
56,312 KB
testcase_18 AC 118 ms
55,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class No161 {
	static final int G = 0, C = 1, P = 2;
	static int[] m = new int[3], e = new int[3];
	public static void main(String[] args) {
		int point = 0;
		Scanner sc = new Scanner(System.in);
		m[G] = sc.nextInt();
		m[C] = sc.nextInt();
		m[P] = sc.nextInt();
		e[G] = e[C] = e[P] = 0;
		char[] s = new char[m[G] + m[C] + m[P]];
		s = sc.next().toCharArray();
		sc.close();
		for (int i = 0; i < s.length; i++) {
			if (s[i] == 'G')e[G]++;
			if (s[i] == 'C')e[C]++;
			if (s[i] == 'P')e[P]++;
		}
		point += (same(G, C) + same(C, P) + same(P, G)) * 3;
		point += same(G, G) + same(C, C) + same(P, P);
		System.out.println(point);
	}
	static int same(int me, int ene) {
		int buf = Math.max(m[me], e[ene]) - Math.abs(m[me] - e[ene]);
		m[me] -= buf;
		e[ene] -= buf;
		return buf;
	}
}
0