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"You are given an array a of n integers. Initially there is only one copy of the given array. You can do operations of two types: You need to find the minimal number of operations needed to obtain a copy where all elements are equal. The input consists of multiple test cases. The first line contains a single integer t ( 1 <= t <= 10^4 ) -- the number of test cases. Description of the test cases follows. The first line of each test case contains a single integer n ( 1 <= n <= 10^5 ) -- the length of the array a . The second line of each test case contains n integers a_1, a_2, ldots, a_n ( -10^9 <= a_i <= 10^9 ) -- the elements of the array a . It is guaranteed that the sum of n over all test cases does not exceed 10^5 . For each test case output a single integer -- the minimal number of operations needed to create at least one copy where all elements are equal. In the first test case all elements in the array are already equal, that's why the answer is 0 . In the second test case it is possible to create a copy of the given array. After that there will be two identical arrays: [ 0 1 3 3 7 0 ] and [ 0 1 3 3 7 0 ] After that we can swap elements in a way so all zeroes are in one array: [ 0 underline{0} underline{0} 3 7 0 ] and [ underline{1} 1 3 3 7 underline{3} ] Now let's create a copy of the first array: [ 0 0 0 3 7 0 ] , [ 0 0 0 3 7 0 ] and [ 1 1 3 3 7 3 ] Let's swap elements in the first two copies: [ 0 0 0 underline{0} underline{0} 0 ] , [ underline{3} underline{7} 0 3 7 0 ] and [ 1 1 3 3 7 3 ] . Finally, we made a copy where all elements are equal and made 6 operations. It can be proven that no fewer operations are enough. "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
153076915 |
sunny12345 |
B |
April 8, 2022, 5:19 p.m. |
OK |
GNU C11 |
TESTS |
15 |
62 |
409600 |
|
|
153077546 |
Sahil2610 |
B |
April 8, 2022, 5:25 p.m. |
OK |
GNU C11 |
TESTS |
15 |
62 |
409600 |
|
|
153106501 |
Wesen |
B |
April 9, 2022, 3:07 a.m. |
OK |
GNU C11 |
TESTS |
15 |
78 |
409600 |
|
|
153103514 |
loverpaul |
B |
April 9, 2022, 1:48 a.m. |
OK |
GNU C++14 |
TESTS |
15 |
31 |
409600 |
|
|
153107796 |
CmsMartin |
B |
April 9, 2022, 3:37 a.m. |
OK |
GNU C++14 |
TESTS |
15 |
31 |
819200 |
|
|
153112692 |
abhii_now |
B |
April 9, 2022, 5:13 a.m. |
OK |
GNU C++14 |
TESTS |
15 |
46 |
409600 |
|
|
153103971 |
mohen |
B |
April 9, 2022, 2:03 a.m. |
OK |
GNU C++14 |
TESTS |
15 |
46 |
409600 |
|
|
153102264 |
hanmo |
B |
April 9, 2022, 1:08 a.m. |
OK |
GNU C++14 |
TESTS |
15 |
46 |
409600 |
|
|
153099946 |
fzj2007 |
B |
April 9, 2022, 12:02 a.m. |
OK |
GNU C++14 |
TESTS |
15 |
46 |
409600 |
|
|
153098962 |
panyanppyy |
B |
April 8, 2022, 11:35 p.m. |
OK |
GNU C++14 |
TESTS |
15 |
46 |
409600 |
|
|
153098339 |
dengziyue |
B |
April 8, 2022, 11:18 p.m. |
OK |
GNU C++14 |
TESTS |
15 |
46 |
409600 |
|
|
153091343 |
aman_086 |
B |
April 8, 2022, 8:34 p.m. |
OK |
GNU C++14 |
TESTS |
15 |
46 |
409600 |
|
|
153114740 |
fikr_not |
B |
April 9, 2022, 5:43 a.m. |
OK |
GNU C++14 |
TESTS |
15 |
46 |
409600 |
|
|
153087566 |
higz |
B |
April 8, 2022, 7:32 p.m. |
OK |
GNU C++17 |
TESTS |
15 |
31 |
409600 |
|
|
153085363 |
C0derX |
B |
April 8, 2022, 6:56 p.m. |
OK |
GNU C++17 |
TESTS |
15 |
31 |
409600 |
|
|
153081788 |
hpx |
B |
April 8, 2022, 6:08 p.m. |
OK |
GNU C++17 |
TESTS |
15 |
31 |
409600 |
|
|
153088761 |
Riblji_Keksic |
B |
April 8, 2022, 7:51 p.m. |
OK |
GNU C++17 |
TESTS |
15 |
31 |
409600 |
|
|
153102765 |
xlykle |
B |
April 9, 2022, 1:23 a.m. |
OK |
GNU C++17 |
TESTS |
15 |
31 |
819200 |
|
|
153106160 |
srinivasyeleti |
B |
April 9, 2022, 2:59 a.m. |
OK |
GNU C++17 |
TESTS |
15 |
31 |
3379200 |
|
|
153111811 |
msvardhan19 |
B |
April 9, 2022, 4:59 a.m. |
OK |
GNU C++17 |
TESTS |
15 |
46 |
409600 |
|
|
153110509 |
1510 |
B |
April 9, 2022, 4:34 a.m. |
OK |
GNU C++17 |
TESTS |
15 |
46 |
409600 |
|
|
153110466 |
Tarique_Abid |
B |
April 9, 2022, 4:33 a.m. |
OK |
GNU C++17 |
TESTS |
15 |
46 |
409600 |
|
|
153102889 |
fengx0000 |
B |
April 9, 2022, 1:27 a.m. |
OK |
GNU C++17 |
TESTS |
15 |
46 |
409600 |
|
|
153069749 |
VaibhavdLights |
B |
April 8, 2022, 4:27 p.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
31 |
409600 |
|
|
153102197 |
xhgua |
B |
April 9, 2022, 1:06 a.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
31 |
409600 |
|
|
153092014 |
kal013 |
B |
April 8, 2022, 8:45 p.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
31 |
409600 |
|
|
153074495 |
mandy_17 |
B |
April 8, 2022, 5:03 p.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
31 |
819200 |
|
|
153079085 |
ball_of_wool |
B |
April 8, 2022, 5:38 p.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
31 |
819200 |
|
|
153076669 |
knightingale |
B |
April 8, 2022, 5:17 p.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
31 |
6144000 |
|
|
153103983 |
LightInShadow |
B |
April 9, 2022, 2:03 a.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
46 |
409600 |
|
|
153104007 |
LightInShadow |
B |
April 9, 2022, 2:04 a.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
46 |
409600 |
|
|
153112963 |
KhaledAtef |
B |
April 9, 2022, 5:17 a.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
46 |
819200 |
|
|
153065309 |
silent1um |
B |
April 8, 2022, 4:13 p.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
46 |
819200 |
|
|
153109962 |
Himanshu_V_Pawar |
B |
April 9, 2022, 4:22 a.m. |
OK |
GNU C++20 (64) |
TESTS |
15 |
15 |
819200 |
|
|
153110444 |
newbiehda |
B |
April 9, 2022, 4:33 a.m. |
OK |
GNU C++20 (64) |
TESTS |
15 |
15 |
7987200 |
|
|
153081095 |
AnonymousGuy12 |
B |
April 8, 2022, 6 p.m. |
OK |
GNU C++20 (64) |
TESTS |
15 |
31 |
409600 |
|
|
153102279 |
return20071007 |
B |
April 9, 2022, 1:08 a.m. |
OK |
GNU C++20 (64) |
TESTS |
15 |
31 |
409600 |
|
|
153087721 |
ParsaEs |
B |
April 8, 2022, 7:34 p.m. |
OK |
GNU C++20 (64) |
TESTS |
15 |
31 |
409600 |
|
|
153081167 |
Siddharth2EEE |
B |
April 8, 2022, 6:01 p.m. |
OK |
GNU C++20 (64) |
TESTS |
15 |
31 |
409600 |
|
|
153070774 |
Vesito |
B |
April 8, 2022, 4:30 p.m. |
OK |
GNU C++20 (64) |
TESTS |
15 |
31 |
409600 |
|
|
153073998 |
AdiletAdilet |
B |
April 8, 2022, 5:01 p.m. |
OK |
GNU C++20 (64) |
TESTS |
15 |
31 |
819200 |
|
|
153074024 |
N_Ed |
B |
April 8, 2022, 5:01 p.m. |
OK |
GNU C++20 (64) |
TESTS |
15 |
31 |
1126400 |
|
|
153110148 |
jigyansu_nanda |
B |
April 9, 2022, 4:26 a.m. |
OK |
GNU C++20 (64) |
TESTS |
15 |
31 |
4915200 |
|
|
153066816 |
likepeppermint |
B |
April 8, 2022, 4:18 p.m. |
OK |
Go |
TESTS |
15 |
77 |
4812800 |
|
|
153065520 |
MarcelShi_96 |
B |
April 8, 2022, 4:14 p.m. |
OK |
Go |
TESTS |
15 |
108 |
4915200 |
|
|
153103382 |
018429 |
B |
April 9, 2022, 1:43 a.m. |
OK |
Go |
TESTS |
15 |
109 |
4812800 |
|
|
153089598 |
DEMO23 |
B |
April 8, 2022, 8:05 p.m. |
OK |
Java 11 |
TESTS |
15 |
202 |
3993600 |
|
|
153081193 |
deepakjoshi6102 |
B |
April 8, 2022, 6:01 p.m. |
OK |
Java 11 |
TESTS |
15 |
218 |
1126400 |
|
|
153082319 |
_ryan18_ |
B |
April 8, 2022, 6:14 p.m. |
OK |
Java 11 |
TESTS |
15 |
218 |
2764800 |
|
|
153109484 |
namnh97 |
B |
April 9, 2022, 4:12 a.m. |
OK |
Java 11 |
TESTS |
15 |
233 |
921600 |
|
|
153080359 |
SaberXpro |
B |
April 8, 2022, 5:52 p.m. |
OK |
Java 11 |
TESTS |
15 |
233 |
2662400 |
|
|
153105823 |
kartikpapney |
B |
April 9, 2022, 2:51 a.m. |
OK |
Java 11 |
TESTS |
15 |
233 |
2662400 |
|
|
153080779 |
mayank.singh19 |
B |
April 8, 2022, 5:56 p.m. |
OK |
Java 11 |
TESTS |
15 |
264 |
1024000 |
|
|
153082829 |
vijender_8601 |
B |
April 8, 2022, 6:20 p.m. |
OK |
Java 11 |
TESTS |
15 |
264 |
1843200 |
|
|
153079977 |
Plums |
B |
April 8, 2022, 5:48 p.m. |
OK |
Java 11 |
TESTS |
15 |
265 |
921600 |
|
|
153101679 |
__Serendipity |
B |
April 9, 2022, 12:50 a.m. |
OK |
Java 11 |
TESTS |
15 |
280 |
1228800 |
|
|
153093552 |
Koka |
B |
April 8, 2022, 9:14 p.m. |
OK |
Java 8 |
TESTS |
15 |
155 |
0 |
|
|
153094112 |
AbdulazizHassan |
B |
April 8, 2022, 9:25 p.m. |
OK |
Java 8 |
TESTS |
15 |
171 |
0 |
|
|
153094090 |
Ah86543 |
B |
April 8, 2022, 9:25 p.m. |
OK |
Java 8 |
TESTS |
15 |
171 |
0 |
|
|
153098055 |
Abdallah_Ragab00 |
B |
April 8, 2022, 11:09 p.m. |
OK |
Java 8 |
TESTS |
15 |
186 |
4915200 |
|
|
153094035 |
IcantSeeCsharp |
B |
April 8, 2022, 9:24 p.m. |
OK |
Java 8 |
TESTS |
15 |
187 |
1945600 |
|
|
153093631 |
IcantSeeCsharp |
B |
April 8, 2022, 9:16 p.m. |
OK |
Java 8 |
TESTS |
15 |
202 |
2048000 |
|
|
153086961 |
rish1896 |
B |
April 8, 2022, 7:22 p.m. |
OK |
Java 8 |
TESTS |
15 |
202 |
6553600 |
|
|
153085581 |
VishuTomar |
B |
April 8, 2022, 6:59 p.m. |
OK |
Java 8 |
TESTS |
15 |
218 |
4403200 |
|
|
153088952 |
rish1896 |
B |
April 8, 2022, 7:54 p.m. |
OK |
Java 8 |
TESTS |
15 |
218 |
6553600 |
|
|
153112938 |
Wolfy01 |
B |
April 9, 2022, 5:17 a.m. |
OK |
Java 8 |
TESTS |
15 |
342 |
0 |
|
|
153078257 |
hanel1164 |
B |
April 8, 2022, 5:31 p.m. |
OK |
Kotlin 1.4 |
TESTS |
15 |
202 |
7475200 |
|
|
153099368 |
meinego |
B |
April 8, 2022, 11:46 p.m. |
OK |
Kotlin 1.4 |
TESTS |
15 |
202 |
7475200 |
|
|
153067286 |
jaintle |
B |
April 8, 2022, 4:19 p.m. |
OK |
MS C++ 2017 |
TESTS |
15 |
124 |
409600 |
|
|
153069916 |
MaksimLogic |
B |
April 8, 2022, 4:27 p.m. |
OK |
MS C++ 2017 |
TESTS |
15 |
124 |
4915200 |
|
|
153074551 |
code-n-roll |
B |
April 8, 2022, 5:03 p.m. |
OK |
MS C++ 2017 |
TESTS |
15 |
140 |
3584000 |
|
|
153115437 |
Aayush5sep |
B |
April 9, 2022, 5:52 a.m. |
OK |
MS C++ 2017 |
TESTS |
15 |
155 |
3276800 |
|
|
153083650 |
Viktor36 |
B |
April 8, 2022, 6:31 p.m. |
OK |
MS C++ 2017 |
TESTS |
15 |
155 |
4915200 |
|
|
153077333 |
justaguyalways |
B |
April 8, 2022, 5:23 p.m. |
OK |
MS C++ 2017 |
TESTS |
15 |
171 |
4710400 |
|
|
153098386 |
Olasiliksizci |
B |
April 8, 2022, 11:19 p.m. |
OK |
.NET Core C# |
TESTS |
15 |
124 |
10444800 |
|
|
153084854 |
manan.garg1504 |
B |
April 8, 2022, 6:49 p.m. |
OK |
.NET Core C# |
TESTS |
15 |
217 |
16691200 |
|
|
153094265 |
1_2_3_4_5_9 |
B |
April 8, 2022, 9:28 p.m. |
OK |
PyPy 2 |
TESTS |
15 |
171 |
11673600 |
|
|
153076397 |
ambs_ |
B |
April 8, 2022, 5:15 p.m. |
OK |
PyPy 3 |
TESTS |
15 |
296 |
15564800 |
|
|
153096731 |
davidchi |
B |
April 8, 2022, 10:27 p.m. |
OK |
PyPy 3 |
TESTS |
15 |
390 |
13414400 |
|
|
153067471 |
Sovi_11 |
B |
April 8, 2022, 4:20 p.m. |
OK |
PyPy 3 |
TESTS |
15 |
499 |
13004800 |
|
|
153068578 |
kandarp.s |
B |
April 8, 2022, 4:23 p.m. |
OK |
PyPy 3 |
TESTS |
15 |
560 |
13926400 |
|
|
153078935 |
God_Player |
B |
April 8, 2022, 5:37 p.m. |
OK |
PyPy 3 |
TESTS |
15 |
561 |
15257600 |
|
|
153067522 |
Maksadbek |
B |
April 8, 2022, 4:20 p.m. |
OK |
PyPy 3 |
TESTS |
15 |
842 |
16076800 |
|
|
153083613 |
skp_r |
B |
April 8, 2022, 6:31 p.m. |
OK |
PyPy 3-64 |
TESTS |
15 |
124 |
20070400 |
|
|
153100487 |
_MADARA_ |
B |
April 9, 2022, 12:16 a.m. |
OK |
PyPy 3-64 |
TESTS |
15 |
124 |
20787200 |
|
|
153111367 |
rivnam |
B |
April 9, 2022, 4:51 a.m. |
OK |
PyPy 3-64 |
TESTS |
15 |
186 |
20684800 |
|
|
153077053 |
warrenbuffet |
B |
April 8, 2022, 5:21 p.m. |
OK |
PyPy 3-64 |
TESTS |
15 |
218 |
20070400 |
|
|
153110995 |
notTehlka |
B |
April 9, 2022, 4:44 a.m. |
OK |
PyPy 3-64 |
TESTS |
15 |
218 |
20684800 |
|
|
153083379 |
kboi |
B |
April 8, 2022, 6:27 p.m. |
OK |
PyPy 3-64 |
TESTS |
15 |
218 |
27238400 |
|
|
153069514 |
UnreliableSpare |
B |
April 8, 2022, 4:26 p.m. |
OK |
PyPy 3-64 |
TESTS |
15 |
311 |
30617600 |
|
|
153068398 |
orsikus |
B |
April 8, 2022, 4:23 p.m. |
OK |
PyPy 3-64 |
TESTS |
15 |
327 |
21401600 |
|
|
153070527 |
YamOCHca |
B |
April 8, 2022, 4:29 p.m. |
OK |
PyPy 3-64 |
TESTS |
15 |
343 |
20377600 |
|
|
153097509 |
Liberator187 |
B |
April 8, 2022, 10:52 p.m. |
OK |
PyPy 3-64 |
TESTS |
15 |
358 |
21606400 |
|
|
153114357 |
azaraks |
B |
April 9, 2022, 5:37 a.m. |
OK |
Python 3 |
TESTS |
15 |
108 |
9420800 |
|
|
153078330 |
eugalt |
B |
April 8, 2022, 5:31 p.m. |
OK |
Python 3 |
TESTS |
15 |
108 |
11980800 |
|
|
153107513 |
jaygaur99 |
B |
April 9, 2022, 3:30 a.m. |
OK |
Python 3 |
TESTS |
15 |
109 |
8806400 |
|
|
153082538 |
nife |
B |
April 8, 2022, 6:17 p.m. |
OK |
Python 3 |
TESTS |
15 |
124 |
9318400 |
|
|
153112098 |
Pythonic__Python |
B |
April 9, 2022, 5:03 a.m. |
OK |
Python 3 |
TESTS |
15 |
124 |
12390400 |
|
|
153078296 |
surajbhanarkar08 |
B |
April 8, 2022, 5:31 p.m. |
OK |
Python 3 |
TESTS |
15 |
155 |
9216000 |
|
|
153111364 |
shovik2020 |
B |
April 9, 2022, 4:51 a.m. |
OK |
Python 3 |
TESTS |
15 |
171 |
9113600 |
|
|
153111930 |
abhijeet.panihar.cse20 |
B |
April 9, 2022, 5 a.m. |
OK |
Python 3 |
TESTS |
15 |
186 |
9932800 |
|
|
153115084 |
Pain1322 |
B |
April 9, 2022, 5:48 a.m. |
OK |
Python 3 |
TESTS |
15 |
202 |
8704000 |
|
|
153092391 |
rr745 |
B |
April 8, 2022, 8:52 p.m. |
OK |
Python 3 |
TESTS |
15 |
202 |
9011200 |
|
|
remove filters
Back to search problems