/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 16ms 3.039 MiB
#2 Wrong Answer 524ms 3.332 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-11-11 03:17:04
Judged By
Score
0
Total Time
524ms
Peak Memory
3.332 MiB