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"There are n beautiful skyscrapers in New York, the height of the i -th one is h_i . Today some villains have set on fire first n - 1 of them, and now the only safety building is n -th skyscraper. Let's call a jump from i -th skyscraper to j -th ( i < j ) discrete, if all skyscrapers between are strictly lower or higher than both of them. Formally, jump is discrete, if i < j and one of the following conditions satisfied: At the moment, Vasya is staying on the first skyscraper and wants to live a little longer, so his goal is to reach n -th skyscraper with minimal count of discrete jumps. Help him with calcualting this number. The first line contains a single integer n ( 2 <= n <= 3 cdot 10^5 ) -- total amount of skyscrapers. The second line contains n integers h_1, h_2, ldots, h_n ( 1 <= h_i <= 10^9 ) -- heights of skyscrapers. Print single number k -- minimal amount of discrete jumps. We can show that an answer always exists. In the first testcase, Vasya can jump in the following way: 1 rightarrow 2 rightarrow 4 rightarrow 5 . In the second and third testcases, we can reach last skyscraper in one jump. Sequence of jumps in the fourth testcase: 1 rightarrow 3 rightarrow 5 . "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
92320682 |
lin_rany |
D |
Sept. 9, 2020, 5:29 a.m. |
OK |
GNU C++11 |
TESTS |
51 |
46 |
3788800 |
|
|
92320224 |
lin_rany2 |
D |
Sept. 9, 2020, 5:22 a.m. |
OK |
GNU C++11 |
TESTS |
51 |
46 |
3788800 |
|
|
92298661 |
arobindo |
D |
Sept. 8, 2020, 7:21 p.m. |
OK |
GNU C++11 |
TESTS |
51 |
46 |
3788800 |
|
|
92294771 |
wuruzhao |
D |
Sept. 8, 2020, 6:24 p.m. |
OK |
GNU C++11 |
TESTS |
50 |
46 |
3788800 |
|
|
92292798 |
wuruzhao |
D |
Sept. 8, 2020, 6 p.m. |
OK |
GNU C++11 |
TESTS |
50 |
46 |
3788800 |
|
|
92313585 |
qkoqhh |
D |
Sept. 9, 2020, 3:10 a.m. |
OK |
GNU C++11 |
TESTS |
51 |
46 |
4812800 |
|
|
92310175 |
onglu1 |
D |
Sept. 9, 2020, 1:26 a.m. |
OK |
GNU C++11 |
TESTS |
51 |
46 |
4812800 |
|
|
92315184 |
YHHxBULIATANIA |
D |
Sept. 9, 2020, 3:47 a.m. |
OK |
GNU C++11 |
TESTS |
51 |
46 |
5017600 |
|
|
92311836 |
I_Love_Sakurajima_Mai |
D |
Sept. 9, 2020, 2:23 a.m. |
OK |
GNU C++11 |
TESTS |
51 |
46 |
5017600 |
|
|
92280213 |
haohongyu |
D |
Sept. 8, 2020, 4:27 p.m. |
OK |
GNU C++11 |
TESTS |
50 |
46 |
5017600 |
|
|
92312713 |
linbinwu |
D |
Sept. 9, 2020, 2:47 a.m. |
OK |
GNU C++14 |
TESTS |
51 |
93 |
3993600 |
|
|
92308233 |
nkxjlym |
D |
Sept. 9, 2020, 12:03 a.m. |
OK |
GNU C++14 |
TESTS |
51 |
93 |
3993600 |
|
|
92319344 |
willingox |
D |
Sept. 9, 2020, 5:08 a.m. |
OK |
GNU C++14 |
TESTS |
51 |
93 |
4812800 |
|
|
92313953 |
Meple |
D |
Sept. 9, 2020, 3:18 a.m. |
OK |
GNU C++14 |
TESTS |
51 |
93 |
7987200 |
|
|
92285676 |
njrafi |
D |
Sept. 8, 2020, 5:03 p.m. |
OK |
GNU C++14 |
TESTS |
50 |
108 |
6451200 |
|
|
92318282 |
Or2_QSP |
D |
Sept. 9, 2020, 4:48 a.m. |
OK |
GNU C++14 |
TESTS |
51 |
108 |
7270400 |
|
|
92309642 |
ErdemKirez |
D |
Sept. 9, 2020, 1:06 a.m. |
OK |
GNU C++14 |
TESTS |
51 |
108 |
7987200 |
|
|
92314422 |
17je003275 |
D |
Sept. 9, 2020, 3:29 a.m. |
OK |
GNU C++14 |
TESTS |
51 |
109 |
3891200 |
|
|
92289772 |
phg0804 |
D |
Sept. 8, 2020, 5:29 p.m. |
OK |
GNU C++14 |
TESTS |
50 |
109 |
3891200 |
|
|
92311805 |
haluapuri |
D |
Sept. 9, 2020, 2:23 a.m. |
OK |
GNU C++14 |
TESTS |
51 |
109 |
3993600 |
|
|
92311999 |
Bennettz |
D |
Sept. 9, 2020, 2:29 a.m. |
OK |
GNU C++17 |
TESTS |
51 |
93 |
4812800 |
|
|
92291576 |
Ruki |
D |
Sept. 8, 2020, 5:47 p.m. |
OK |
GNU C++17 |
TESTS |
50 |
108 |
5632000 |
|
|
92299237 |
adityapathak1630 |
D |
Sept. 8, 2020, 7:30 p.m. |
OK |
GNU C++17 |
TESTS |
51 |
108 |
6553600 |
|
|
92311003 |
swust5120177231 |
D |
Sept. 9, 2020, 1:57 a.m. |
OK |
GNU C++17 |
TESTS |
51 |
108 |
7270400 |
|
|
92319915 |
starve_to_death |
D |
Sept. 9, 2020, 5:17 a.m. |
OK |
GNU C++17 |
TESTS |
51 |
108 |
20070400 |
|
|
92322637 |
wow_Wonderful |
D |
Sept. 9, 2020, 6 a.m. |
OK |
GNU C++17 |
TESTS |
51 |
109 |
3993600 |
|
|
92320007 |
ZztRans |
D |
Sept. 9, 2020, 5:19 a.m. |
OK |
GNU C++17 |
TESTS |
51 |
109 |
3993600 |
|
|
92304293 |
lukkka |
D |
Sept. 8, 2020, 9:23 p.m. |
OK |
GNU C++17 |
TESTS |
51 |
109 |
3993600 |
|
|
92292920 |
slowyfine |
D |
Sept. 8, 2020, 6:01 p.m. |
OK |
GNU C++17 |
TESTS |
50 |
109 |
3993600 |
|
|
92289798 |
Everule |
D |
Sept. 8, 2020, 5:29 p.m. |
OK |
GNU C++17 |
TESTS |
50 |
109 |
3993600 |
|
|
92305127 |
smax |
D |
Sept. 8, 2020, 9:51 p.m. |
OK |
GNU C++17 (64) |
TESTS |
51 |
62 |
3788800 |
|
|
92302340 |
WeakestTopology |
D |
Sept. 8, 2020, 8:30 p.m. |
OK |
GNU C++17 (64) |
TESTS |
51 |
77 |
3788800 |
|
|
92310173 |
Bediver |
D |
Sept. 9, 2020, 1:26 a.m. |
OK |
GNU C++17 (64) |
TESTS |
51 |
77 |
4812800 |
|
|
92290656 |
I_love_Harpae |
D |
Sept. 8, 2020, 5:37 p.m. |
OK |
GNU C++17 (64) |
TESTS |
50 |
77 |
6553600 |
|
|
92298701 |
dna049 |
D |
Sept. 8, 2020, 7:21 p.m. |
OK |
GNU C++17 (64) |
TESTS |
51 |
77 |
6656000 |
|
|
92289202 |
Harshlyn94 |
D |
Sept. 8, 2020, 5:24 p.m. |
OK |
GNU C++17 (64) |
TESTS |
50 |
77 |
6656000 |
|
|
92287523 |
Lucina |
D |
Sept. 8, 2020, 5:11 p.m. |
OK |
GNU C++17 (64) |
TESTS |
50 |
78 |
6656000 |
|
|
92294855 |
roshan_mehta |
D |
Sept. 8, 2020, 6:25 p.m. |
OK |
GNU C++17 (64) |
TESTS |
50 |
78 |
7782400 |
|
|
92286168 |
Juvitus |
D |
Sept. 8, 2020, 5:04 p.m. |
OK |
GNU C++17 (64) |
TESTS |
50 |
78 |
9113600 |
|
|
92296149 |
tryptophan |
D |
Sept. 8, 2020, 6:43 p.m. |
OK |
GNU C++17 (64) |
TESTS |
50 |
78 |
9830400 |
|
|
92300048 |
mphillotry |
D |
Sept. 8, 2020, 7:44 p.m. |
OK |
Java 11 |
TESTS |
51 |
264 |
5734400 |
|
|
92280961 |
adp527 |
D |
Sept. 8, 2020, 4:28 p.m. |
OK |
Java 11 |
TESTS |
50 |
374 |
21913600 |
|
|
92306847 |
hakr_2104 |
D |
Sept. 8, 2020, 10:58 p.m. |
OK |
Java 11 |
TESTS |
51 |
405 |
29491200 |
|
|
92299639 |
Dukkha |
D |
Sept. 8, 2020, 7:37 p.m. |
OK |
Java 11 |
TESTS |
51 |
561 |
0 |
|
|
92290241 |
Naman_123 |
D |
Sept. 8, 2020, 5:33 p.m. |
OK |
Java 8 |
TESTS |
50 |
233 |
22323200 |
|
|
92316905 |
SecondThread |
D |
Sept. 9, 2020, 4:21 a.m. |
OK |
Java 8 |
TESTS |
51 |
265 |
30617600 |
|
|
92295718 |
KharYusuf |
D |
Sept. 8, 2020, 6:37 p.m. |
OK |
Java 8 |
TESTS |
50 |
358 |
15360000 |
|
|
92305715 |
mwen |
D |
Sept. 8, 2020, 10:11 p.m. |
OK |
Java 8 |
TESTS |
51 |
389 |
13619200 |
|
|
92309962 |
martins |
D |
Sept. 9, 2020, 1:18 a.m. |
OK |
Java 8 |
TESTS |
51 |
607 |
15155200 |
|
|
92293332 |
JunBinLiang |
D |
Sept. 8, 2020, 6:06 p.m. |
OK |
Java 8 |
TESTS |
50 |
654 |
4915200 |
|
|
92313318 |
DivyaSree20 |
D |
Sept. 9, 2020, 3:03 a.m. |
OK |
Java 8 |
TESTS |
51 |
764 |
36249600 |
|
|
92322138 |
martins |
D |
Sept. 9, 2020, 5:52 a.m. |
OK |
Java 8 |
TESTS |
51 |
810 |
41062400 |
|
|
92305003 |
hoffrj |
D |
Sept. 8, 2020, 9:47 p.m. |
OK |
Java 8 |
TESTS |
51 |
826 |
85811200 |
|
|
92280709 |
Hemose |
D |
Sept. 8, 2020, 4:28 p.m. |
OK |
Java 8 |
TESTS |
50 |
982 |
36249600 |
|
|
92291280 |
hibatibati |
D |
Sept. 8, 2020, 5:44 p.m. |
OK |
Mono C# |
TESTS |
50 |
218 |
45465600 |
|
|
92285386 |
fgwiebfaoish |
D |
Sept. 8, 2020, 5:02 p.m. |
OK |
Mono C# |
TESTS |
50 |
717 |
52019200 |
|
|
92315381 |
P___ |
D |
Sept. 9, 2020, 3:50 a.m. |
OK |
MS C++ 2017 |
TESTS |
51 |
187 |
10444800 |
|
|
92313046 |
rhksdn6227 |
D |
Sept. 9, 2020, 2:57 a.m. |
OK |
MS C++ 2017 |
TESTS |
51 |
280 |
4812800 |
|
|
92321811 |
little_lion |
D |
Sept. 9, 2020, 5:46 a.m. |
OK |
MS C++ 2017 |
TESTS |
51 |
312 |
4812800 |
|
|
92313881 |
caandmn |
D |
Sept. 9, 2020, 3:17 a.m. |
OK |
MS C++ 2017 |
TESTS |
51 |
405 |
17612800 |
|
|
92280690 |
AnnSuperstar |
D |
Sept. 8, 2020, 4:28 p.m. |
OK |
MS C++ 2017 |
TESTS |
50 |
421 |
10854400 |
|
|
92303121 |
AnnSuperstar |
D |
Sept. 8, 2020, 8:50 p.m. |
OK |
MS C++ 2017 |
TESTS |
51 |
483 |
44339200 |
|
|
92286793 |
TheVan |
D |
Sept. 8, 2020, 5:07 p.m. |
OK |
PyPy 3 |
TESTS |
50 |
358 |
31948800 |
|
|
92291370 |
kclee2172 |
D |
Sept. 8, 2020, 5:45 p.m. |
OK |
PyPy 3 |
TESTS |
50 |
514 |
28057600 |
|
|
92286671 |
lowking |
D |
Sept. 8, 2020, 5:07 p.m. |
OK |
PyPy 3 |
TESTS |
50 |
546 |
32051200 |
|
|
92322545 |
IMP0STER |
D |
Sept. 9, 2020, 5:58 a.m. |
OK |
PyPy 3 |
TESTS |
51 |
576 |
30515200 |
|
|
92295108 |
nehan_der_thal |
D |
Sept. 8, 2020, 6:29 p.m. |
OK |
PyPy 3 |
TESTS |
50 |
748 |
104550400 |
|
|
92292000 |
titia |
D |
Sept. 8, 2020, 5:51 p.m. |
OK |
PyPy 3 |
TESTS |
50 |
779 |
55500800 |
|
|
92289641 |
throwawayatcoder |
D |
Sept. 8, 2020, 5:28 p.m. |
OK |
PyPy 3 |
TESTS |
50 |
826 |
53862400 |
|
|
92288621 |
throwawayatcoder |
D |
Sept. 8, 2020, 5:20 p.m. |
OK |
PyPy 3 |
TESTS |
50 |
966 |
96051200 |
|
|
92319775 |
shanu_im |
D |
Sept. 9, 2020, 5:16 a.m. |
OK |
PyPy 3 |
TESTS |
51 |
1091 |
145612800 |
|
|
92294372 |
chinerist |
D |
Sept. 8, 2020, 6:18 p.m. |
OK |
PyPy 3 |
TESTS |
50 |
1965 |
112230400 |
|
|
92287199 |
nwi |
D |
Sept. 8, 2020, 5:10 p.m. |
OK |
Python 2 |
TESTS |
50 |
1949 |
75468800 |
|
|
92297053 |
sh1194 |
D |
Sept. 8, 2020, 6:57 p.m. |
OK |
Python 3 |
TESTS |
51 |
1668 |
23654400 |
|
|
92296983 |
sh1194 |
D |
Sept. 8, 2020, 6:55 p.m. |
OK |
Python 3 |
TESTS |
51 |
1731 |
23654400 |
|
|
92314272 |
wow_ok |
D |
Sept. 9, 2020, 3:25 a.m. |
OK |
Ruby |
TESTS |
51 |
1450 |
113152000 |
|
|
92312475 |
wow_ok |
D |
Sept. 9, 2020, 2:41 a.m. |
OK |
Ruby |
TESTS |
51 |
1466 |
111923200 |
|
|
92314355 |
wow_ok |
D |
Sept. 9, 2020, 3:27 a.m. |
OK |
Ruby |
TESTS |
51 |
1466 |
112230400 |
|
|
92287764 |
sansen |
D |
Sept. 8, 2020, 5:13 p.m. |
OK |
Rust |
TESTS |
50 |
62 |
15052800 |
|
|
92285389 |
o2c |
D |
Sept. 8, 2020, 5:02 p.m. |
OK |
Rust |
TESTS |
50 |
124 |
19968000 |
|
|
remove filters
Back to search problems