Solutions are presented as using the least memory and the fastest execution time. It also takes the top
10 most recent solutions from each language. If you want to limit to a specific index, click the
"Solved" button and go to that problem.
Problems
B"Polycarp has n friends, the i -th of his friends has a_i candies. Polycarp's friends do not like when they have different numbers of candies. In other words they want all a_i to be the same. To solve this, Polycarp performs the following set of actions exactly once: Note that the number k is not fixed in advance and can be arbitrary. Your task is to find the minimum value of k . For example, if n=4 and a=[4, 5, 2, 5] , then Polycarp could make the following distribution of the candies: Note that in this example Polycarp cannot choose k=1 friend so that he can redistribute candies so that in the end all a_i are equal. For the data n and a , determine the minimum value k . With this value k , Polycarp should be able to select k friends and redistribute their candies so that everyone will end up with the same number of candies. The first line contains one integer t ( 1 <= t <= 10^4 ). Then t test cases follow. The first line of each test case contains one integer n ( 1 <= n <= 2 cdot 10^5 ). The second line contains n integers a_1, a_2, ldots, a_n ( 0 <= a_i <= 10^4 ). It is guaranteed that the sum of n over all test cases does not exceed 2 cdot 10^5 . For each test case output: "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
119103941 |
15532256331 |
B |
June 11, 2021, 12:20 a.m. |
OK |
GNU C++11 |
TESTS |
10 |
30 |
819200 |
|
|
119108970 |
zfybfq |
B |
June 11, 2021, 2:53 a.m. |
OK |
GNU C++11 |
TESTS |
10 |
30 |
3993600 |
|
|
119102448 |
_byta |
B |
June 10, 2021, 11:04 p.m. |
OK |
GNU C++11 |
TESTS |
10 |
30 |
6451200 |
|
|
119115893 |
One_Zzz |
B |
June 11, 2021, 4:52 a.m. |
OK |
GNU C++11 |
TESTS |
10 |
31 |
614400 |
|
|
119115409 |
Wuyanru |
B |
June 11, 2021, 4:45 a.m. |
OK |
GNU C++11 |
TESTS |
10 |
46 |
614400 |
|
|
119114354 |
Sham_Devour |
B |
June 11, 2021, 4:29 a.m. |
OK |
GNU C++11 |
TESTS |
10 |
46 |
819200 |
|
|
119110557 |
CaiXY06 |
B |
June 11, 2021, 3:23 a.m. |
OK |
GNU C++11 |
TESTS |
10 |
46 |
819200 |
|
|
119104006 |
2020linweitong |
B |
June 11, 2021, 12:24 a.m. |
OK |
GNU C++11 |
TESTS |
10 |
46 |
819200 |
|
|
119104831 |
I_do_not_know |
B |
June 11, 2021, 12:58 a.m. |
OK |
GNU C++11 |
TESTS |
10 |
46 |
1433600 |
|
|
119111869 |
_Sunrise |
B |
June 11, 2021, 3:47 a.m. |
OK |
GNU C++11 |
TESTS |
10 |
46 |
1638400 |
|
|
119121047 |
originalsidd |
B |
June 11, 2021, 5:58 a.m. |
OK |
GNU C++14 |
TESTS |
10 |
46 |
819200 |
|
|
119120921 |
abhishek.gururani |
B |
June 11, 2021, 5:56 a.m. |
OK |
GNU C++14 |
TESTS |
10 |
46 |
819200 |
|
|
119112646 |
ja3n2812 |
B |
June 11, 2021, 4:01 a.m. |
OK |
GNU C++14 |
TESTS |
10 |
46 |
819200 |
|
|
119108197 |
bhupathi07 |
B |
June 11, 2021, 2:36 a.m. |
OK |
GNU C++14 |
TESTS |
10 |
46 |
819200 |
|
|
119106625 |
v0rtex |
B |
June 11, 2021, 1:58 a.m. |
OK |
GNU C++14 |
TESTS |
10 |
46 |
819200 |
|
|
119105702 |
himv1998 |
B |
June 11, 2021, 1:29 a.m. |
OK |
GNU C++14 |
TESTS |
10 |
46 |
819200 |
|
|
119105614 |
__OS09__ |
B |
June 11, 2021, 1:26 a.m. |
OK |
GNU C++14 |
TESTS |
10 |
46 |
819200 |
|
|
119104154 |
Shruti_001 |
B |
June 11, 2021, 12:32 a.m. |
OK |
GNU C++14 |
TESTS |
10 |
46 |
819200 |
|
|
119103947 |
CarlosS48 |
B |
June 11, 2021, 12:21 a.m. |
OK |
GNU C++14 |
TESTS |
10 |
46 |
819200 |
|
|
119102897 |
namangpt2312 |
B |
June 10, 2021, 11:26 p.m. |
OK |
GNU C++14 |
TESTS |
10 |
46 |
819200 |
|
|
119115620 |
parth_99 |
B |
June 11, 2021, 4:48 a.m. |
OK |
GNU C++17 |
TESTS |
10 |
31 |
819200 |
|
|
119120116 |
zaied_AoS |
B |
June 11, 2021, 5:46 a.m. |
OK |
GNU C++17 |
TESTS |
10 |
46 |
716800 |
|
|
119121232 |
notTien4112004 |
B |
June 11, 2021, 6 a.m. |
OK |
GNU C++17 |
TESTS |
10 |
46 |
819200 |
|
|
119120812 |
parampamparam |
B |
June 11, 2021, 5:55 a.m. |
OK |
GNU C++17 |
TESTS |
10 |
46 |
819200 |
|
|
119120196 |
udbhav99 |
B |
June 11, 2021, 5:47 a.m. |
OK |
GNU C++17 |
TESTS |
10 |
46 |
819200 |
|
|
119119905 |
hitarthk_9 |
B |
June 11, 2021, 5:44 a.m. |
OK |
GNU C++17 |
TESTS |
10 |
46 |
819200 |
|
|
119119826 |
NotANoob |
B |
June 11, 2021, 5:43 a.m. |
OK |
GNU C++17 |
TESTS |
10 |
46 |
819200 |
|
|
119119030 |
Rexik_Geroj |
B |
June 11, 2021, 5:34 a.m. |
OK |
GNU C++17 |
TESTS |
10 |
46 |
819200 |
|
|
119119027 |
akashbhoi525 |
B |
June 11, 2021, 5:34 a.m. |
OK |
GNU C++17 |
TESTS |
10 |
46 |
819200 |
|
|
119118084 |
tonystark_3000 |
B |
June 11, 2021, 5:21 a.m. |
OK |
GNU C++17 |
TESTS |
10 |
46 |
819200 |
|
|
remove filters
Back to search problems