結果

問題 No.1995 CHIKA Road
ユーザー hir355hir355
提出日時 2022-07-01 21:40:38
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 322 ms / 2,000 ms
コード長 480 bytes
コンパイル時間 393 ms
コンパイル使用メモリ 87,156 KB
実行使用メモリ 155,888 KB
最終ジャッジ日時 2023-08-17 09:06:39
合計ジャッジ時間 8,961 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,104 KB
testcase_01 AC 70 ms
71,260 KB
testcase_02 AC 72 ms
71,568 KB
testcase_03 AC 72 ms
71,188 KB
testcase_04 AC 72 ms
71,444 KB
testcase_05 AC 74 ms
71,512 KB
testcase_06 AC 114 ms
79,240 KB
testcase_07 AC 149 ms
93,048 KB
testcase_08 AC 76 ms
71,368 KB
testcase_09 AC 75 ms
71,592 KB
testcase_10 AC 151 ms
85,080 KB
testcase_11 AC 322 ms
137,152 KB
testcase_12 AC 239 ms
118,324 KB
testcase_13 AC 173 ms
104,444 KB
testcase_14 AC 171 ms
103,392 KB
testcase_15 AC 319 ms
155,888 KB
testcase_16 AC 127 ms
82,384 KB
testcase_17 AC 207 ms
113,308 KB
testcase_18 AC 269 ms
130,988 KB
testcase_19 AC 271 ms
130,988 KB
testcase_20 AC 196 ms
108,824 KB
testcase_21 AC 180 ms
101,580 KB
testcase_22 AC 258 ms
128,300 KB
testcase_23 AC 151 ms
92,892 KB
testcase_24 AC 241 ms
123,668 KB
testcase_25 AC 128 ms
83,672 KB
testcase_26 AC 162 ms
95,824 KB
testcase_27 AC 231 ms
112,712 KB
testcase_28 AC 179 ms
101,604 KB
testcase_29 AC 270 ms
131,704 KB
testcase_30 AC 126 ms
83,452 KB
testcase_31 AC 114 ms
79,024 KB
testcase_32 AC 132 ms
85,832 KB
testcase_33 AC 223 ms
99,392 KB
testcase_34 AC 117 ms
79,248 KB
testcase_35 AC 155 ms
94,788 KB
testcase_36 AC 165 ms
96,784 KB
testcase_37 AC 262 ms
128,832 KB
testcase_38 AC 208 ms
112,276 KB
testcase_39 AC 113 ms
78,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

compress = lambda arr: {e: i for i, e in enumerate(sorted(set(arr)))}
n, m = map(int, input().split())
t = (n - 1) * 2
a = [0] * m
b = [0] * m
for i in range(m):
    a[i], b[i] = map(int, input().split())
cp = compress([1] + a + b + [n])
n = len(cp)
g = [[] for _ in range(n)]
for i in range(m):
    g[cp[a[i]]].append(cp[b[i]])
dp = [0] * n
for i in range(n - 1):
    dp[i + 1] = max(dp[i + 1], dp[i])
    for j in g[i]:
        dp[j] = max(dp[j], dp[i] + 1)
print(t - dp[n - 1])
0