結果

問題 No.29 パワーアップ
ユーザー YamaKasaYamaKasa
提出日時 2018-04-20 01:06:48
言語 Java19
(openjdk 21)
結果
AC  
実行時間 142 ms / 5,000 ms
コード長 703 bytes
コンパイル時間 2,831 ms
コンパイル使用メモリ 71,152 KB
実行使用メモリ 57,812 KB
最終ジャッジ日時 2023-09-09 11:54:01
合計ジャッジ時間 7,026 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
56,404 KB
testcase_01 AC 122 ms
55,712 KB
testcase_02 AC 123 ms
55,608 KB
testcase_03 AC 126 ms
56,040 KB
testcase_04 AC 123 ms
56,072 KB
testcase_05 AC 138 ms
55,900 KB
testcase_06 AC 139 ms
55,948 KB
testcase_07 AC 131 ms
56,292 KB
testcase_08 AC 127 ms
55,736 KB
testcase_09 AC 125 ms
56,156 KB
testcase_10 AC 142 ms
55,592 KB
testcase_11 AC 142 ms
55,884 KB
testcase_12 AC 127 ms
55,696 KB
testcase_13 AC 138 ms
55,928 KB
testcase_14 AC 140 ms
55,808 KB
testcase_15 AC 139 ms
56,064 KB
testcase_16 AC 138 ms
55,692 KB
testcase_17 AC 128 ms
55,732 KB
testcase_18 AC 135 ms
57,812 KB
testcase_19 AC 133 ms
53,756 KB
testcase_20 AC 124 ms
55,632 KB
testcase_21 AC 124 ms
56,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
//		int []a = new int[N];
//		int []b = new int[N];
//		int []c = new int[N];
		int []x = new int[3 *N];
		for(int i = 0; i < 3 * N; i++) {
			x[i] = scan.nextInt();
		}
		scan.close();
		Arrays.sort(x);
		int temp = x[0];
		int cnt1 = 1;
		int cnt2 = 0;
		int ans = 0;
		for(int i = 1; i < 3 * N; i++) {
			if(temp == x[i]) {
				cnt1 ++;
			}else {
				ans += cnt1 / 2;
				cnt2 += cnt1 % 2;
				temp = x[i];
				cnt1 = 1;
			}
		}
		ans += cnt1 / 2;
		cnt2 += cnt1 % 2;
		ans += cnt2 / 4;
		System.out.println(ans);
	}
}
0