結果

問題 No.2796 Small Matryoshka
ユーザー 👑 kakel-sankakel-san
提出日時 2024-06-28 21:38:48
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 1,282 bytes
コンパイル時間 7,793 ms
コンパイル使用メモリ 169,636 KB
実行使用メモリ 244,176 KB
最終ジャッジ日時 2024-06-28 21:39:01
合計ジャッジ時間 12,823 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
30,336 KB
testcase_01 AC 52 ms
30,464 KB
testcase_02 AC 52 ms
30,208 KB
testcase_03 AC 50 ms
30,592 KB
testcase_04 WA -
testcase_05 AC 107 ms
44,544 KB
testcase_06 AC 376 ms
97,092 KB
testcase_07 AC 52 ms
30,464 KB
testcase_08 AC 255 ms
70,920 KB
testcase_09 AC 353 ms
76,240 KB
testcase_10 AC 399 ms
76,072 KB
testcase_11 AC 391 ms
76,492 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (93 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();
    static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var map = NArr(n);
        Array.Sort(map, (l, r) => l[0].CompareTo(r[0]));
        var set = new HashSet<int>();
        foreach (var m in map)
        {
            set.Add(m[0]);
            set.Add(m[1]);
        }
        var list = new List<int>(set);
        list.Sort();
        var dic = new Dictionary<int, int>();
        for (var i = 0; i < list.Count; ++i) dic[list[i]] = i;
        var pos = 0;
        var dp = new int[list.Count + 1];
        for (var i = 0; i < dp.Length; ++i)
        {
            if (i > 0) dp[i] = Math.Max(dp[i], dp[i - 1]);
            while (pos < n && dic[map[pos][0]] == i)
            {
                dp[dic[map[pos][1]]] = Math.Max(dp[dic[map[pos][1]]], dp[i] + 1);
                ++pos;
            }
        }
        WriteLine(n - dp[^1]);
    }
}
0