結果

問題 No.2334 Distinct Cards
ユーザー 👑 kakel-sankakel-san
提出日時 2023-06-02 21:24:58
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 950 bytes
コンパイル時間 2,260 ms
コンパイル使用メモリ 72,272 KB
実行使用メモリ 34,352 KB
最終ジャッジ日時 2023-08-28 02:41:38
合計ジャッジ時間 5,106 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
23,912 KB
testcase_01 AC 64 ms
19,888 KB
testcase_02 AC 65 ms
21,780 KB
testcase_03 AC 65 ms
19,948 KB
testcase_04 AC 66 ms
21,952 KB
testcase_05 AC 65 ms
21,788 KB
testcase_06 AC 66 ms
21,796 KB
testcase_07 AC 75 ms
24,104 KB
testcase_08 AC 74 ms
21,984 KB
testcase_09 AC 74 ms
23,960 KB
testcase_10 AC 74 ms
21,972 KB
testcase_11 AC 73 ms
24,032 KB
testcase_12 AC 123 ms
33,356 KB
testcase_13 AC 122 ms
31,244 KB
testcase_14 AC 124 ms
31,240 KB
testcase_15 AC 122 ms
31,308 KB
testcase_16 AC 119 ms
31,300 KB
testcase_17 AC 125 ms
34,108 KB
testcase_18 AC 125 ms
34,272 KB
testcase_19 AC 126 ms
34,352 KB
testcase_20 AC 107 ms
28,084 KB
testcase_21 AC 109 ms
30,056 KB
testcase_22 AC 109 ms
28,112 KB
testcase_23 AC 64 ms
23,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, k) = (c[0], c[1]);
        var a = NList;
        var dic = new Dictionary<int, int>();
        foreach (var ai in a)
        {
            if (dic.ContainsKey(ai)) ++dic[ai];
            else dic[ai] = 1;
        }
        var list = new List<int>();
        foreach (var kv in dic) list.Add(kv.Value);
        list.Sort((l, r) => r.CompareTo(l));
        var ans = 0;
        foreach (var li in list)
        {
            if (k > 0)
            {
                ++ans;
                k -= li;
            }
        }
        WriteLine(ans);
    }
}
0