結果
問題 | No.2650 [Cherry 6th Tune *] セイジャク |
ユーザー |
|
提出日時 | 2024-02-23 21:53:44 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,252 ms / 2,500 ms |
コード長 | 827 bytes |
コンパイル時間 | 399 ms |
コンパイル使用メモリ | 82,412 KB |
実行使用メモリ | 139,536 KB |
最終ジャッジ日時 | 2024-11-28 09:35:09 |
合計ジャッジ時間 | 57,110 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 31 |
ソースコード
N,A = map(int,input().split()) X = list(map(int,input().split())) T = int(input()) import heapq #X = [(X[i],i) for i in range(N)] q = [] for _ in range(T): l,r = map(int,input().split()) q.append((l,r)) h1 = [] h2 = [] for i in range(T): l,r = q[i] h1.append((l,-i,1)) h1.append((r,i + N + 100,2)) for i in range(N): x = X[i] h1.append((x,i,3)) heapq.heapify(h1) ans = [-1] * N s = set() while h1: now,j,f = heapq.heappop(h1) if f == 1: j = -j heapq.heappush(h2,-j) elif f == 2: j = j - N - 100 s.add(j) else: while h2: u = -heapq.heappop(h2) if u in s: continue else: ans[j] = u + 1 heapq.heappush(h2,-u) break for a in ans: print(a)