Roy and Maximum Partition
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
Time Limit: 4.0 s
Memory Limit: 256.0 MB
Description
You are given an array A[ ] and the length of the array is N.
You can rearrange this array A[ ]. After rearrange you can do following of the operations,
- Divide array A[ ] into maximum block.
- Each block has equal length
- Each block has at least two elements.
- Each block, different between Maximum and Minimum element should be equal for all. For example,
A[] ={1,3,4,2}, we can divide it, two blocks : {1,3}, {4,2}.
Different block {1,3} , Max element - Min element = 3 - 1 = 2 ;
Different block {4,2} , Max element - Min element = 4 - 2 = 2 ;
Find the maximum block of the array after ful-fill the above conditions.
Input
- First Line T,(1 ≤ T ≤ 50) the number of test cases.
- In each test case,first line contain an integer N, (2 ≤ N ≤ 30), - length of the array.
- Second line, an array A[], ( 1 ≤ A[] ≤ \(10^5\)) with exactly N elements.
Output
In each test case, print the maximum block of the array.
Sample
Input | Output |
---|---|
|
|
First test case:
Brain Booster #8
- Status
- Done
- Rule
- ACM/ICPC
- Problem
- 8
- Start at
- 2025-02-17 14:30
- End at
- 2025-02-17 17:00
- Duration
- 2.5 hour(s)
- Host
- Partic.
- 142