結果
| 問題 |
No.2650 [Cherry 6th Tune *] セイジャク
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-02-23 21:39:32 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 874 ms / 2,500 ms |
| コード長 | 969 bytes |
| コンパイル時間 | 216 ms |
| コンパイル使用メモリ | 82,300 KB |
| 実行使用メモリ | 236,068 KB |
| 最終ジャッジ日時 | 2024-09-29 05:54:40 |
| 合計ジャッジ時間 | 24,269 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 31 |
ソースコード
import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes")
no = lambda :print("no");No = lambda :print("No")
#######################################################################
N, A = na()
X = na()
T = ni()
from collections import defaultdict
s_in = defaultdict(list)
s_out = defaultdict(list)
p = defaultdict(list)
for i in range(T):
l, r = na()
s_in[l].append(i)
s_out[r].append(i)
for i in range(N):
p[X[i]].append(i)
loc = sorted(set(list(s_in)+list(s_out)+list(p)))
from heapq import heappop, heappush
hq = []
ans = [-1] * N
removed = [0] * T
for x in loc:
for i in s_in[x]:
heappush(hq, -i)
for i in p[x]:
while hq and removed[-hq[0]]:
heappop(hq)
if hq:
j = -hq[0]
ans[i] = j+1
for i in s_out[x]:
removed[i] = 1
for i in ans:
print(i)