結果
| 問題 | No.2220 Range Insert & Point Mex | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-02-17 22:47:21 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                TLE
                                 
                            (最新) 
                                AC
                                 
                            (最初) | 
| 実行時間 | - | 
| コード長 | 819 bytes | 
| コンパイル時間 | 362 ms | 
| コンパイル使用メモリ | 82,300 KB | 
| 実行使用メモリ | 122,604 KB | 
| 最終ジャッジ日時 | 2024-07-21 12:50:31 | 
| 合計ジャッジ時間 | 16,195 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 35 TLE * 1 | 
ソースコード
n = int(input())
LRA = [list(map(int,input().split())) for i in range(n)]
q = int(input())
X = list(map(int,input().split()))
M = 10**5+5
event = []
for l,r,a in LRA:
    if a >= M:
        continue
    event.append([l,a,0])
    event.append([r+1,a,1])
ans = []
event.sort()
mex = [0]*(10**5+5)
now = 0
mexnum = 0
le = len(event)
for x in X:
    # print(x)
    while now < le and event[now][0] <= x:
        _,a,t = event[now]
        now += 1
        if t == 0:
            mex[a] += 1
            if mexnum == a:
                while mex[mexnum]:
                    mexnum += 1
        else:
            mex[a] -= 1
            if mex[a] == 0 and mexnum > a:
                mexnum = a
    #     print(_,a,t,mexnum)
    #     print(mex[:10])
    # print(x,mexnum)
    ans.append(mexnum)
for i in ans:
    print(i)
            
            
            
        