結果

問題 No.1995 CHIKA Road
ユーザー FromBooskaFromBooska
提出日時 2023-04-07 05:52:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 208 ms / 2,000 ms
コード長 761 bytes
コンパイル時間 213 ms
コンパイル使用メモリ 82,096 KB
実行使用メモリ 84,440 KB
最終ジャッジ日時 2024-04-10 16:11:00
合計ジャッジ時間 6,516 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
52,864 KB
testcase_01 AC 33 ms
52,688 KB
testcase_02 AC 31 ms
52,552 KB
testcase_03 AC 31 ms
53,000 KB
testcase_04 AC 31 ms
53,420 KB
testcase_05 AC 34 ms
52,592 KB
testcase_06 AC 73 ms
74,068 KB
testcase_07 AC 96 ms
77,768 KB
testcase_08 AC 39 ms
54,752 KB
testcase_09 AC 39 ms
54,448 KB
testcase_10 AC 173 ms
81,836 KB
testcase_11 AC 208 ms
84,440 KB
testcase_12 AC 127 ms
84,052 KB
testcase_13 AC 100 ms
78,088 KB
testcase_14 AC 97 ms
78,088 KB
testcase_15 AC 174 ms
81,172 KB
testcase_16 AC 78 ms
76,796 KB
testcase_17 AC 135 ms
79,500 KB
testcase_18 AC 187 ms
81,636 KB
testcase_19 AC 188 ms
81,624 KB
testcase_20 AC 127 ms
79,340 KB
testcase_21 AC 123 ms
79,548 KB
testcase_22 AC 183 ms
81,732 KB
testcase_23 AC 97 ms
77,756 KB
testcase_24 AC 166 ms
81,352 KB
testcase_25 AC 83 ms
77,140 KB
testcase_26 AC 98 ms
78,100 KB
testcase_27 AC 163 ms
81,388 KB
testcase_28 AC 115 ms
79,656 KB
testcase_29 AC 177 ms
81,764 KB
testcase_30 AC 73 ms
76,876 KB
testcase_31 AC 60 ms
73,896 KB
testcase_32 AC 78 ms
77,072 KB
testcase_33 AC 161 ms
81,512 KB
testcase_34 AC 63 ms
74,252 KB
testcase_35 AC 93 ms
78,016 KB
testcase_36 AC 98 ms
78,484 KB
testcase_37 AC 172 ms
81,388 KB
testcase_38 AC 134 ms
79,480 KB
testcase_39 AC 61 ms
73,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# Nが大きい、ダイクストラ法ではおそらくできない
# a<bであり、start<goalなので、1次元dpで前から決定できるのでは
# と思ったがNがまだ大きすぎる
# 要はショートカットを何回使えるか、使えた回数分だけ歩数も少なくなる
# ショートカットを何回使えるかをどうやって調べるか
# グラフ、新たな1次元dpも考えたが区間スケジューリングがよいのでは

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

#print(AB)

count = 0
last = -1 
for a, b in AB:
    if a >= last:
        count += 1
        last = b
ans = (N-1)*2 - count
print(ans)
0