結果

問題 No.1995 CHIKA Road
ユーザー ntudantuda
提出日時 2022-10-10 21:03:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 468 ms / 2,000 ms
コード長 445 bytes
コンパイル時間 404 ms
コンパイル使用メモリ 87,264 KB
実行使用メモリ 154,448 KB
最終ジャッジ日時 2023-09-06 23:59:45
合計ジャッジ時間 13,069 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,348 KB
testcase_01 AC 68 ms
71,292 KB
testcase_02 AC 67 ms
71,152 KB
testcase_03 AC 68 ms
71,448 KB
testcase_04 AC 68 ms
71,264 KB
testcase_05 AC 72 ms
71,352 KB
testcase_06 AC 122 ms
79,716 KB
testcase_07 AC 173 ms
92,444 KB
testcase_08 AC 72 ms
71,148 KB
testcase_09 AC 70 ms
71,528 KB
testcase_10 AC 266 ms
88,516 KB
testcase_11 AC 468 ms
154,448 KB
testcase_12 AC 264 ms
128,060 KB
testcase_13 AC 208 ms
101,700 KB
testcase_14 AC 209 ms
99,080 KB
testcase_15 AC 398 ms
131,040 KB
testcase_16 AC 134 ms
82,588 KB
testcase_17 AC 264 ms
114,256 KB
testcase_18 AC 400 ms
142,312 KB
testcase_19 AC 401 ms
142,196 KB
testcase_20 AC 254 ms
100,756 KB
testcase_21 AC 240 ms
109,036 KB
testcase_22 AC 365 ms
116,452 KB
testcase_23 AC 175 ms
92,488 KB
testcase_24 AC 343 ms
129,200 KB
testcase_25 AC 148 ms
85,436 KB
testcase_26 AC 194 ms
97,980 KB
testcase_27 AC 323 ms
125,308 KB
testcase_28 AC 235 ms
107,300 KB
testcase_29 AC 376 ms
139,100 KB
testcase_30 AC 143 ms
85,156 KB
testcase_31 AC 117 ms
79,320 KB
testcase_32 AC 161 ms
84,960 KB
testcase_33 AC 316 ms
125,204 KB
testcase_34 AC 124 ms
79,436 KB
testcase_35 AC 191 ms
96,212 KB
testcase_36 AC 202 ms
93,540 KB
testcase_37 AC 357 ms
114,972 KB
testcase_38 AC 280 ms
116,476 KB
testcase_39 AC 119 ms
79,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, (input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]
S = set()
for a, b in AB:
    S.add(a)
    S.add(b)
B = sorted(list(S))
D = dict(zip(B, range(len(B))))
NB = len(B)

dp = [0] * (NB)
AB.sort(key=lambda x: x[1])
k = 0
for i in range(1, NB):
    b = B[i]
    dp[i] = dp[i - 1]
    while k < M and AB[k][1] == b:
        dp[i] = max(dp[i], dp[D[AB[k][0]]] + 1)
        k += 1
print(2 * N - dp[NB - 1] - 2)
0