結果

問題 No.2777 Wild Flush
ユーザー tobisatistobisatis
提出日時 2024-06-07 21:25:53
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 1,867 bytes
コンパイル時間 10,834 ms
コンパイル使用メモリ 169,716 KB
実行使用メモリ 194,616 KB
最終ジャッジ日時 2024-06-07 21:26:09
合計ジャッジ時間 14,168 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
30,976 KB
testcase_01 AC 60 ms
30,720 KB
testcase_02 AC 60 ms
30,720 KB
testcase_03 AC 55 ms
29,824 KB
testcase_04 AC 61 ms
30,976 KB
testcase_05 AC 60 ms
30,720 KB
testcase_06 AC 55 ms
29,824 KB
testcase_07 AC 61 ms
30,972 KB
testcase_08 AC 61 ms
30,848 KB
testcase_09 AC 80 ms
36,972 KB
testcase_10 AC 83 ms
37,244 KB
testcase_11 AC 83 ms
37,376 KB
testcase_12 AC 98 ms
46,848 KB
testcase_13 AC 99 ms
44,800 KB
testcase_14 AC 99 ms
44,796 KB
testcase_15 AC 99 ms
44,800 KB
testcase_16 AC 62 ms
31,872 KB
testcase_17 AC 101 ms
44,288 KB
testcase_18 AC 94 ms
42,104 KB
testcase_19 AC 94 ms
42,244 KB
testcase_20 AC 82 ms
35,328 KB
testcase_21 AC 78 ms
34,304 KB
testcase_22 AC 93 ms
41,788 KB
testcase_23 AC 91 ms
41,404 KB
testcase_24 AC 93 ms
41,344 KB
testcase_25 AC 98 ms
44,672 KB
testcase_26 AC 98 ms
42,880 KB
testcase_27 AC 90 ms
37,760 KB
testcase_28 AC 78 ms
194,616 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (102 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

namespace AtCoder;

#nullable enable

using System.Numerics;

static class Extensions
{
    public static T[] Repeat<T>(this int time, Func<T> F) => Enumerable.Range(0, time).Select(_ => F()).ToArray();
}

class AtCoder
{
    object? Solve()
    {
        var n = Int();
        var k = Int();
        var d = new Dictionary<int, int>();
        var z = 0;
        for (var i = 0; i < n; i++)
        {
            var a = Int();
            if (a == 0)
            {
                z++;
                continue;
            }
            if (d.TryGetValue(a, out var v)) d[a] = v + 1;
            else d[a] = 1;
        }
        var max = 0;
        if (d.Count > 0) max = d.Values.Max();
        return max + z >= k;
    }

    public static void Main() => new AtCoder().Run();
    public void Run()
    {
        var res = Solve();
        if (res != null)
        {
            if (res is bool yes) res = yes ? "Yes" : "No";
            sw.WriteLine(res);
        }
        sw.Flush();
    }

    string[] input = Array.Empty<string>();
    int iter = 0;
    readonly StreamWriter sw = new(Console.OpenStandardOutput()) { AutoFlush = false };

    string String()
    {
        while (iter >= input.Length) (input, iter) = (Console.ReadLine()!.Split(' '), 0);
        return input[iter++];
    }
    T Input<T>() where T : IParsable<T> => T.Parse(String(), null);
    int Int() => Input<int>();
    void Out(object? x, string? separator = null)
    {
        separator ??= Environment.NewLine;
        if (x is System.Collections.IEnumerable obj and not string)
        {
            var firstLine = true;
            foreach (var item in obj)
            {
                if (!firstLine) sw.Write(separator);
                firstLine = false;
                sw.Write(item);
            }
        }
        else sw.Write(x);
        sw.WriteLine();
    }
}
0