結果
| 問題 | No.686 Uncertain LIS | 
| コンテスト | |
| ユーザー |  gew1fw | 
| 提出日時 | 2025-06-12 16:42:14 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,094 bytes | 
| コンパイル時間 | 465 ms | 
| コンパイル使用メモリ | 82,456 KB | 
| 実行使用メモリ | 112,912 KB | 
| 最終ジャッジ日時 | 2025-06-12 16:42:22 | 
| 合計ジャッジ時間 | 5,379 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 16 WA * 20 | 
ソースコード
import bisect
def main():
    import sys
    input = sys.stdin.read
    data = input().split()
    N = int(data[0])
    L = []
    R = []
    idx = 1
    for _ in range(N):
        l = int(data[idx])
        r = int(data[idx+1])
        L.append(l)
        R.append(r)
        idx += 2
    
    tails = []
    for i in range(N):
        l = L[i]
        r = R[i]
        if not tails:
            x = l
            tails.append(x)
            continue
        
        # Find k_max where tails[k_max] < r
        pos = bisect.bisect_left(tails, r)
        k_max = pos - 1
        
        if k_max == -1:
            x_candidate = l
        else:
            x_candidate = max(l, tails[k_max] + 1)
        
        if x_candidate > r:
            continue
        
        # Find position to insert x_candidate
        pos = bisect.bisect_left(tails, x_candidate)
        if pos == len(tails):
            tails.append(x_candidate)
        else:
            if x_candidate < tails[pos]:
                tails[pos] = x_candidate
    
    print(len(tails))
if __name__ == "__main__":
    main()
            
            
            
        