結果

問題 No.1380 Borderline
ユーザー ks2mks2m
提出日時 2021-02-07 20:37:55
言語 Java19
(openjdk 21)
結果
AC  
実行時間 153 ms / 2,000 ms
コード長 561 bytes
コンパイル時間 2,253 ms
コンパイル使用メモリ 73,340 KB
実行使用メモリ 56,724 KB
最終ジャッジ日時 2023-09-19 04:29:11
合計ジャッジ時間 10,682 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,796 KB
testcase_01 AC 126 ms
55,856 KB
testcase_02 AC 127 ms
55,776 KB
testcase_03 AC 128 ms
56,056 KB
testcase_04 AC 128 ms
55,804 KB
testcase_05 AC 126 ms
56,412 KB
testcase_06 AC 127 ms
56,104 KB
testcase_07 AC 127 ms
56,076 KB
testcase_08 AC 131 ms
56,096 KB
testcase_09 AC 129 ms
56,092 KB
testcase_10 AC 128 ms
55,996 KB
testcase_11 AC 129 ms
56,344 KB
testcase_12 AC 129 ms
56,000 KB
testcase_13 AC 127 ms
55,888 KB
testcase_14 AC 146 ms
55,744 KB
testcase_15 AC 144 ms
55,816 KB
testcase_16 AC 145 ms
56,020 KB
testcase_17 AC 144 ms
55,720 KB
testcase_18 AC 144 ms
56,192 KB
testcase_19 AC 145 ms
55,884 KB
testcase_20 AC 144 ms
56,184 KB
testcase_21 AC 145 ms
55,976 KB
testcase_22 AC 145 ms
56,724 KB
testcase_23 AC 146 ms
55,852 KB
testcase_24 AC 146 ms
56,032 KB
testcase_25 AC 153 ms
55,804 KB
testcase_26 AC 146 ms
55,712 KB
testcase_27 AC 147 ms
55,872 KB
testcase_28 AC 149 ms
54,044 KB
testcase_29 AC 149 ms
55,808 KB
testcase_30 AC 150 ms
56,044 KB
testcase_31 AC 149 ms
56,016 KB
testcase_32 AC 145 ms
55,632 KB
testcase_33 AC 146 ms
55,784 KB
testcase_34 AC 145 ms
55,736 KB
testcase_35 AC 145 ms
55,696 KB
testcase_36 AC 146 ms
55,584 KB
testcase_37 AC 147 ms
55,808 KB
testcase_38 AC 151 ms
56,004 KB
testcase_39 AC 148 ms
55,804 KB
testcase_40 AC 148 ms
55,884 KB
testcase_41 AC 148 ms
55,976 KB
testcase_42 AC 148 ms
55,656 KB
testcase_43 AC 149 ms
56,528 KB
testcase_44 AC 129 ms
55,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		TreeMap<Integer, Integer> map = new TreeMap<>();
		for (int i = 0; i < n; i++) {
			int p = sc.nextInt();
			map.put(p, map.getOrDefault(p, 0) + 1);
		}
		sc.close();

		int ans = 0;
		while (!map.isEmpty()) {
			int v = map.pollLastEntry().getValue();
			if (ans + v > k) {
				break;
			}
			ans += v;
		}
		System.out.println(ans);
	}
}
0