/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 30ms 19.523 MiB
#2 Wrong Answer 32ms 19.395 MiB

Code

def solve():
    T = int(input())  # number of test cases
    for _ in range(T):
        N = int(input())  # length of the array
        A = list(map(int, input().split()))  # the array itself
        
        # Sort the array first
        A.sort()
        
        # Try to find the maximum number of partitions
        max_partitions = 1  # At least one partition will always be possible
        
        for k in range(2, N + 1):  # k is the partition size
            if N % k == 0:  # Only consider k that divides N
                valid = True
                # Check if the difference between max and min is the same for all subarrays
                diff = A[k-1] - A[0]  # Initial difference in the first partition
                
                for i in range(k, N, k):
                    if A[i+k-1] - A[i] != diff:
                        valid = False
                        break
                
                if valid:
                    max_partitions = max(max_partitions, N // k)
        
        # Output the result for this test case
        print(max_partitions)

Information

Submit By
Type
Submission
Problem
P1162 Roy and Maximum Partition
Language
PyPy 3 (Python 3.9.18 PyPy 7.3.15)
Submit At
2025-01-21 14:09:04
Judged At
2025-01-21 14:09:04
Judged By
Score
0
Total Time
32ms
Peak Memory
19.523 MiB