結果

問題 No.686 Uncertain LIS
ユーザー lam6er
提出日時 2025-03-31 17:27:07
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 452 bytes
コンパイル時間 135 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 89,000 KB
最終ジャッジ日時 2025-03-31 17:27:54
合計ジャッジ時間 6,395 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect

n = int(input())
intervals = [tuple(map(int, input().split())) for _ in range(n)]

tails = []

for L, R in intervals:
    idx = bisect.bisect_left(tails, R)
    j = idx - 1
    if j >= 0:
        current = tails[j] + 1
    else:
        current = L
    x = max(current, L)
    if x > R:
        continue
    if j + 1 < len(tails):
        if x < tails[j+1]:
            tails[j+1] = x
    else:
        tails.append(x)

print(len(tails))
0