結果

問題 No.2334 Distinct Cards
ユーザー AdamantiteAdamantite
提出日時 2023-06-28 21:27:14
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 811 bytes
コンパイル時間 14,368 ms
コンパイル使用メモリ 148,248 KB
実行使用メモリ 163,948 KB
最終ジャッジ日時 2023-09-19 02:02:30
合計ジャッジ時間 19,207 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
28,520 KB
testcase_01 AC 56 ms
28,584 KB
testcase_02 AC 54 ms
28,516 KB
testcase_03 AC 53 ms
28,524 KB
testcase_04 AC 56 ms
28,640 KB
testcase_05 AC 54 ms
28,664 KB
testcase_06 AC 56 ms
30,636 KB
testcase_07 AC 57 ms
28,720 KB
testcase_08 AC 56 ms
28,712 KB
testcase_09 AC 57 ms
28,896 KB
testcase_10 AC 57 ms
28,832 KB
testcase_11 AC 55 ms
28,848 KB
testcase_12 AC 78 ms
38,756 KB
testcase_13 AC 76 ms
36,728 KB
testcase_14 AC 78 ms
38,648 KB
testcase_15 AC 77 ms
38,548 KB
testcase_16 AC 77 ms
38,604 KB
testcase_17 AC 76 ms
36,864 KB
testcase_18 AC 78 ms
40,704 KB
testcase_19 AC 77 ms
38,808 KB
testcase_20 AC 77 ms
38,584 KB
testcase_21 AC 77 ms
38,688 KB
testcase_22 AC 76 ms
36,820 KB
testcase_23 AC 52 ms
163,948 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  Determining projects to restore...
  Restored /home/judge/data/code/main.csproj (in 206 ms).
.NET 向け Microsoft (R) Build Engine バージョン 17.0.0-preview-21470-01+cb055d28f
Copyright (C) Microsoft Corporation.All rights reserved.

  プレビュー版の .NET を使用しています。https://aka.ms/dotnet-core-preview をご覧ください
  main -> /home/judge/data/code/bin/Release/net6.0/main.dll
  main -> /home/judge/data/code/bin/Release/net6.0/publish/

ソースコード

diff #

using System;

namespace No02334_DistinctCards
{
    internal class Program
    {
        static void Main(string[] args) {
            string[] param = Console.ReadLine().Split(' ');
            int n = int.Parse(param[0]);
            int k = int.Parse(param[1]);
            int[] array = Array.ConvertAll(Console.ReadLine().Split(' '), x => int.Parse(x));

            int[] countArray = new int[n];
            for(int i = 0; i < n; i++) {
                countArray[array[i] - 1]++;
            }
            Array.Sort(countArray);

            int total = 0;
            for (int i = n - 1; 0 <= i; i--) {
                total += countArray[i];
                if(k <= total) {
                    Console.WriteLine(n - i);
                    return;
                }
            }
        }
    }
}
0