結果
| 問題 |
No.2220 Range Insert & Point Mex
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-15 23:25:55 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,320 bytes |
| コンパイル時間 | 218 ms |
| コンパイル使用メモリ | 82,296 KB |
| 実行使用メモリ | 160,068 KB |
| 最終ジャッジ日時 | 2025-04-15 23:27:40 |
| 合計ジャッジ時間 | 18,495 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 TLE * 1 |
ソースコード
import sys
from collections import defaultdict
def main():
input = sys.stdin.read().split()
ptr = 0
N = int(input[ptr])
ptr += 1
events = []
for _ in range(N):
l = int(input[ptr])
r = int(input[ptr + 1])
a = int(input[ptr + 2])
ptr += 3
events.append((l, 1, a))
events.append((r + 1, -1, a))
events.sort(key=lambda x: (x[0], x[1]))
Q = int(input[ptr])
ptr += 1
x_list = list(map(int, input[ptr:ptr + Q]))
ptr += Q
e = 0
count = defaultdict(int)
present = set()
mex = 0
for x in x_list:
while e < len(events):
pos, typ, a = events[e]
if pos > x:
break
if typ == 1:
if a >= 0:
count[a] += 1
if count[a] == 1:
present.add(a)
while mex in present:
mex += 1
else:
if a >= 0:
count[a] -= 1
if count[a] == 0:
if a in present:
present.remove(a)
if a < mex:
mex = a
e += 1
print(mex)
if __name__ == "__main__":
main()
lam6er