結果

問題 No.2126 MEX Game
ユーザー kakel-san
提出日時 2023-10-18 01:06:19
言語 C#
(.NET 8.0.404)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 871 bytes
コンパイル時間 10,115 ms
コンパイル使用メモリ 171,416 KB
実行使用メモリ 184,920 KB
最終ジャッジ日時 2024-09-17 22:06:17
合計ジャッジ時間 10,066 ms
ジャッジサーバーID
(参考情報)
judge4 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (99 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 #

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 n = NN;
        var a = NList;
        if (n == 1)
        {
            WriteLine(0);
            return;
        }
        var count = new int[n / 2];
        foreach (var ai in a) if (ai < count.Length) ++count[ai];
        var tmp = 0;
        for (var i = 0; i < count.Length; ++i)
        {
            tmp += Math.Max(0, 2 - count[i]);
            if (tmp >= 2)
            {
                WriteLine(i);
                return;
            }
        }
        WriteLine(count.Length);
    }
}
0