/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 14ms 3.008 MiB
#2 Wrong Answer 14ms 3.137 MiB

Code

def find_min_freq_integer(A, Q):
    N = len(A)
    freq = [0] * N

    for _ in range(Q):
        l, r = map(int, input().split())
        l -= 1  # Adjust for 0-based indexing
        r -= 1

        min_freq = (r - l + 1) // 3 + 1

        # Update frequency array for the range [l, r]
        for i in range(l, r + 1):
            freq[A[i] - 1] += 1

        # Find the minimum integer with frequency > min_freq
        min_integer = -1
        for i in range(N):
            if freq[i] >= min_freq and (min_integer == -1 or A[i] < A[min_integer]):
                min_integer = i

        print(A[min_integer] if min_integer != -1 else -1)

        # Reset frequency array for the next query
        for i in range(l, r + 1):
            freq[A[i] - 1] = 0

# Read input
N, Q = map(int, input().split())
A = list(map(int, input().split()))

find_min_freq_integer(A, Q)

Information

Submit By
Type
Submission
Problem
P1103 The Secret Garden of Numbers
Contest
Brain Booster #7
Language
Python 3 (Python 3.12.3)
Submit At
2024-11-05 16:30:55
Judged At
2024-11-05 16:30:55
Judged By
Score
0
Total Time
14ms
Peak Memory
3.137 MiB