/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 16ms 3.09 MiB

Code


def solve_queries(N, A, Q, queries):
    # Initialize the minimum value and its index
    min_value = float('inf')
    min_index = -1

    # Find the initial minimum value and its index
    for i in range(N):
        if A[i] < min_value:
            min_value = A[i]
            min_index = i

    # Process each query
    for X in queries:
        # Print the position of the original minimum value
        print(min_index + 1)  # Adding 1 to convert from 0-based index to 1-based index

        # Update the array with the new value
        A[min_index] = X

        # Find the new minimum value and its index
        min_value = float('inf')
        for i in range(N):
            if A[i] < min_value:
                min_value = A[i]
                min_index = i

# Example usage
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
queries = [int(input()) for _ in range(Q)]

solve_queries(N, A, Q, queries)


Information

Submit By
Type
Pretest
Problem
P1086 KuZ the Position
Language
Python 3 (Python 3.12.3)
Submit At
2024-08-16 15:55:14
Judged At
2024-10-03 13:29:30
Judged By
Score
10
Total Time
16ms
Peak Memory
3.09 MiB