結果

問題 No.1995 CHIKA Road
ユーザー Kiri8128Kiri8128
提出日時 2022-07-01 21:49:24
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 356 ms / 2,000 ms
コード長 492 bytes
コンパイル時間 571 ms
コンパイル使用メモリ 86,976 KB
実行使用メモリ 175,020 KB
最終ジャッジ日時 2023-08-17 09:21:30
合計ジャッジ時間 9,483 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,496 KB
testcase_01 AC 70 ms
71,264 KB
testcase_02 AC 71 ms
71,216 KB
testcase_03 AC 72 ms
71,468 KB
testcase_04 AC 72 ms
71,464 KB
testcase_05 AC 75 ms
71,336 KB
testcase_06 AC 138 ms
79,492 KB
testcase_07 AC 160 ms
94,852 KB
testcase_08 AC 75 ms
71,228 KB
testcase_09 AC 73 ms
71,588 KB
testcase_10 AC 174 ms
91,868 KB
testcase_11 AC 356 ms
175,020 KB
testcase_12 AC 250 ms
120,140 KB
testcase_13 AC 167 ms
94,884 KB
testcase_14 AC 172 ms
94,640 KB
testcase_15 AC 293 ms
153,204 KB
testcase_16 AC 125 ms
82,976 KB
testcase_17 AC 214 ms
115,632 KB
testcase_18 AC 264 ms
126,192 KB
testcase_19 AC 268 ms
126,256 KB
testcase_20 AC 207 ms
112,700 KB
testcase_21 AC 196 ms
108,132 KB
testcase_22 AC 267 ms
128,628 KB
testcase_23 AC 162 ms
95,796 KB
testcase_24 AC 258 ms
126,840 KB
testcase_25 AC 133 ms
84,668 KB
testcase_26 AC 169 ms
96,732 KB
testcase_27 AC 250 ms
124,568 KB
testcase_28 AC 203 ms
107,832 KB
testcase_29 AC 329 ms
130,212 KB
testcase_30 AC 130 ms
84,316 KB
testcase_31 AC 119 ms
78,928 KB
testcase_32 AC 153 ms
90,152 KB
testcase_33 AC 247 ms
124,192 KB
testcase_34 AC 121 ms
79,540 KB
testcase_35 AC 162 ms
96,080 KB
testcase_36 AC 166 ms
92,284 KB
testcase_37 AC 272 ms
129,840 KB
testcase_38 AC 213 ms
112,732 KB
testcase_39 AC 123 ms
78,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
X = []
A = []
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    X.append((a, b))
    A.append(a)
    A.append(b)

SA = sorted(set(A))
IA = {a: i for i, a in enumerate(SA)}
X = [(IA[a], IA[b]) for a, b in X]
Z = [[] for _ in range(len(SA))]
for a, b in X:
    Z[a].append(b)
Y = [0] * len(SA)

for i in range(len(SA)):
    Y[i] = max(Y[i], Y[i-1])
    for j in Z[i]:
        Y[j] = max(Y[j], Y[i] + 1)
print((N - 1) * 2 - Y[-1])
0