結果

問題 No.29 パワーアップ
ユーザー koukonkokoukonko
提出日時 2015-12-07 13:49:51
言語 Java19
(openjdk 21)
結果
AC  
実行時間 45 ms / 5,000 ms
コード長 827 bytes
コンパイル時間 2,173 ms
コンパイル使用メモリ 74,148 KB
実行使用メモリ 49,908 KB
最終ジャッジ日時 2023-10-12 19:56:56
合計ジャッジ時間 3,849 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,848 KB
testcase_01 AC 42 ms
47,468 KB
testcase_02 AC 42 ms
49,436 KB
testcase_03 AC 43 ms
49,236 KB
testcase_04 AC 43 ms
49,312 KB
testcase_05 AC 45 ms
49,436 KB
testcase_06 AC 45 ms
49,600 KB
testcase_07 AC 43 ms
49,448 KB
testcase_08 AC 42 ms
49,428 KB
testcase_09 AC 43 ms
49,900 KB
testcase_10 AC 44 ms
49,420 KB
testcase_11 AC 44 ms
49,904 KB
testcase_12 AC 43 ms
49,720 KB
testcase_13 AC 44 ms
49,484 KB
testcase_14 AC 45 ms
49,444 KB
testcase_15 AC 45 ms
49,440 KB
testcase_16 AC 44 ms
49,644 KB
testcase_17 AC 43 ms
49,344 KB
testcase_18 AC 44 ms
49,908 KB
testcase_19 AC 44 ms
49,596 KB
testcase_20 AC 42 ms
49,348 KB
testcase_21 AC 43 ms
49,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));

		try {
			int N = Integer.parseInt(buff.readLine());
			int sum = N * 3;
			int[] num = new int[10];

			for (int i = 0; i < N; ++i) {
				String[] box = buff.readLine().split(" ");
				for (int j = 0; j < box.length; ++j) {
					num[Integer.parseInt(box[j]) - 1]++;
				}
			}

			int ans = 0;
			for (int i = 0; i < 10; ++i) {

				if (num[i] >= 2) {
					ans += num[i] / 2;
					sum -= num[i] - (num[i] % 2);
					num[i] %= 2;
				}
			}
			if (sum >= 4) {
				ans += sum / 4;
			}

			System.out.println(ans);
		} catch (NumberFormatException e) {

		} catch (IOException e) {

		}
	}
}
0