結果
| 問題 |
No.649 ここでちょっとQK!
|
| コンテスト | |
| ユーザー |
6soukiti29
|
| 提出日時 | 2018-02-09 23:15:27 |
| 言語 | Nim (2.2.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,894 bytes |
| コンパイル時間 | 686 ms |
| コンパイル使用メモリ | 64,880 KB |
| 最終ジャッジ日時 | 2024-06-30 04:18:01 |
| 合計ジャッジ時間 | 2,584 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
/home/judge/data/code/Main.nim(23, 25) Warning: Number of spaces around '<=' is not consistent [Spacing]
/home/judge/data/code/Main.nim(48, 30) Error: type mismatch: got 'seq[int]' for 'map(split(readLine(stdin), {' ', '\t', '\v', '\r', '\n', '\f'}, -1), parseInt)' but expected 'tuple'
ソースコード
import sequtils,strutils
type
priorityQue[I:static[int];T:tuple] = array[I + 1,T]
item = tuple[cost: int64,ID : int64]
proc push[T](A:var priorityQue; b: T;)=
const key = 0
A[0][0] += 1
A[A[0][0]] = b
var index = A[0][0]
while index > 1 and A[index][key] > A[index div 2][key]:
(A[index],A[index div 2]) = (A[index div 2],A[index])
index = index div 2
proc pop(A: var priorityQue):item =
const key = 0
result = A[1]
A[1] = A[A[0][0]]
var a : item
A[A[0][0]] = a
A[0][0] -= 1
var index = 1
while index * 2 <= A[0][0]:
if index * 2 + 1<= A[0][0]:
if A[index][key] < A[index * 2][key] and A[index * 2 + 1][key] <= A[index * 2][key]:
(A[index],A[index * 2]) = (A[index * 2],A[index])
index = index * 2
elif A[index][key] < A[index * 2 + 1][key]:
(A[index],A[index * 2 + 1]) = (A[index * 2 + 1],A[index])
index = index * 2 + 1
else:
break
elif index * 2 <= A[0][0]:
if A[index][key] < A[index * 2][key]:
(A[index],A[index * 2]) = (A[index * 2],A[index])
break
else:
break
proc size(A : priorityQue):int64=
return A[0][0]
var
Q, K : int
pq1 : priorityQue[200001, item]
pq2 : priorityQue[200001, item]
q : seq[int64]
I,T : item
v : int64
(Q, K) = stdin.readline.split.map(parseInt)
for i in 1..Q:
q = stdin.readline.split.map(parseBiggestInt)
if q[0] == 1:
v = q[1]
if pq1.size < K - 1:
pq1.push((v, v))
elif pq1[1][1] <= v:
pq2.push((-v, v))
else:
I = pq1.pop
pq1.push((v, v))
pq2.push((-I.ID, I.ID))
else:
if pq2.size == 0:
echo -1
else:
echo pq2.pop.ID
6soukiti29