結果

問題 No.2779 Don't make Pair
ユーザー 👑 kakel-sankakel-san
提出日時 2024-06-07 21:44:48
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 120 ms / 2,000 ms
コード長 1,217 bytes
コンパイル時間 7,293 ms
コンパイル使用メモリ 167,940 KB
実行使用メモリ 214,456 KB
最終ジャッジ日時 2024-06-07 21:45:13
合計ジャッジ時間 10,946 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
31,100 KB
testcase_01 AC 57 ms
30,976 KB
testcase_02 AC 57 ms
30,848 KB
testcase_03 AC 54 ms
30,080 KB
testcase_04 AC 56 ms
30,976 KB
testcase_05 AC 56 ms
30,976 KB
testcase_06 AC 54 ms
31,168 KB
testcase_07 AC 55 ms
31,100 KB
testcase_08 AC 53 ms
30,336 KB
testcase_09 AC 70 ms
33,536 KB
testcase_10 AC 83 ms
43,392 KB
testcase_11 AC 81 ms
34,816 KB
testcase_12 AC 90 ms
44,796 KB
testcase_13 AC 91 ms
45,440 KB
testcase_14 AC 84 ms
38,912 KB
testcase_15 AC 104 ms
55,620 KB
testcase_16 AC 104 ms
56,364 KB
testcase_17 AC 97 ms
48,384 KB
testcase_18 AC 93 ms
45,056 KB
testcase_19 AC 96 ms
49,280 KB
testcase_20 AC 83 ms
38,528 KB
testcase_21 AC 111 ms
58,556 KB
testcase_22 AC 120 ms
59,064 KB
testcase_23 AC 116 ms
60,424 KB
testcase_24 AC 108 ms
58,684 KB
testcase_25 AC 111 ms
58,816 KB
testcase_26 AC 110 ms
58,812 KB
testcase_27 AC 107 ms
58,940 KB
testcase_28 AC 105 ms
214,456 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (115 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;
        var dic = new Dictionary<int, List<int>>();
        for (var i = 0; i < n; ++i)
        {
            if (dic.ContainsKey(a[i])) dic[a[i]].Add(i);
            else dic[a[i]] = new List<int>{ i };
        }
        var kmin = 1;
        var kmax = n - 1;
        foreach (var kv in dic)
        {
            if (kv.Value.Count > 2)
            {
                WriteLine("0");
                WriteLine();
                return;
            }
            else if (kv.Value.Count == 2)
            {
                kmin = Math.Max(kmin, kv.Value[0] + 1);
                kmax = Math.Min(kmax, kv.Value[1]);
            }
        }
        var ans = new List<int>();
        for (var i = kmin; i <= kmax; ++i) ans.Add(i);
        WriteLine(ans.Count);
        WriteLine(string.Join(" ", ans));
    }
}
0