結果

問題 No.1995 CHIKA Road
コンテスト
ユーザー lam6er
提出日時 2025-03-20 18:40:29
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 313 ms / 2,000 ms
コード長 287 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 238 ms
コンパイル使用メモリ 95,844 KB
実行使用メモリ 99,584 KB
最終ジャッジ日時 2026-07-07 07:16:19
合計ジャッジ時間 10,165 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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