結果
| 問題 | No.2422 regisys? | 
| コンテスト | |
| ユーザー |  gew1fw | 
| 提出日時 | 2025-06-12 19:46:26 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,853 bytes | 
| コンパイル時間 | 264 ms | 
| コンパイル使用メモリ | 81,844 KB | 
| 実行使用メモリ | 190,144 KB | 
| 最終ジャッジ日時 | 2025-06-12 19:46:55 | 
| 合計ジャッジ時間 | 21,552 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 42 WA * 19 | 
ソースコード
import bisect
def main():
    import sys
    input = sys.stdin.read
    data = input().split()
    idx = 0
    n = int(data[idx])
    idx += 1
    m = int(data[idx])
    idx += 1
    
    A = list(map(int, data[idx:idx+n]))
    idx += n
    B = list(map(int, data[idx:idx+n]))
    idx += n
    
    S0 = []
    S1 = []
    for _ in range(m):
        t = int(data[idx])
        c = int(data[idx+1])
        idx += 2
        if t == 0:
            S0.append(c)
        else:
            S1.append(c)
    
    S0.sort()
    S1.sort()
    
    items = []
    for i in range(n):
        a = A[i]
        b = B[i]
        min_val = min(a, b)
        items.append( (min_val, a, b) )
    
    items.sort()
    
    p0 = 0
    p1 = 0
    count = 0
    
    for min_val, a, b in items:
        idx0 = None
        if p0 < len(S0):
            idx0 = bisect.bisect_left(S0, a, p0)
            if idx0 < len(S0):
                idx0 = idx0
            else:
                idx0 = None
        else:
            idx0 = None
        
        idx1 = None
        if p1 < len(S1):
            idx1 = bisect.bisect_left(S1, b, p1)
            if idx1 < len(S1):
                idx1 = idx1
            else:
                idx1 = None
        else:
            idx1 = None
        
        if idx0 is None and idx1 is None:
            continue
        elif idx0 is None:
            count += 1
            p1 = idx1 + 1
        elif idx1 is None:
            count += 1
            p0 = idx0 + 1
        else:
            c0 = S0[idx0]
            c1 = S1[idx1]
            if c0 < c1:
                count += 1
                p0 = idx0 + 1
            elif c1 < c0:
                count += 1
                p1 = idx1 + 1
            else:
                count += 1
                p0 = idx0 + 1
    
    print(n - count)
if __name__ == '__main__':
    main()
            
            
            
        