結果

問題 No.2334 Distinct Cards
ユーザー ks2mks2m
提出日時 2023-06-02 21:22:11
言語 Java21
(openjdk 21)
結果
AC  
実行時間 219 ms / 2,000 ms
コード長 676 bytes
コンパイル時間 3,865 ms
コンパイル使用メモリ 72,100 KB
実行使用メモリ 61,088 KB
最終ジャッジ日時 2023-08-28 02:35:38
合計ジャッジ時間 8,015 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
49,116 KB
testcase_01 AC 45 ms
49,336 KB
testcase_02 AC 46 ms
49,128 KB
testcase_03 AC 45 ms
49,400 KB
testcase_04 AC 45 ms
49,124 KB
testcase_05 AC 45 ms
49,244 KB
testcase_06 AC 46 ms
49,352 KB
testcase_07 AC 54 ms
49,452 KB
testcase_08 AC 53 ms
49,424 KB
testcase_09 AC 53 ms
49,580 KB
testcase_10 AC 53 ms
49,484 KB
testcase_11 AC 54 ms
49,560 KB
testcase_12 AC 210 ms
60,744 KB
testcase_13 AC 219 ms
60,104 KB
testcase_14 AC 211 ms
60,460 KB
testcase_15 AC 211 ms
61,088 KB
testcase_16 AC 215 ms
60,760 KB
testcase_17 AC 202 ms
60,324 KB
testcase_18 AC 213 ms
60,268 KB
testcase_19 AC 217 ms
60,120 KB
testcase_20 AC 210 ms
60,468 KB
testcase_21 AC 209 ms
60,444 KB
testcase_22 AC 207 ms
58,616 KB
testcase_23 AC 45 ms
49,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int k = Integer.parseInt(sa[1]);
		sa = br.readLine().split(" ");
		int[] c = new int[n + 1];
		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(sa[i]);
			c[a]++;
		}
		br.close();

		Arrays.sort(c);
		int ans = 0;
		for (int i = n; i >= 0; i--) {
			ans++;
			k -= c[i];
			if (k <= 0) {
				break;
			}
		}
		System.out.println(ans);
	}
}
0