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 a game designer and want to make an obstacle course. The player will walk from left to right. You have n heights of mountains already selected and want to arrange them so that the absolute difference of the heights of the first and last mountains is as small as possible. In addition, you want to make the game difficult, and since walking uphill or flat is harder than walking downhill, the difficulty of the level will be the number of mountains i ( 1 <= q i < n ) such that h_i <= q h_{i+1} where h_i is the height of the i -th mountain. You don't want to waste any of the mountains you modelled, so you have to use all of them. From all the arrangements that minimize |h_1-h_n| , find one that is the most difficult. If there are multiple orders that satisfy these requirements, you may find any. The first line will contain a single integer t ( 1 <= q t <= q 100 ) -- the number of test cases. Then t test cases follow. The first line of each test case contains a single integer n ( 2 <= q n <= q 2 cdot 10^5 ) -- the number of mountains. The second line of each test case contains n integers h_1, ldots,h_n ( 1 <= q h_i <= q 10^9 ), where h_i is the height of the i -th mountain. It is guaranteed that the sum of n over all test cases does not exceed 2 cdot 10^5 . For each test case, output n integers -- the given heights in an order that maximizes the difficulty score among all orders that minimize |h_1-h_n| . If there are multiple orders that satisfy these requirements, you may output any. In the first test case: The player begins at height 2 , next going up to height 4 increasing the difficulty by 1 . After that he will go down to height 1 and the difficulty doesn't change because he is going downhill. Finally the player will go up to height 2 and the difficulty will increase by 1 . The absolute difference be"... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
119918689 |
ruban |
C |
June 18, 2021, 6:43 p.m. |
OK |
Delphi |
TESTS |
59 |
311 |
84070400 |
|
|
119941715 |
royo_sea |
C |
June 19, 2021, 3:28 a.m. |
OK |
FPC |
TESTS |
59 |
639 |
819200 |
|
|
119946373 |
patil98varad |
C |
June 19, 2021, 4:36 a.m. |
OK |
GNU C11 |
TESTS |
59 |
841 |
819200 |
|
|
119929610 |
Lunessel |
C |
June 18, 2021, 9:22 p.m. |
OK |
GNU C11 |
TESTS |
59 |
873 |
819200 |
|
|
119940498 |
Twilight_Dark |
C |
June 19, 2021, 3:08 a.m. |
OK |
GNU C++11 |
TESTS |
59 |
78 |
819200 |
|
|
119936193 |
luogu_bot5 |
C |
June 19, 2021, 1:43 a.m. |
OK |
GNU C++11 |
TESTS |
59 |
93 |
614400 |
|
|
119934455 |
priority |
C |
June 19, 2021, 12:55 a.m. |
OK |
GNU C++11 |
TESTS |
59 |
93 |
819200 |
|
|
119944986 |
CN__james1 |
C |
June 19, 2021, 4:18 a.m. |
OK |
GNU C++11 |
TESTS |
59 |
93 |
819200 |
|
|
119936643 |
explorerxx |
C |
June 19, 2021, 1:55 a.m. |
OK |
GNU C++11 |
TESTS |
59 |
93 |
819200 |
|
|
119933926 |
Aestas16 |
C |
June 19, 2021, 12:34 a.m. |
OK |
GNU C++11 |
TESTS |
59 |
93 |
1638400 |
|
|
119953975 |
lichenxi_small |
C |
June 19, 2021, 5:57 a.m. |
OK |
GNU C++11 |
TESTS |
59 |
93 |
5222400 |
|
|
119934748 |
Helinshan |
C |
June 19, 2021, 1:04 a.m. |
OK |
GNU C++11 |
TESTS |
59 |
109 |
614400 |
|
|
119934371 |
One_Zzz |
C |
June 19, 2021, 12:52 a.m. |
OK |
GNU C++11 |
TESTS |
59 |
109 |
614400 |
|
|
119954132 |
BILL666 |
C |
June 19, 2021, 5:58 a.m. |
OK |
GNU C++11 |
TESTS |
59 |
109 |
819200 |
|
|
119951333 |
p.ferrari |
C |
June 19, 2021, 5:31 a.m. |
OK |
GNU C++14 |
TESTS |
59 |
124 |
819200 |
|
|
119950831 |
abhay_lavania |
C |
June 19, 2021, 5:25 a.m. |
OK |
GNU C++14 |
TESTS |
59 |
124 |
819200 |
|
|
119950696 |
fullcomding |
C |
June 19, 2021, 5:24 a.m. |
OK |
GNU C++14 |
TESTS |
59 |
124 |
819200 |
|
|
119949787 |
agree2526 |
C |
June 19, 2021, 5:15 a.m. |
OK |
GNU C++14 |
TESTS |
59 |
124 |
819200 |
|
|
119947126 |
abhupops |
C |
June 19, 2021, 4:45 a.m. |
OK |
GNU C++14 |
TESTS |
59 |
124 |
819200 |
|
|
119952873 |
nikS_2001 |
C |
June 19, 2021, 5:47 a.m. |
OK |
GNU C++14 |
TESTS |
59 |
124 |
819200 |
|
|
119946680 |
J_san |
C |
June 19, 2021, 4:40 a.m. |
OK |
GNU C++14 |
TESTS |
59 |
124 |
819200 |
|
|
119946678 |
himanshu_goldy |
C |
June 19, 2021, 4:40 a.m. |
OK |
GNU C++14 |
TESTS |
59 |
124 |
819200 |
|
|
119953910 |
Tongxin |
C |
June 19, 2021, 5:56 a.m. |
OK |
GNU C++14 |
TESTS |
59 |
124 |
819200 |
|
|
119946930 |
hacxter |
C |
June 19, 2021, 4:43 a.m. |
OK |
GNU C++14 |
TESTS |
59 |
124 |
819200 |
|
|
119953451 |
_andyli |
C |
June 19, 2021, 5:52 a.m. |
OK |
GNU C++17 |
TESTS |
59 |
62 |
5017600 |
|
|
119936498 |
ED_is_best |
C |
June 19, 2021, 1:51 a.m. |
OK |
GNU C++17 |
TESTS |
59 |
109 |
819200 |
|
|
119942361 |
abhinav4279 |
C |
June 19, 2021, 3:38 a.m. |
OK |
GNU C++17 |
TESTS |
59 |
109 |
819200 |
|
|
119933595 |
gustavo_m32 |
C |
June 19, 2021, 12:20 a.m. |
OK |
GNU C++17 |
TESTS |
59 |
109 |
1740800 |
|
|
119951500 |
shencheng_ |
C |
June 19, 2021, 5:33 a.m. |
OK |
GNU C++17 |
TESTS |
59 |
109 |
1740800 |
|
|
119927410 |
Furiousbug_1602 |
C |
June 18, 2021, 8:32 p.m. |
OK |
GNU C++17 |
TESTS |
59 |
109 |
2457600 |
|
|
119920760 |
itsrohit |
C |
June 18, 2021, 7:03 p.m. |
OK |
GNU C++17 |
TESTS |
59 |
109 |
2457600 |
|
|
119945778 |
foreverSeven |
C |
June 19, 2021, 4:28 a.m. |
OK |
GNU C++17 |
TESTS |
59 |
109 |
3993600 |
|
|
119953155 |
vaibhavdalmia |
C |
June 19, 2021, 5:49 a.m. |
OK |
GNU C++17 |
TESTS |
59 |
124 |
819200 |
|
|
119953479 |
Kara_Shaman_Togai |
C |
June 19, 2021, 5:52 a.m. |
OK |
GNU C++17 |
TESTS |
59 |
124 |
819200 |
|
|
119940750 |
DargonFire |
C |
June 19, 2021, 3:12 a.m. |
OK |
GNU C++17 (64) |
TESTS |
59 |
93 |
819200 |
|
|
119936202 |
yzang |
C |
June 19, 2021, 1:43 a.m. |
OK |
GNU C++17 (64) |
TESTS |
59 |
93 |
819200 |
|
|
119933448 |
Snuc |
C |
June 19, 2021, 12:13 a.m. |
OK |
GNU C++17 (64) |
TESTS |
59 |
93 |
819200 |
|
|
119943211 |
simply_hooman |
C |
June 19, 2021, 3:51 a.m. |
OK |
GNU C++17 (64) |
TESTS |
59 |
93 |
819200 |
|
|
119952727 |
Mac_prime |
C |
June 19, 2021, 5:45 a.m. |
OK |
GNU C++17 (64) |
TESTS |
59 |
93 |
819200 |
|
|
119950039 |
pst10 |
C |
June 19, 2021, 5:17 a.m. |
OK |
GNU C++17 (64) |
TESTS |
59 |
93 |
819200 |
|
|
119948543 |
Codinator |
C |
June 19, 2021, 5:02 a.m. |
OK |
GNU C++17 (64) |
TESTS |
59 |
93 |
819200 |
|
|
119948422 |
Time_JYF |
C |
June 19, 2021, 5 a.m. |
OK |
GNU C++17 (64) |
TESTS |
59 |
93 |
819200 |
|
|
119948130 |
shashankagrawal |
C |
June 19, 2021, 4:57 a.m. |
OK |
GNU C++17 (64) |
TESTS |
59 |
93 |
819200 |
|
|
119942070 |
ravi_sins |
C |
June 19, 2021, 3:33 a.m. |
OK |
GNU C++17 (64) |
TESTS |
59 |
93 |
819200 |
|
|
119949426 |
tranquyetthang281 |
C |
June 19, 2021, 5:11 a.m. |
OK |
Haskell |
TESTS |
59 |
1029 |
56832000 |
|
|
119948656 |
tranquyetthang281 |
C |
June 19, 2021, 5:03 a.m. |
OK |
Haskell |
TESTS |
59 |
1107 |
56832000 |
|
|
119917807 |
tony_heart |
C |
June 18, 2021, 6:35 p.m. |
OK |
Java 11 |
TESTS |
59 |
311 |
307200 |
|
|
119922783 |
rachitagrawal1011 |
C |
June 18, 2021, 7:21 p.m. |
OK |
Java 11 |
TESTS |
59 |
311 |
2150400 |
|
|
119948410 |
Pradyumn.Agrawal |
C |
June 19, 2021, 5 a.m. |
OK |
Java 11 |
TESTS |
59 |
312 |
409600 |
|
|
119926330 |
contra_007 |
C |
June 18, 2021, 8:13 p.m. |
OK |
Java 11 |
TESTS |
59 |
327 |
307200 |
|
|
119917488 |
Swapniltri |
C |
June 18, 2021, 6:33 p.m. |
OK |
Java 11 |
TESTS |
59 |
343 |
2457600 |
|
|
119948488 |
algothink |
C |
June 19, 2021, 5:01 a.m. |
OK |
Java 11 |
TESTS |
59 |
358 |
2252800 |
|
|
119922151 |
Subhu_999 |
C |
June 18, 2021, 7:15 p.m. |
OK |
Java 11 |
TESTS |
59 |
373 |
3276800 |
|
|
119930881 |
Plums |
C |
June 18, 2021, 10:02 p.m. |
OK |
Java 11 |
TESTS |
59 |
374 |
6041600 |
|
|
119918477 |
siva03 |
C |
June 18, 2021, 6:40 p.m. |
OK |
Java 11 |
TESTS |
59 |
374 |
17408000 |
|
|
119935618 |
himanshu_0624 |
C |
June 19, 2021, 1:29 a.m. |
OK |
Java 11 |
TESTS |
59 |
389 |
19660800 |
|
|
119948306 |
abhi_718 |
C |
June 19, 2021, 4:59 a.m. |
OK |
Java 8 |
TESTS |
59 |
218 |
9523200 |
|
|
119946097 |
harsh_it |
C |
June 19, 2021, 4:32 a.m. |
OK |
Java 8 |
TESTS |
59 |
233 |
4505600 |
|
|
119921399 |
BruteForcee |
C |
June 18, 2021, 7:08 p.m. |
OK |
Java 8 |
TESTS |
59 |
233 |
4505600 |
|
|
119921271 |
zxxhh |
C |
June 18, 2021, 7:07 p.m. |
OK |
Java 8 |
TESTS |
59 |
233 |
4505600 |
|
|
119919079 |
Hasib_Ullah |
C |
June 18, 2021, 6:47 p.m. |
OK |
Java 8 |
TESTS |
59 |
233 |
4505600 |
|
|
119940482 |
ashuman231 |
C |
June 19, 2021, 3:08 a.m. |
OK |
Java 8 |
TESTS |
59 |
233 |
8704000 |
|
|
119918242 |
RonWonWon |
C |
June 18, 2021, 6:38 p.m. |
OK |
Java 8 |
TESTS |
59 |
248 |
4608000 |
|
|
119920371 |
InANutshell |
C |
June 18, 2021, 7 p.m. |
OK |
Java 8 |
TESTS |
59 |
249 |
4505600 |
|
|
119921466 |
pgthebigshot |
C |
June 18, 2021, 7:09 p.m. |
OK |
Java 8 |
TESTS |
59 |
264 |
0 |
|
|
119951072 |
trappy00_28 |
C |
June 19, 2021, 5:28 a.m. |
OK |
Java 8 |
TESTS |
59 |
264 |
8294400 |
|
|
119926913 |
e.ramos |
C |
June 18, 2021, 8:23 p.m. |
OK |
Mono C# |
TESTS |
59 |
764 |
26521600 |
|
|
119938739 |
VarunUtsav |
C |
June 19, 2021, 2:38 a.m. |
OK |
MS C++ |
TESTS |
59 |
312 |
1638400 |
|
|
119954065 |
khan_saifkhan_ |
C |
June 19, 2021, 5:58 a.m. |
OK |
MS C++ 2017 |
TESTS |
59 |
342 |
819200 |
|
|
119931985 |
gleb.zuev04 |
C |
June 18, 2021, 10:48 p.m. |
OK |
MS C++ 2017 |
TESTS |
59 |
342 |
819200 |
|
|
119943624 |
ZeroBlast |
C |
June 19, 2021, 3:58 a.m. |
OK |
MS C++ 2017 |
TESTS |
59 |
343 |
819200 |
|
|
119920546 |
Vitazzz |
C |
June 18, 2021, 7:01 p.m. |
OK |
MS C++ 2017 |
TESTS |
59 |
343 |
819200 |
|
|
119942459 |
mnrmustafa |
C |
June 19, 2021, 3:39 a.m. |
OK |
MS C++ 2017 |
TESTS |
59 |
343 |
1638400 |
|
|
119933673 |
_Rimjhim_36 |
C |
June 19, 2021, 12:24 a.m. |
OK |
MS C++ 2017 |
TESTS |
59 |
358 |
819200 |
|
|
119918845 |
incuiio |
C |
June 18, 2021, 6:44 p.m. |
OK |
MS C++ 2017 |
TESTS |
59 |
358 |
819200 |
|
|
119934023 |
acorn11 |
C |
June 19, 2021, 12:38 a.m. |
OK |
PyPy 2 |
TESTS |
59 |
171 |
19046400 |
|
|
119918380 |
dufresne_1949 |
C |
June 18, 2021, 6:39 p.m. |
OK |
PyPy 3 |
TESTS |
59 |
264 |
22630400 |
|
|
119935303 |
songtae |
C |
June 19, 2021, 1:20 a.m. |
OK |
PyPy 3 |
TESTS |
59 |
280 |
22323200 |
|
|
119933372 |
jano31415 |
C |
June 19, 2021, 12:08 a.m. |
OK |
PyPy 3 |
TESTS |
59 |
342 |
23756800 |
|
|
119930706 |
caow |
C |
June 18, 2021, 9:55 p.m. |
OK |
PyPy 3 |
TESTS |
59 |
374 |
25907200 |
|
|
119944302 |
___Neo___ |
C |
June 19, 2021, 4:08 a.m. |
OK |
PyPy 3 |
TESTS |
59 |
405 |
22630400 |
|
|
119928694 |
HETRAKESHFADIA |
C |
June 18, 2021, 8:58 p.m. |
OK |
PyPy 3 |
TESTS |
59 |
405 |
22732800 |
|
|
119928798 |
HETRAKESHFADIA |
C |
June 18, 2021, 9:01 p.m. |
OK |
PyPy 3 |
TESTS |
59 |
421 |
23040000 |
|
|
119951239 |
JustJie |
C |
June 19, 2021, 5:30 a.m. |
OK |
PyPy 3 |
TESTS |
59 |
452 |
19046400 |
|
|
119945273 |
apnikmkjain |
C |
June 19, 2021, 4:22 a.m. |
OK |
PyPy 3 |
TESTS |
59 |
467 |
22016000 |
|
|
119935933 |
h8191 |
C |
June 19, 2021, 1:37 a.m. |
OK |
PyPy 3 |
TESTS |
59 |
467 |
24576000 |
|
|
119940186 |
abcRohit |
C |
June 19, 2021, 3:04 a.m. |
OK |
Python 3 |
TESTS |
59 |
374 |
17408000 |
|
|
119951452 |
hellohowareyou |
C |
June 19, 2021, 5:33 a.m. |
OK |
Python 3 |
TESTS |
59 |
374 |
19865600 |
|
|
119928459 |
asd-code123 |
C |
June 18, 2021, 8:54 p.m. |
OK |
Python 3 |
TESTS |
59 |
436 |
18739200 |
|
|
119924078 |
charanjeet678 |
C |
June 18, 2021, 7:39 p.m. |
OK |
Python 3 |
TESTS |
59 |
436 |
19456000 |
|
|
119918484 |
ACoder_25 |
C |
June 18, 2021, 6:40 p.m. |
OK |
Python 3 |
TESTS |
59 |
482 |
16179200 |
|
|
119931250 |
snip_tusher |
C |
June 18, 2021, 10:14 p.m. |
OK |
Python 3 |
TESTS |
59 |
482 |
16281600 |
|
|
119934147 |
secondtimer |
C |
June 19, 2021, 12:43 a.m. |
OK |
Python 3 |
TESTS |
59 |
482 |
16384000 |
|
|
119952610 |
eugalt |
C |
June 19, 2021, 5:44 a.m. |
OK |
Python 3 |
TESTS |
59 |
483 |
16998400 |
|
|
119946015 |
XdjX |
C |
June 19, 2021, 4:31 a.m. |
OK |
Python 3 |
TESTS |
59 |
498 |
16076800 |
|
|
119950893 |
eugalt |
C |
June 19, 2021, 5:26 a.m. |
OK |
Python 3 |
TESTS |
59 |
498 |
18227200 |
|
|
remove filters
Back to search problems