結果
問題 |
No.2220 Range Insert & Point Mex
|
ユーザー |
![]() |
提出日時 | 2025-04-15 23:24:42 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,538 bytes |
コンパイル時間 | 157 ms |
コンパイル使用メモリ | 82,516 KB |
実行使用メモリ | 152,204 KB |
最終ジャッジ日時 | 2025-04-15 23:26:23 |
合計ジャッジ時間 | 16,532 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 TLE * 1 |
ソースコード
def main(): import sys 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, 0, a)) # add event events.append((r + 1, 1, a)) # remove event # Sort events: by position, then add events (0) before remove events (1) events.sort() Q = int(input[ptr]) ptr += 1 queries = list(map(int, input[ptr:ptr + Q])) ptr += Q # Initialize variables count = {} m = 0 event_ptr = 0 res = [] for x in queries: # Process all events with pos <= x while event_ptr < len(events) and events[event_ptr][0] <= x: pos, typ, a = events[event_ptr] if typ == 0: # Add event if a in count: count[a] += 1 else: count[a] = 1 # Check if current m is affected while m in count: m += 1 else: # Remove event if a in count: if count[a] == 1: del count[a] if a < m: m = min(m, a) else: count[a] -= 1 event_ptr += 1 res.append(m) for num in res: print(num) if __name__ == "__main__": main()