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"Suppose you are stuck on a desert island. The only way to save yourself is to craft a wooden raft and go to the sea. Fortunately, you have a hand-made saw and a forest nearby. Moreover, you've already cut several trees and prepared it to the point that now you have n logs and the i -th log has length a_i . The wooden raft you'd like to build has the following structure: 2 logs of length x and x logs of length y . Such raft would have the area equal to x cdot y . Both x and y must be integers since it's the only way you can measure the lengths while being on a desert island. And both x and y must be at least 2 since the raft that is one log wide is unstable. You can cut logs in pieces but you can't merge two logs in one. What is the maximum area of the raft you can craft? The first line contains the only integer n ( 1 <= n <= 5 cdot 10^5 ) -- the number of logs you have. The second line contains n integers a_1, a_2, ... , a_n ( 2 <= a_i <= 5 cdot 10^5 ) -- the corresponding lengths of the logs. It's guaranteed that you can always craft at least 2 x 2 raft. Print the only integer -- the maximum area of the raft you can craft. In the first example, you can cut the log of the length 9 in 5 parts: 2 + 2 + 2 + 2 + 1 . Now you can build 2 x 2 raft using 2 logs of length x = 2 and x = 2 logs of length y = 2 . In the second example, you can cut a_4 = 18 into two pieces 9 + 9 and a_8 = 28 in three pieces 10 + 9 + 9 . Now you can make 10 x 9 raft using 2 logs of length 10 and 10 logs of length 9 . "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
62055303 |
kdh |
G |
Oct. 7, 2019, 11:51 a.m. |
OK |
GNU C++11 |
TESTS |
42 |
389 |
3993600 |
|
3100 |
62056580 |
kdh |
G |
Oct. 7, 2019, 12:17 p.m. |
OK |
GNU C++11 |
TESTS |
42 |
405 |
3993600 |
|
3100 |
62056947 |
logicroc |
G |
Oct. 7, 2019, 12:24 p.m. |
OK |
GNU C++11 |
TESTS |
42 |
405 |
15155200 |
|
3100 |
62096294 |
BeNoble |
G |
Oct. 8, 2019, 7:38 a.m. |
OK |
GNU C++11 |
TESTS |
42 |
499 |
6144000 |
|
3100 |
64202563 |
lukelin |
G |
Nov. 4, 2019, 11:54 a.m. |
OK |
GNU C++11 |
TESTS |
42 |
514 |
17817600 |
|
3100 |
64265460 |
ljc2002 |
G |
Nov. 4, 2019, 5:18 p.m. |
OK |
GNU C++11 |
TESTS |
42 |
732 |
12083200 |
|
3100 |
65277141 |
lzoiexplorer2004 |
G |
Nov. 18, 2019, 2:27 a.m. |
OK |
GNU C++11 |
TESTS |
42 |
811 |
16076800 |
|
3100 |
64276462 |
birka0 |
G |
Nov. 4, 2019, 9:47 p.m. |
OK |
GNU C++11 |
TESTS |
42 |
920 |
6041600 |
|
3100 |
66031883 |
bqq |
G |
Nov. 30, 2019, 10:26 a.m. |
OK |
GNU C++11 |
TESTS |
42 |
1231 |
6041600 |
|
3100 |
62177278 |
sharpener |
G |
Oct. 9, 2019, 4:49 a.m. |
OK |
GNU C++11 |
TESTS |
42 |
1419 |
5017600 |
|
3100 |
67626517 |
Benq |
G |
Dec. 25, 2019, 10:21 p.m. |
OK |
GNU C++14 |
TESTS |
42 |
389 |
6041600 |
|
3100 |
63368610 |
ljk123 |
G |
Oct. 25, 2019, 8:30 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
607 |
6041600 |
|
3100 |
62246096 |
I_love_chickpea |
G |
Oct. 10, 2019, 6:10 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
655 |
6041600 |
|
3100 |
66672735 |
sruthi_1729 |
G |
Dec. 12, 2019, 10:03 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
904 |
16076800 |
|
3100 |
64189506 |
hjc20032003 |
G |
Nov. 4, 2019, 7:03 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
1138 |
16076800 |
|
3100 |
62862377 |
hjc20032003 |
G |
Oct. 18, 2019, 11:12 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
1170 |
11980800 |
|
3100 |
66707533 |
upobir |
G |
Dec. 12, 2019, 2:44 p.m. |
OK |
GNU C++14 |
TESTS |
42 |
1575 |
40140800 |
|
3100 |
66707222 |
upobir |
G |
Dec. 12, 2019, 2:43 p.m. |
OK |
GNU C++14 |
TESTS |
42 |
1746 |
40140800 |
|
3100 |
66707759 |
upobir |
G |
Dec. 12, 2019, 2:45 p.m. |
OK |
GNU C++14 |
TESTS |
42 |
1793 |
40140800 |
|
3100 |
62384422 |
Shayan.P |
G |
Oct. 11, 2019, 8:33 p.m. |
OK |
GNU C++17 |
TESTS |
42 |
265 |
2048000 |
|
3100 |
62025192 |
Joggor |
G |
Oct. 6, 2019, 7:51 p.m. |
OK |
GNU C++17 |
TESTS |
42 |
296 |
3993600 |
|
3100 |
62021932 |
300iq |
G |
Oct. 6, 2019, 4:52 p.m. |
OK |
GNU C++17 |
TESTS |
42 |
311 |
15257600 |
|
3100 |
63370512 |
gongsuidashen |
G |
Oct. 25, 2019, 9:11 a.m. |
OK |
GNU C++17 |
TESTS |
42 |
405 |
6144000 |
|
3100 |
63779881 |
jah_melon |
G |
Oct. 30, 2019, 10:42 a.m. |
OK |
GNU C++17 |
TESTS |
42 |
421 |
6041600 |
|
3100 |
62062828 |
Super_M. |
G |
Oct. 7, 2019, 2:12 p.m. |
OK |
GNU C++17 |
TESTS |
42 |
436 |
6041600 |
|
3100 |
62573460 |
ak_taniya |
G |
Oct. 14, 2019, 3:11 p.m. |
OK |
GNU C++17 |
TESTS |
42 |
499 |
6041600 |
|
3100 |
63766124 |
__JuRuo |
G |
Oct. 30, 2019, 6:16 a.m. |
OK |
GNU C++17 |
TESTS |
42 |
561 |
6348800 |
|
3100 |
62909225 |
qq166736763 |
G |
Oct. 19, 2019, 6:48 a.m. |
OK |
GNU C++17 |
TESTS |
42 |
623 |
7987200 |
|
3100 |
62085665 |
jiangly |
G |
Oct. 8, 2019, 1:33 a.m. |
OK |
GNU C++17 |
TESTS |
42 |
654 |
18227200 |
|
3100 |
remove filters
Back to search problems