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 n numbers a_1, a_2, ... , a_n . In one operation we can add to any one of those numbers a nonnegative integer power of 2 . What is the smallest number of operations we need to perform to make all n numbers equal? It can be proved that under given constraints it doesn't exceed 10^{18} . The first line contains a single integer n ( 1 <= n <= 10^5 ). The second line contains n integers a_1, a_2, ldots, a_n ( 0 <= a_i <= 10^{17} ). Output exactly one integer -- the smallest number of operations we need to perform to make all n numbers equal. In the first example, all numbers are already equal. So the needed number of operation is 0 . In the second example, we can apply the operation 3 times: add 8 to first 2 , add 8 to second 2 , add 2 to 8 , making all numbers equal to 10 . It can be proved that we can't make all numbers equal in less than 3 operations. "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
56789073 |
lzoilxy |
D |
July 10, 2019, 9:44 a.m. |
OK |
GNU C++11 |
TESTS |
36 |
93 |
28262400 |
|
3000 |
56602284 |
mmmod_lqs |
D |
July 6, 2019, 1:45 a.m. |
OK |
GNU C++11 |
TESTS |
36 |
108 |
2457600 |
|
3000 |
61549128 |
vjudge1 |
D |
Sept. 30, 2019, 11:46 a.m. |
OK |
GNU C++11 |
TESTS |
36 |
109 |
5222400 |
|
3000 |
56868526 |
frodakcin |
D |
July 12, 2019, 5:04 a.m. |
OK |
GNU C++11 |
TESTS |
36 |
109 |
5836800 |
|
3000 |
58859724 |
YanHan22 |
D |
Aug. 15, 2019, 11:06 a.m. |
OK |
GNU C++11 |
TESTS |
36 |
124 |
2457600 |
|
3000 |
58826448 |
YanHan22 |
D |
Aug. 14, 2019, 4:04 p.m. |
OK |
GNU C++11 |
TESTS |
36 |
124 |
2457600 |
|
3000 |
56745518 |
yyf0309 |
D |
July 9, 2019, 9:31 a.m. |
OK |
GNU C++11 |
TESTS |
36 |
124 |
3174400 |
|
3000 |
60335208 |
ezhjw |
D |
Sept. 10, 2019, 8:11 a.m. |
OK |
GNU C++11 |
TESTS |
36 |
124 |
27648000 |
|
3000 |
58859795 |
YanHan22 |
D |
Aug. 15, 2019, 11:08 a.m. |
OK |
GNU C++11 |
TESTS |
36 |
139 |
2457600 |
|
3000 |
58826072 |
YanHan22 |
D |
Aug. 14, 2019, 3:55 p.m. |
OK |
GNU C++11 |
TESTS |
36 |
139 |
2457600 |
|
3000 |
56729294 |
Motarack |
D |
July 8, 2019, 11:06 p.m. |
OK |
GNU C++14 |
TESTS |
36 |
109 |
26419200 |
|
3000 |
62934032 |
MiricaMatei |
D |
Oct. 19, 2019, 1:33 p.m. |
OK |
GNU C++14 |
TESTS |
36 |
109 |
26828800 |
|
3000 |
56601731 |
art637 |
D |
July 6, 2019, 1:13 a.m. |
OK |
GNU C++14 |
TESTS |
36 |
124 |
3174400 |
|
3000 |
61549363 |
imAnik |
D |
Sept. 30, 2019, 11:51 a.m. |
OK |
GNU C++14 |
TESTS |
36 |
124 |
5222400 |
|
3000 |
56701482 |
lanpang |
D |
July 8, 2019, 9:16 a.m. |
OK |
GNU C++14 |
TESTS |
36 |
139 |
2457600 |
|
3000 |
61549326 |
imAnik |
D |
Sept. 30, 2019, 11:50 a.m. |
OK |
GNU C++14 |
TESTS |
36 |
139 |
5222400 |
|
3000 |
61549203 |
imAnik |
D |
Sept. 30, 2019, 11:49 a.m. |
OK |
GNU C++14 |
TESTS |
36 |
139 |
5222400 |
|
3000 |
58244231 |
daniel14311531 |
D |
Aug. 4, 2019, 4:11 a.m. |
OK |
GNU C++14 |
TESTS |
36 |
156 |
26112000 |
|
3000 |
56986097 |
tick |
D |
July 13, 2019, 3:53 p.m. |
OK |
GNU C++14 |
TESTS |
36 |
171 |
29286400 |
|
3000 |
59970778 |
mayaohua2003 |
D |
Sept. 4, 2019, 12:53 a.m. |
OK |
GNU C++14 |
TESTS |
36 |
186 |
7270400 |
|
3000 |
56600186 |
neal |
D |
July 5, 2019, 11 p.m. |
OK |
GNU C++17 |
TESTS |
36 |
93 |
3276800 |
|
3000 |
56600144 |
neal |
D |
July 5, 2019, 10:56 p.m. |
OK |
GNU C++17 |
TESTS |
36 |
109 |
3276800 |
|
3000 |
56816109 |
bmerry |
D |
July 10, 2019, 7:16 p.m. |
OK |
GNU C++17 |
TESTS |
36 |
124 |
2457600 |
|
3000 |
56600135 |
neal |
D |
July 5, 2019, 10:55 p.m. |
OK |
GNU C++17 |
TESTS |
36 |
124 |
3174400 |
|
3000 |
56600132 |
neal |
D |
July 5, 2019, 10:55 p.m. |
OK |
GNU C++17 |
TESTS |
36 |
124 |
3174400 |
|
3000 |
56600095 |
neal |
D |
July 5, 2019, 10:52 p.m. |
OK |
GNU C++17 |
TESTS |
36 |
124 |
3174400 |
|
3000 |
58150590 |
RNS_CUS |
D |
Aug. 2, 2019, 2:17 a.m. |
OK |
GNU C++17 |
TESTS |
36 |
155 |
2457600 |
|
3000 |
58150905 |
CMXRYNP |
D |
Aug. 2, 2019, 2:30 a.m. |
OK |
GNU C++17 |
TESTS |
36 |
171 |
25702400 |
|
3000 |
56681886 |
dantita |
D |
July 7, 2019, 7:01 p.m. |
OK |
GNU C++17 |
TESTS |
36 |
171 |
28262400 |
|
3000 |
56621153 |
Shayan.P |
D |
July 6, 2019, 11:59 a.m. |
OK |
GNU C++17 |
TESTS |
36 |
186 |
8601600 |
|
3000 |
59636339 |
qwerty787788 |
D |
Aug. 28, 2019, 8:56 p.m. |
OK |
Java 8 |
TESTS |
36 |
764 |
3072000 |
|
3000 |
58323474 |
vjudge1 |
D |
Aug. 5, 2019, 6:51 a.m. |
OK |
MS C++ |
TESTS |
36 |
264 |
59289600 |
|
3000 |
remove filters
Back to search problems