結果

問題 No.686 Uncertain LIS
ユーザー lam6er
提出日時 2025-04-15 22:50:26
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 583 bytes
コンパイル時間 315 ms
コンパイル使用メモリ 81,848 KB
実行使用メモリ 79,712 KB
最終ジャッジ日時 2025-04-15 22:51:55
合計ジャッジ時間 5,362 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect

n = int(input())
tails = []
for _ in range(n):
    L, R = map(int, input().split())
    idx = bisect.bisect_left(tails, R)
    if idx == 0:
        x = L
        if x <= R:
            if not tails:
                tails.append(x)
            else:
                if x < tails[0]:
                    tails[0] = x
    else:
        k = idx - 1
        x = max(L, tails[k] + 1)
        if x > R:
            continue
        if idx >= len(tails):
            tails.append(x)
        else:
            if x < tails[idx]:
                tails[idx] = x
print(len(tails))
0