結果

問題 No.1995 CHIKA Road
ユーザー FromBooskaFromBooska
提出日時 2023-10-17 21:26:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 242 ms / 2,000 ms
コード長 563 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 81,732 KB
実行使用メモリ 84,012 KB
最終ジャッジ日時 2023-10-17 21:26:13
合計ジャッジ時間 7,144 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,484 KB
testcase_01 AC 38 ms
53,484 KB
testcase_02 AC 38 ms
53,484 KB
testcase_03 AC 39 ms
53,484 KB
testcase_04 AC 39 ms
53,484 KB
testcase_05 AC 39 ms
53,484 KB
testcase_06 AC 73 ms
73,524 KB
testcase_07 AC 105 ms
77,200 KB
testcase_08 AC 40 ms
53,488 KB
testcase_09 AC 39 ms
53,488 KB
testcase_10 AC 191 ms
80,984 KB
testcase_11 AC 236 ms
84,012 KB
testcase_12 AC 139 ms
83,736 KB
testcase_13 AC 113 ms
77,696 KB
testcase_14 AC 117 ms
77,840 KB
testcase_15 AC 200 ms
80,720 KB
testcase_16 AC 85 ms
76,324 KB
testcase_17 AC 156 ms
79,188 KB
testcase_18 AC 221 ms
81,220 KB
testcase_19 AC 220 ms
81,216 KB
testcase_20 AC 147 ms
79,192 KB
testcase_21 AC 139 ms
79,188 KB
testcase_22 AC 231 ms
81,188 KB
testcase_23 AC 107 ms
77,452 KB
testcase_24 AC 194 ms
80,984 KB
testcase_25 AC 90 ms
76,620 KB
testcase_26 AC 113 ms
77,728 KB
testcase_27 AC 188 ms
80,860 KB
testcase_28 AC 140 ms
79,192 KB
testcase_29 AC 242 ms
81,200 KB
testcase_30 AC 88 ms
76,460 KB
testcase_31 AC 73 ms
73,024 KB
testcase_32 AC 95 ms
76,788 KB
testcase_33 AC 192 ms
81,040 KB
testcase_34 AC 74 ms
73,796 KB
testcase_35 AC 111 ms
77,732 KB
testcase_36 AC 121 ms
78,196 KB
testcase_37 AC 210 ms
81,196 KB
testcase_38 AC 186 ms
79,196 KB
testcase_39 AC 71 ms
72,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 区間スケジューリングでの解き方、最初はそうやったね
# 長い近道ではなく、近道の回数が増えるのがベスト
# つまり近道で区間スケジューリングをやって何回使えるかカウントする

N, M = map(int, input().split())

edge_list = []
for i in range(M):
    a, b = map(int, input().split())
    edge_list.append((a, b))
edge_list.sort(key = lambda x:x[1])

count = 0
last = -1
for a, b in edge_list:
    if a >= last:
        count += 1
        last = b
#print(count)

ans = 2*(N-1)-count
print(ans)
0