/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 21ms 3.098 MiB
#2 Wrong Answer 616ms 3.391 MiB
#3 Wrong Answer 673ms 3.695 MiB
#4 Wrong Answer 656ms 3.691 MiB
#5 Wrong Answer 868ms 18.117 MiB
#6 Wrong Answer 888ms 18.105 MiB

Code

import sys
from heapq import heappush, heappop

def solve():
    n = int(input())
    a = list(map(int, input().split()))
    q = int(input())

    heap = []
    for i, val in enumerate(a):
        heappush(heap, (val, i))

    for _ in range(q):
        x = int(input())
        while heap[0][0] < x:
            _, idx = heappop(heap)
            print(idx + 1, end=" ")
            heappush(heap, (x, idx))
            a[idx] = x
            break
        else:
            _, idx = heap[0]
            print(idx + 1, end=" ")
            heappop(heap)
            heappush(heap, (x, idx))
            a[idx] = x

    print()

if __name__ == "__main__":
    solve()

Information

Submit By
Type
Submission
Problem
P1086 KuZ the Position
Contest
Bangladesh 2.0
Language
Python 3 (Python 3.12.3)
Submit At
2024-08-16 15:52:30
Judged At
2024-10-03 13:29:38
Judged By
Score
0
Total Time
888ms
Peak Memory
18.117 MiB