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 want to advertise your new business, so you are going to place two posters on a billboard in the city center. The billboard consists of n vertical panels of width 1 and varying integer heights, held together by a horizontal bar. The i -th of the n panels has height h_i . Initially, all panels hang down from the bar (their top edges lie on it), but before placing the two posters, you are allowed to move each panel up by any integer length, as long as it is still connected to the bar (its bottom edge lies below or on it). After the moves are done, you will place two posters: one below the bar and one above it. They are not allowed to go over the bar and they must be positioned completely inside of the panels. What is the maximum total area the two posters can cover together if you make the optimal moves? Note that you can also place a poster of 0 area. This case is equivalent to placing a single poster. The first line of input contains one integer n ( 1 <= n <= 10^4 ) -- the number of vertical panels. The second line of input contains n integers h_1, h_2, ..., h_n ( 1 <= h_i <= 10^{12} ) -- the heights of the n vertical panels. Print a single integer -- the maximum total area the two posters can cover together. In the first sample test, we can choose an upper poster with area 12 and a lower poster of area 6 as in the image below. In the second sample test, we can cover the whole billboard using a single poster. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
146450639 |
rainboy |
F |
Feb. 14, 2022, 8:02 p.m. |
OK |
GNU C11 |
TESTS |
224 |
1668 |
307200 |
|
|
146468359 |
Vsinger_YuezhengLing |
F |
Feb. 15, 2022, 3:29 a.m. |
OK |
GNU C++14 |
TESTS |
224 |
1591 |
409600 |
|
|
146470617 |
kuldeep_kumar_ism |
F |
Feb. 15, 2022, 4:03 a.m. |
OK |
GNU C++17 |
TESTS |
224 |
1341 |
1126400 |
|
|
146451114 |
fastmath |
F |
Feb. 14, 2022, 8:09 p.m. |
OK |
GNU C++17 (64) |
TESTS |
224 |
826 |
819200 |
|
|
146474907 |
aonbel_noob2 |
F |
Feb. 15, 2022, 5:05 a.m. |
OK |
GNU C++17 (64) |
TESTS |
224 |
982 |
409600 |
|
|
146426528 |
Ormlis |
F |
Feb. 14, 2022, 4:31 p.m. |
OK |
GNU C++20 (64) |
TESTS |
224 |
15 |
307200 |
|
|
146474650 |
Alan233 |
F |
Feb. 15, 2022, 5:01 a.m. |
OK |
GNU C++20 (64) |
TESTS |
224 |
312 |
512000 |
|
|
146466320 |
maximeromeoassogba03 |
F |
Feb. 15, 2022, 2:51 a.m. |
OK |
GNU C++20 (64) |
TESTS |
224 |
904 |
1126400 |
|
|
146474726 |
taa1 |
F |
Feb. 15, 2022, 5:02 a.m. |
OK |
GNU C++20 (64) |
TESTS |
224 |
998 |
409600 |
|
|
146460141 |
chunjiangchaoshui |
F |
Feb. 15, 2022, 12:11 a.m. |
OK |
GNU C++20 (64) |
TESTS |
224 |
998 |
409600 |
|
|
146472098 |
askd |
F |
Feb. 15, 2022, 4:25 a.m. |
OK |
GNU C++20 (64) |
TESTS |
224 |
1107 |
716800 |
|
|
146445384 |
maspy |
F |
Feb. 14, 2022, 7:11 p.m. |
OK |
GNU C++20 (64) |
TESTS |
224 |
1528 |
806809600 |
|
|
146458322 |
oleh1421 |
F |
Feb. 14, 2022, 10:47 p.m. |
OK |
GNU C++20 (64) |
TESTS |
224 |
1715 |
1536000 |
|
|
remove filters
Back to search problems