結果
| 問題 | No.1675 Strange Minimum Query |
| コンテスト | |
| ユーザー |
ygd.
|
| 提出日時 | 2021-09-12 10:12:59 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 905 bytes |
| 記録 | |
| コンパイル時間 | 197 ms |
| コンパイル使用メモリ | 82,356 KB |
| 実行使用メモリ | 216,140 KB |
| 最終ジャッジ日時 | 2024-06-23 22:26:11 |
| 合計ジャッジ時間 | 20,477 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 WA * 21 |
ソースコード
import sys
input = sys.stdin.readline
from collections import defaultdict
from heapq import heapify, heappop, heappush, nlargest
def main():
N,Q = map(int,input().split()); INF = pow(10,9)
L = defaultdict(list)
R = defaultdict(list)
comp = set([])
query = []
PQ = []
for i in range(Q):
l,r,b = map(int,input().split())
l -= 1; r -= 1 #0-index
L[l].append((b,i))
R[r].append((b,i))
comp.add(b)
query.append((l,r,b))
ans = [INF]*N
i = 0
PQ = []
while i < N:
for b,idx in L[i]:
heappush(PQ,(-b,idx)) #-Minとクエリ番号
if PQ:
b,idx = heappop(PQ)
b *= -1
if query[idx][1] < i: #この制約を満たせていない
print(-1);exit()
ans[i] = b
i += 1
print(*ans)
if __name__ == '__main__':
main()
ygd.