結果
問題 | No.2334 Distinct Cards |
ユーザー |
![]() |
提出日時 | 2023-06-02 21:25:20 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 19 ms / 2,000 ms |
コード長 | 631 bytes |
コンパイル時間 | 193 ms |
コンパイル使用メモリ | 29,184 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-28 16:20:32 |
合計ジャッジ時間 | 1,152 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
#include <stdio.h> #include <stdlib.h> int cmp_int_rev (const void *ap, const void *bp) { int a = *(int *)ap; int b = *(int *)bp; if (a < b) { return 1; } if (a > b) { return -1; } return 0; } int main () { int n = 0; int k = 0; int a = 0; int res = 0; int ans = 0; int cnt[100000] = {}; int sum = 0; res = scanf("%d", &n); res = scanf("%d", &k); for (int i = 0; i < n; i++) { res = scanf("%d", &a); cnt[a-1]++; } qsort(cnt, n, sizeof(int), cmp_int_rev); while (sum < k) { sum += cnt[ans]; ans++; } printf("%d\n", ans); return 0; }