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'Ridhiman challenged Ashish to find the maximum valued subsequence of an array a of size n consisting of positive integers. The value of a non-empty subsequence of k elements of a is defined as sum 2^i over all integers i ge 0 such that at least max(1, k - 2) elements of the subsequence have the i -th bit set in their binary representation (value x has the i -th bit set in its binary representation if lfloor frac{x}{2^i} rfloor mod 2 is equal to 1 ). Recall that b is a subsequence of a , if b can be obtained by deleting some(possibly zero) elements from a . Help Ashish find the maximum value he can get by choosing some subsequence of a . The first line of the input consists of a single integer n (1 <= n <= 500) -- the size of a . The next line consists of n space-separated integers -- the elements of the array (1 <= a_i <= 10^{18}) . Print a single integer -- the maximum value Ashish can get by choosing some subsequence of a . For the first test case, Ashish can pick the subsequence {{2, 3} } of size 2 . The binary representation of 2 is 10 and that of 3 is 11. Since max(k - 2, 1) is equal to 1 , the value of the subsequence is 2^0 + 2^1 (both 2 and 3 have 1 -st bit set in their binary representation and 3 has 0 -th bit set in its binary representation). Note that he could also pick the subsequence {{3 }} or {{2, 1, 3 }} . For the second test case, Ashish can pick the subsequence {{3, 4 }} with value 7 . For the third test case, Ashish can pick the subsequence {{1 }} with value 1 . For the fourth test case, Ashish can pick the subsequence {{7, 7 }} with value 7 . '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
82898758 |
ruban |
E |
June 8, 2020, 2:12 a.m. |
OK |
FPC |
TESTS |
83 |
124 |
31948800 |
|
1900 |
83257779 |
tiger0132 |
E |
June 9, 2020, 11:19 p.m. |
OK |
GNU C11 |
TESTS |
83 |
46 |
204800 |
|
1900 |
83146248 |
akash19jain |
E |
June 8, 2020, 2:48 p.m. |
OK |
GNU C11 |
TESTS |
83 |
249 |
0 |
|
1900 |
83143672 |
JoseTomas01 |
E |
June 8, 2020, 2:20 p.m. |
OK |
GNU C11 |
TESTS |
83 |
421 |
0 |
|
1900 |
83389354 |
sonu628 |
E |
June 11, 2020, 2:32 p.m. |
OK |
GNU C++11 |
TESTS |
83 |
46 |
0 |
|
1900 |
83388205 |
RogueNinja |
E |
June 11, 2020, 2:17 p.m. |
OK |
GNU C++11 |
TESTS |
83 |
46 |
0 |
|
1900 |
83379250 |
code_struck |
E |
June 11, 2020, 12:16 p.m. |
OK |
GNU C++11 |
TESTS |
83 |
46 |
0 |
|
1900 |
83530915 |
AlbertoTDNeto |
E |
June 12, 2020, 12:39 p.m. |
OK |
GNU C++11 |
TESTS |
83 |
46 |
0 |
|
1900 |
83507489 |
AaZaDi |
E |
June 12, 2020, 7:25 a.m. |
OK |
GNU C++11 |
TESTS |
83 |
46 |
0 |
|
1900 |
83474299 |
Fuad |
E |
June 11, 2020, 6:34 p.m. |
OK |
GNU C++11 |
TESTS |
83 |
46 |
0 |
|
1900 |
83413003 |
do_while_true |
E |
June 11, 2020, 3:09 p.m. |
OK |
GNU C++11 |
TESTS |
83 |
46 |
0 |
|
1900 |
83562142 |
Tanmoy_Datta |
E |
June 12, 2020, 8:27 p.m. |
OK |
GNU C++11 |
TESTS |
83 |
46 |
0 |
|
1900 |
83561279 |
matteo.palmieri |
E |
June 12, 2020, 8:10 p.m. |
OK |
GNU C++11 |
TESTS |
83 |
46 |
0 |
|
1900 |
83539892 |
bleedcoder |
E |
June 12, 2020, 2:30 p.m. |
OK |
GNU C++11 |
TESTS |
83 |
46 |
0 |
|
1900 |
82882054 |
rohan_ardulous |
E |
June 7, 2020, 7:03 p.m. |
OK |
GNU C++14 |
TESTS |
83 |
31 |
204800 |
|
1900 |
83388889 |
goldenskygiang |
E |
June 11, 2020, 2:26 p.m. |
OK |
GNU C++14 |
TESTS |
83 |
46 |
0 |
|
1900 |
83378672 |
Lord_Saga |
E |
June 11, 2020, 12:08 p.m. |
OK |
GNU C++14 |
TESTS |
83 |
46 |
0 |
|
1900 |
83376672 |
cervotrex |
E |
June 11, 2020, 11:42 a.m. |
OK |
GNU C++14 |
TESTS |
83 |
46 |
0 |
|
1900 |
83368257 |
vjudge4 |
E |
June 11, 2020, 9:46 a.m. |
OK |
GNU C++14 |
TESTS |
83 |
46 |
0 |
|
1900 |
83367492 |
bojackhorseman550 |
E |
June 11, 2020, 9:36 a.m. |
OK |
GNU C++14 |
TESTS |
83 |
46 |
0 |
|
1900 |
83348152 |
Vesper_Lynd |
E |
June 11, 2020, 4:33 a.m. |
OK |
GNU C++14 |
TESTS |
83 |
46 |
0 |
|
1900 |
83463357 |
RHT_20 |
E |
June 11, 2020, 4:47 p.m. |
OK |
GNU C++14 |
TESTS |
83 |
46 |
0 |
|
1900 |
83568397 |
tanvirtareq |
E |
June 12, 2020, 11:55 p.m. |
OK |
GNU C++14 |
TESTS |
83 |
46 |
0 |
|
1900 |
83554723 |
_i_mean_its_mine_ |
E |
June 12, 2020, 6:24 p.m. |
OK |
GNU C++14 |
TESTS |
83 |
46 |
0 |
|
1900 |
83114927 |
Pozhiloy_Vityok |
E |
June 8, 2020, 8:29 a.m. |
OK |
GNU C++17 |
TESTS |
83 |
31 |
0 |
|
1900 |
83321892 |
bhardwajabhishek5555 |
E |
June 10, 2020, 4:55 p.m. |
OK |
GNU C++17 |
TESTS |
83 |
31 |
0 |
|
1900 |
83150201 |
NBelieve |
E |
June 8, 2020, 3:27 p.m. |
OK |
GNU C++17 |
TESTS |
83 |
31 |
0 |
|
1900 |
83149492 |
NBelieve |
E |
June 8, 2020, 3:21 p.m. |
OK |
GNU C++17 |
TESTS |
83 |
31 |
0 |
|
1900 |
83466833 |
pabloskimg |
E |
June 11, 2020, 5:12 p.m. |
OK |
GNU C++17 |
TESTS |
83 |
46 |
0 |
|
1900 |
83385700 |
ansustdi |
E |
June 11, 2020, 1:44 p.m. |
OK |
GNU C++17 |
TESTS |
83 |
46 |
0 |
|
1900 |
83341080 |
masterthai001 |
E |
June 11, 2020, 1:07 a.m. |
OK |
GNU C++17 |
TESTS |
83 |
46 |
0 |
|
1900 |
83334929 |
Andreii |
E |
June 10, 2020, 8:50 p.m. |
OK |
GNU C++17 |
TESTS |
83 |
46 |
0 |
|
1900 |
83334366 |
KLWDSF_mantra |
E |
June 10, 2020, 8:34 p.m. |
OK |
GNU C++17 |
TESTS |
83 |
46 |
0 |
|
1900 |
83332184 |
pamho108 |
E |
June 10, 2020, 7:42 p.m. |
OK |
GNU C++17 |
TESTS |
83 |
46 |
0 |
|
1900 |
82955082 |
PouyaNavid |
E |
June 8, 2020, 4:59 a.m. |
OK |
GNU C++17 (64) |
TESTS |
83 |
31 |
0 |
|
1900 |
82880413 |
TheDark_Knight |
E |
June 7, 2020, 6:47 p.m. |
OK |
GNU C++17 (64) |
TESTS |
83 |
31 |
0 |
|
1900 |
82955199 |
PouyaNavid |
E |
June 8, 2020, 5:01 a.m. |
OK |
GNU C++17 (64) |
TESTS |
83 |
31 |
0 |
|
1900 |
83117496 |
akifpatel |
E |
June 8, 2020, 9:01 a.m. |
OK |
GNU C++17 (64) |
TESTS |
83 |
31 |
0 |
|
1900 |
83138297 |
nullmn |
E |
June 8, 2020, 1:16 p.m. |
OK |
GNU C++17 (64) |
TESTS |
83 |
31 |
0 |
|
1900 |
83253145 |
Ehab_Fawzy |
E |
June 9, 2020, 8:23 p.m. |
OK |
GNU C++17 (64) |
TESTS |
83 |
46 |
0 |
|
1900 |
83249500 |
smax |
E |
June 9, 2020, 7:07 p.m. |
OK |
GNU C++17 (64) |
TESTS |
83 |
46 |
0 |
|
1900 |
83571628 |
marX |
E |
June 13, 2020, 2:23 a.m. |
OK |
GNU C++17 (64) |
TESTS |
83 |
46 |
0 |
|
1900 |
83319438 |
Bondo |
E |
June 10, 2020, 4:25 p.m. |
OK |
GNU C++17 (64) |
TESTS |
83 |
46 |
0 |
|
1900 |
83255631 |
bmu |
E |
June 9, 2020, 9:41 p.m. |
OK |
GNU C++17 (64) |
TESTS |
83 |
46 |
0 |
|
1900 |
83333877 |
magnickolas |
E |
June 10, 2020, 8:22 p.m. |
OK |
Go |
TESTS |
83 |
109 |
0 |
|
1900 |
82897747 |
synapse |
E |
June 8, 2020, 1:43 a.m. |
OK |
Go |
TESTS |
83 |
187 |
307200 |
|
1900 |
82896967 |
anhtaihsgs |
E |
June 8, 2020, 1:17 a.m. |
OK |
Java 11 |
TESTS |
83 |
218 |
0 |
|
1900 |
82896864 |
anhtaihsgs |
E |
June 8, 2020, 1:14 a.m. |
OK |
Java 11 |
TESTS |
83 |
218 |
0 |
|
1900 |
82897103 |
anhtaihsgs |
E |
June 8, 2020, 1:22 a.m. |
OK |
Java 11 |
TESTS |
83 |
233 |
0 |
|
1900 |
83156046 |
saikaushik333 |
E |
June 8, 2020, 4:33 p.m. |
OK |
Java 11 |
TESTS |
83 |
248 |
0 |
|
1900 |
83141513 |
chaparasagar |
E |
June 8, 2020, 1:56 p.m. |
OK |
Java 11 |
TESTS |
83 |
249 |
0 |
|
1900 |
83568184 |
vktennis |
E |
June 12, 2020, 11:45 p.m. |
OK |
Java 11 |
TESTS |
83 |
249 |
0 |
|
1900 |
83183922 |
abhi123valani |
E |
June 9, 2020, 4:15 a.m. |
OK |
Java 11 |
TESTS |
83 |
249 |
0 |
|
1900 |
83141950 |
noahlewis.ca |
E |
June 8, 2020, 2:01 p.m. |
OK |
Java 11 |
TESTS |
83 |
249 |
0 |
|
1900 |
83141888 |
AshrafEzz |
E |
June 8, 2020, 2 p.m. |
OK |
Java 11 |
TESTS |
83 |
249 |
0 |
|
1900 |
83107222 |
In_The_Name_Of_Love |
E |
June 8, 2020, 6:51 a.m. |
OK |
Java 11 |
TESTS |
83 |
249 |
0 |
|
1900 |
83169964 |
an09mous |
E |
June 8, 2020, 8:13 p.m. |
OK |
Java 8 |
TESTS |
83 |
155 |
0 |
|
1900 |
83155307 |
O_E |
E |
June 8, 2020, 4:24 p.m. |
OK |
Java 8 |
TESTS |
83 |
155 |
0 |
|
1900 |
83125687 |
bluesky111 |
E |
June 8, 2020, 10:42 a.m. |
OK |
Java 8 |
TESTS |
83 |
171 |
0 |
|
1900 |
82972417 |
SrapZark |
E |
June 8, 2020, 5:21 a.m. |
OK |
Java 8 |
TESTS |
83 |
171 |
0 |
|
1900 |
82892635 |
2020akadaver |
E |
June 7, 2020, 10:24 p.m. |
OK |
Java 8 |
TESTS |
83 |
171 |
0 |
|
1900 |
83201266 |
noobie_code |
E |
June 9, 2020, 8:42 a.m. |
OK |
Java 8 |
TESTS |
83 |
186 |
0 |
|
1900 |
83175619 |
Relief |
E |
June 8, 2020, 11:40 p.m. |
OK |
Java 8 |
TESTS |
83 |
186 |
0 |
|
1900 |
82891787 |
RockStar_14 |
E |
June 7, 2020, 9:55 p.m. |
OK |
Java 8 |
TESTS |
83 |
186 |
0 |
|
1900 |
83527179 |
e_coder |
E |
June 12, 2020, 11:51 a.m. |
OK |
Java 8 |
TESTS |
83 |
187 |
0 |
|
1900 |
83474669 |
The_Hidden_Man |
E |
June 11, 2020, 6:39 p.m. |
OK |
Java 8 |
TESTS |
83 |
187 |
0 |
|
1900 |
83136522 |
Spheniscine |
E |
June 8, 2020, 12:53 p.m. |
OK |
Kotlin |
TESTS |
83 |
202 |
0 |
|
1900 |
82881072 |
Hakiobo |
E |
June 7, 2020, 6:53 p.m. |
OK |
Kotlin |
TESTS |
83 |
202 |
307200 |
|
1900 |
82971987 |
koboshi |
E |
June 8, 2020, 5:14 a.m. |
OK |
Kotlin |
TESTS |
83 |
218 |
0 |
|
1900 |
83163292 |
shivam1420 |
E |
June 8, 2020, 6:13 p.m. |
OK |
Kotlin |
TESTS |
83 |
482 |
0 |
|
1900 |
82892643 |
DATVN |
E |
June 7, 2020, 10:24 p.m. |
OK |
Kotlin |
TESTS |
83 |
545 |
0 |
|
1900 |
82892745 |
DATVN |
E |
June 7, 2020, 10:29 p.m. |
OK |
Kotlin |
TESTS |
83 |
561 |
0 |
|
1900 |
83200205 |
Mosyagin |
E |
June 9, 2020, 8:29 a.m. |
OK |
Mono C# |
TESTS |
83 |
109 |
204800 |
|
1900 |
83106765 |
avtoruxadze |
E |
June 8, 2020, 6:46 a.m. |
OK |
Mono C# |
TESTS |
83 |
171 |
3788800 |
|
1900 |
83124407 |
Yupiteru |
E |
June 8, 2020, 10:27 a.m. |
OK |
Mono C# |
TESTS |
83 |
561 |
3788800 |
|
1900 |
83228148 |
olpetOdessaONU |
E |
June 9, 2020, 2:32 p.m. |
OK |
MS C++ |
TESTS |
83 |
62 |
0 |
|
1900 |
82878331 |
Volja |
E |
June 7, 2020, 6:32 p.m. |
OK |
MS C++ |
TESTS |
83 |
78 |
0 |
|
1900 |
83544994 |
MrBear |
E |
June 12, 2020, 3:29 p.m. |
OK |
MS C++ 2017 |
TESTS |
83 |
61 |
0 |
|
1900 |
83110072 |
AnnSuperstar |
E |
June 8, 2020, 7:28 a.m. |
OK |
MS C++ 2017 |
TESTS |
83 |
62 |
0 |
|
1900 |
83174420 |
JulesIMF |
E |
June 8, 2020, 10:37 p.m. |
OK |
MS C++ 2017 |
TESTS |
83 |
62 |
0 |
|
1900 |
83255612 |
Shify |
E |
June 9, 2020, 9:41 p.m. |
OK |
MS C++ 2017 |
TESTS |
83 |
62 |
0 |
|
1900 |
83349619 |
skkuinkwan1205 |
E |
June 11, 2020, 5:08 a.m. |
OK |
MS C++ 2017 |
TESTS |
83 |
62 |
0 |
|
1900 |
83370431 |
acrux |
E |
June 11, 2020, 10:15 a.m. |
OK |
MS C++ 2017 |
TESTS |
83 |
62 |
307200 |
|
1900 |
83247348 |
TMHazem |
E |
June 9, 2020, 6:33 p.m. |
OK |
MS C++ 2017 |
TESTS |
83 |
62 |
1638400 |
|
1900 |
83365638 |
Dante_Alighieri |
E |
June 11, 2020, 9:11 a.m. |
OK |
MS C++ 2017 |
TESTS |
83 |
78 |
0 |
|
1900 |
83263827 |
leeyupeng |
E |
June 10, 2020, 3:10 a.m. |
OK |
MS C++ 2017 |
TESTS |
83 |
109 |
307200 |
|
1900 |
82888271 |
ilya_totl |
E |
June 7, 2020, 8:29 p.m. |
OK |
MS C++ 2017 |
TESTS |
83 |
140 |
0 |
|
1900 |
82894533 |
pajenegod |
E |
June 7, 2020, 11:46 p.m. |
OK |
PyPy 2 |
TESTS |
83 |
233 |
1024000 |
|
1900 |
82888756 |
pratikjain226 |
E |
June 7, 2020, 8:39 p.m. |
OK |
PyPy 2 |
TESTS |
83 |
857 |
2150400 |
|
1900 |
82888320 |
realnimish |
E |
June 7, 2020, 8:31 p.m. |
OK |
PyPy 2 |
TESTS |
83 |
904 |
1433600 |
|
1900 |
82884133 |
pajenegod |
E |
June 7, 2020, 7:26 p.m. |
OK |
PyPy 2 |
TESTS |
83 |
920 |
1536000 |
|
1900 |
82894710 |
pajenegod |
E |
June 7, 2020, 11:53 p.m. |
OK |
PyPy 2 |
TESTS |
83 |
1122 |
819200 |
|
1900 |
83112835 |
snape_here |
E |
June 8, 2020, 8:04 a.m. |
OK |
PyPy 2 |
TESTS |
83 |
1481 |
1433600 |
|
1900 |
82893976 |
pajenegod |
E |
June 7, 2020, 11:21 p.m. |
OK |
PyPy 2 |
TESTS |
83 |
1497 |
2150400 |
|
1900 |
83088342 |
satyamcse |
E |
June 8, 2020, 6:16 a.m. |
OK |
PyPy 2 |
TESTS |
83 |
1528 |
2867200 |
|
1900 |
83107421 |
pratikjain226 |
E |
June 8, 2020, 6:53 a.m. |
OK |
PyPy 3 |
TESTS |
83 |
842 |
2867200 |
|
1900 |
83144050 |
aberent |
E |
June 8, 2020, 2:25 p.m. |
OK |
PyPy 3 |
TESTS |
83 |
873 |
2969600 |
|
1900 |
82890289 |
KhozmoS |
E |
June 7, 2020, 9:14 p.m. |
OK |
PyPy 3 |
TESTS |
83 |
1434 |
2662400 |
|
1900 |
83122738 |
chris-md |
E |
June 8, 2020, 10:06 a.m. |
OK |
PyPy 3 |
TESTS |
83 |
1435 |
2560000 |
|
1900 |
82892878 |
gintoki_s |
E |
June 7, 2020, 10:34 p.m. |
OK |
PyPy 3 |
TESTS |
83 |
1435 |
2867200 |
|
1900 |
82892914 |
gintoki_s |
E |
June 7, 2020, 10:35 p.m. |
OK |
PyPy 3 |
TESTS |
83 |
1450 |
2355200 |
|
1900 |
82902159 |
Shee11 |
E |
June 8, 2020, 3:28 a.m. |
OK |
PyPy 3 |
TESTS |
83 |
1450 |
2457600 |
|
1900 |
83142619 |
willtryagain |
E |
June 8, 2020, 2:09 p.m. |
OK |
PyPy 3 |
TESTS |
83 |
1450 |
2969600 |
|
1900 |
82888668 |
jscn |
E |
June 7, 2020, 8:38 p.m. |
OK |
PyPy 3 |
TESTS |
83 |
1450 |
2969600 |
|
1900 |
83144399 |
glucose |
E |
June 8, 2020, 2:29 p.m. |
OK |
PyPy 3 |
TESTS |
83 |
1465 |
2969600 |
|
1900 |
83377636 |
cotton100pc |
E |
June 11, 2020, 11:55 a.m. |
OK |
Rust |
TESTS |
83 |
77 |
204800 |
|
1900 |
83175134 |
kobae964 |
E |
June 8, 2020, 11:14 p.m. |
OK |
Rust |
TESTS |
83 |
78 |
307200 |
|
1900 |
83489710 |
Andrey_R |
E |
June 12, 2020, 1:44 a.m. |
OK |
Rust |
TESTS |
83 |
358 |
0 |
|
1900 |
83173755 |
IvanDyachenko |
E |
June 8, 2020, 10:05 p.m. |
OK |
Scala |
TESTS |
83 |
1387 |
0 |
|
1900 |
remove filters
Back to search problems