結果

問題 No.1995 CHIKA Road
ユーザー lam6er
提出日時 2025-03-20 18:40:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 397 ms / 2,000 ms
コード長 287 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 82,844 KB
実行使用メモリ 92,096 KB
最終ジャッジ日時 2025-03-20 18:40:47
合計ジャッジ時間 10,675 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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