結果

問題 No.1995 CHIKA Road
ユーザー lam6er
提出日時 2025-03-20 20:17:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 400 ms / 2,000 ms
コード長 287 bytes
コンパイル時間 139 ms
コンパイル使用メモリ 82,480 KB
実行使用メモリ 91,896 KB
最終ジャッジ日時 2025-03-20 20:18:01
合計ジャッジ時間 9,235 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
shortcuts = [tuple(map(int, input().split())) for _ in range(m)]
shortcuts.sort(key=lambda x: (x[1], x[0]))

current_end = 0
count = 0

for a, b in shortcuts:
    if a >= current_end:
        count += 1
        current_end = b

print(2 * (n - 1) - count)
0