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 given a sequence of n integers a_1 , a_2 , ..., a_n . Let us call an index j ( 2 <= j <= {{n-1}} ) a hill if a_j > a_{{j+1}} and a_j > a_{{j-1}} ; and let us call it a valley if a_j < a_{{j+1}} and a_j < a_{{j-1}} . Let us define the intimidation value of a sequence as the sum of the number of hills and the number of valleys in the sequence. You can change exactly one integer in the sequence to any number that you want, or let the sequence remain unchanged. What is the minimum intimidation value that you can achieve? The first line of the input contains a single integer t ( 1 <= t <= 10000 ) -- the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer n ( 1 <= n <= 3 cdot10^5 ). The second line of each test case contains n space-separated integers a_1 , a_2 , ..., a_n ( 1 <= a_i <= 10^9 ). It is guaranteed that the sum of n over all test cases does not exceed 3 cdot10^5 . For each test case, print a single integer -- the minimum intimidation value that you can achieve. In the first test case, changing a_2 to 2 results in no hills and no valleys. In the second test case, the best answer is just to leave the array as it is. In the third test case, changing a_3 to 6 results in only one valley (at the index 5 ). In the fourth test case, changing a_3 to 6 results in no hills and no valleys. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
103811164 |
ruban |
B |
Jan. 8, 2021, 5:05 p.m. |
OK |
Delphi |
TESTS |
10 |
171 |
69120000 |
|
1700 |
103832515 |
ramvenkat98 |
B |
Jan. 8, 2021, 9:50 p.m. |
OK |
GNU C11 |
TESTS |
10 |
93 |
1228800 |
|
1700 |
103819626 |
LW_ZM |
B |
Jan. 8, 2021, 6:16 p.m. |
OK |
GNU C11 |
TESTS |
10 |
93 |
1638400 |
|
1700 |
103820319 |
Arie123777 |
B |
Jan. 8, 2021, 6:24 p.m. |
OK |
GNU C11 |
TESTS |
10 |
93 |
2457600 |
|
1700 |
103810204 |
Beku.sh |
B |
Jan. 8, 2021, 5:01 p.m. |
OK |
GNU C11 |
TESTS |
10 |
124 |
1228800 |
|
1700 |
103839712 |
zja601 |
B |
Jan. 9, 2021, 2:13 a.m. |
OK |
GNU C11 |
TESTS |
10 |
763 |
4812800 |
|
1700 |
103802326 |
Chitanda_ |
B |
Jan. 8, 2021, 4:23 p.m. |
OK |
GNU C++11 |
TESTS |
10 |
31 |
1228800 |
|
1700 |
103842195 |
vectorwyx |
B |
Jan. 9, 2021, 3:25 a.m. |
OK |
GNU C++11 |
TESTS |
10 |
31 |
2457600 |
|
1700 |
103840641 |
Fairicle |
B |
Jan. 9, 2021, 2:41 a.m. |
OK |
GNU C++11 |
TESTS |
10 |
46 |
1228800 |
|
1700 |
103803882 |
GhostCai |
B |
Jan. 8, 2021, 4:26 p.m. |
OK |
GNU C++11 |
TESTS |
10 |
46 |
1228800 |
|
1700 |
103836323 |
sorry_thebighead |
B |
Jan. 9, 2021, 12:08 a.m. |
OK |
GNU C++11 |
TESTS |
10 |
46 |
1843200 |
|
1700 |
103802154 |
QDK_Storm |
B |
Jan. 8, 2021, 4:23 p.m. |
OK |
GNU C++11 |
TESTS |
10 |
46 |
2457600 |
|
1700 |
103841662 |
74Nanashi |
B |
Jan. 9, 2021, 3:11 a.m. |
OK |
GNU C++11 |
TESTS |
10 |
46 |
2560000 |
|
1700 |
103843680 |
zhazha_song |
B |
Jan. 9, 2021, 4 a.m. |
OK |
GNU C++11 |
TESTS |
10 |
46 |
7987200 |
|
1700 |
103844480 |
wjmsxbd |
B |
Jan. 9, 2021, 4:19 a.m. |
OK |
GNU C++11 |
TESTS |
10 |
61 |
2457600 |
|
1700 |
103836580 |
Another_CraZYali |
B |
Jan. 9, 2021, 12:19 a.m. |
OK |
GNU C++11 |
TESTS |
10 |
62 |
1228800 |
|
1700 |
103815656 |
tangodown |
B |
Jan. 8, 2021, 5:38 p.m. |
OK |
GNU C++14 |
TESTS |
10 |
93 |
1228800 |
|
1700 |
103813208 |
nagisa-test |
B |
Jan. 8, 2021, 5:17 p.m. |
OK |
GNU C++14 |
TESTS |
10 |
93 |
1228800 |
|
1700 |
103849315 |
apurv001 |
B |
Jan. 9, 2021, 5:56 a.m. |
OK |
GNU C++14 |
TESTS |
10 |
93 |
1228800 |
|
1700 |
103847323 |
partha_paul |
B |
Jan. 9, 2021, 5:23 a.m. |
OK |
GNU C++14 |
TESTS |
10 |
93 |
1228800 |
|
1700 |
103846459 |
liaoshixing |
B |
Jan. 9, 2021, 5:06 a.m. |
OK |
GNU C++14 |
TESTS |
10 |
93 |
1228800 |
|
1700 |
103825856 |
RedAnt |
B |
Jan. 8, 2021, 7:32 p.m. |
OK |
GNU C++14 |
TESTS |
10 |
93 |
1228800 |
|
1700 |
103818636 |
Ma7moud.7amdy |
B |
Jan. 8, 2021, 6:06 p.m. |
OK |
GNU C++14 |
TESTS |
10 |
93 |
1228800 |
|
1700 |
103812105 |
Splashing |
B |
Jan. 8, 2021, 5:10 p.m. |
OK |
GNU C++14 |
TESTS |
10 |
93 |
1536000 |
|
1700 |
103818029 |
ash_98 |
B |
Jan. 8, 2021, 6:01 p.m. |
OK |
GNU C++14 |
TESTS |
10 |
93 |
1536000 |
|
1700 |
103845197 |
Yash_mittal2409 |
B |
Jan. 9, 2021, 4:37 a.m. |
OK |
GNU C++14 |
TESTS |
10 |
93 |
2355200 |
|
1700 |
103802909 |
Lenick |
B |
Jan. 8, 2021, 4:24 p.m. |
OK |
GNU C++17 |
TESTS |
10 |
78 |
1536000 |
|
1700 |
103838552 |
-DanTheMan- |
B |
Jan. 9, 2021, 1:31 a.m. |
OK |
GNU C++17 |
TESTS |
10 |
93 |
1228800 |
|
1700 |
103846128 |
devinqu |
B |
Jan. 9, 2021, 4:57 a.m. |
OK |
GNU C++17 |
TESTS |
10 |
93 |
1228800 |
|
1700 |
103842220 |
motorcycle |
B |
Jan. 9, 2021, 3:25 a.m. |
OK |
GNU C++17 |
TESTS |
10 |
93 |
1228800 |
|
1700 |
103841303 |
X-knight |
B |
Jan. 9, 2021, 3 a.m. |
OK |
GNU C++17 |
TESTS |
10 |
93 |
1228800 |
|
1700 |
103836473 |
mike51 |
B |
Jan. 9, 2021, 12:14 a.m. |
OK |
GNU C++17 |
TESTS |
10 |
93 |
1228800 |
|
1700 |
103835601 |
Magdy_Sedra |
B |
Jan. 8, 2021, 11:36 p.m. |
OK |
GNU C++17 |
TESTS |
10 |
93 |
1228800 |
|
1700 |
103834727 |
searleser97 |
B |
Jan. 8, 2021, 10:59 p.m. |
OK |
GNU C++17 |
TESTS |
10 |
93 |
1228800 |
|
1700 |
103834466 |
SAADxENCIPHERER |
B |
Jan. 8, 2021, 10:50 p.m. |
OK |
GNU C++17 |
TESTS |
10 |
93 |
1228800 |
|
1700 |
103833778 |
searleser97 |
B |
Jan. 8, 2021, 10:27 p.m. |
OK |
GNU C++17 |
TESTS |
10 |
93 |
1228800 |
|
1700 |
103840885 |
tuanio |
B |
Jan. 9, 2021, 2:49 a.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
61 |
1228800 |
|
1700 |
103835102 |
decltypo |
B |
Jan. 8, 2021, 11:13 p.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
62 |
1228800 |
|
1700 |
103834523 |
MixxCP3 |
B |
Jan. 8, 2021, 10:52 p.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
62 |
1228800 |
|
1700 |
103830982 |
Levoz |
B |
Jan. 8, 2021, 9:12 p.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
62 |
1228800 |
|
1700 |
103828309 |
haengsyo |
B |
Jan. 8, 2021, 8:12 p.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
62 |
1228800 |
|
1700 |
103837967 |
qdd |
B |
Jan. 9, 2021, 1:09 a.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
62 |
1228800 |
|
1700 |
103840486 |
LethalPuppy |
B |
Jan. 9, 2021, 2:36 a.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
62 |
1228800 |
|
1700 |
103840864 |
tuanio |
B |
Jan. 9, 2021, 2:48 a.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
62 |
1228800 |
|
1700 |
103843810 |
Rorent |
B |
Jan. 9, 2021, 4:03 a.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
62 |
1228800 |
|
1700 |
103837643 |
__modurovy__ |
B |
Jan. 9, 2021, 12:58 a.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
62 |
1228800 |
|
1700 |
103841552 |
0x3F |
B |
Jan. 9, 2021, 3:07 a.m. |
OK |
Go |
TESTS |
10 |
234 |
4812800 |
|
1700 |
103841322 |
0x3F |
B |
Jan. 9, 2021, 3:01 a.m. |
OK |
Go |
TESTS |
10 |
234 |
4812800 |
|
1700 |
103841269 |
0x3F |
B |
Jan. 9, 2021, 2:59 a.m. |
OK |
Go |
TESTS |
10 |
249 |
4710400 |
|
1700 |
103828652 |
dauom |
B |
Jan. 8, 2021, 8:19 p.m. |
OK |
Java 11 |
TESTS |
10 |
186 |
0 |
|
1700 |
103829220 |
Magikarp1 |
B |
Jan. 8, 2021, 8:31 p.m. |
OK |
Java 11 |
TESTS |
10 |
233 |
4198400 |
|
1700 |
103837528 |
Mhmmd.itani |
B |
Jan. 9, 2021, 12:54 a.m. |
OK |
Java 11 |
TESTS |
10 |
248 |
4198400 |
|
1700 |
103820529 |
BlueBirdie |
B |
Jan. 8, 2021, 6:26 p.m. |
OK |
Java 11 |
TESTS |
10 |
248 |
4198400 |
|
1700 |
103803632 |
I_Killed_Jason_Todd |
B |
Jan. 8, 2021, 4:26 p.m. |
OK |
Java 11 |
TESTS |
10 |
248 |
4198400 |
|
1700 |
103846044 |
RuthlessAggression |
B |
Jan. 9, 2021, 4:55 a.m. |
OK |
Java 11 |
TESTS |
10 |
249 |
4198400 |
|
1700 |
103815683 |
gssakash |
B |
Jan. 8, 2021, 5:39 p.m. |
OK |
Java 11 |
TESTS |
10 |
264 |
4198400 |
|
1700 |
103834593 |
5612 |
B |
Jan. 8, 2021, 10:55 p.m. |
OK |
Java 11 |
TESTS |
10 |
265 |
4198400 |
|
1700 |
103808751 |
Restricted |
B |
Jan. 8, 2021, 4:34 p.m. |
OK |
Java 11 |
TESTS |
10 |
265 |
4198400 |
|
1700 |
103803090 |
decoder_1671 |
B |
Jan. 8, 2021, 4:25 p.m. |
OK |
Java 11 |
TESTS |
10 |
265 |
26112000 |
|
1700 |
103844982 |
mufaddalnaya |
B |
Jan. 9, 2021, 4:32 a.m. |
OK |
Java 8 |
TESTS |
10 |
155 |
0 |
|
1700 |
103816211 |
MubtasimShahriar |
B |
Jan. 8, 2021, 5:43 p.m. |
OK |
Java 8 |
TESTS |
10 |
155 |
0 |
|
1700 |
103816132 |
MubtasimShahriar |
B |
Jan. 8, 2021, 5:43 p.m. |
OK |
Java 8 |
TESTS |
10 |
155 |
0 |
|
1700 |
103811327 |
MubtasimShahriar |
B |
Jan. 8, 2021, 5:06 p.m. |
OK |
Java 8 |
TESTS |
10 |
155 |
0 |
|
1700 |
103813544 |
MubtasimShahriar |
B |
Jan. 8, 2021, 5:20 p.m. |
OK |
Java 8 |
TESTS |
10 |
156 |
0 |
|
1700 |
103821336 |
2020akadaver |
B |
Jan. 8, 2021, 6:34 p.m. |
OK |
Java 8 |
TESTS |
10 |
186 |
12800000 |
|
1700 |
103849549 |
RonWonWon |
B |
Jan. 9, 2021, 6 a.m. |
OK |
Java 8 |
TESTS |
10 |
186 |
12902400 |
|
1700 |
103846682 |
Charigardash |
B |
Jan. 9, 2021, 5:10 a.m. |
OK |
Java 8 |
TESTS |
10 |
186 |
12902400 |
|
1700 |
103810908 |
an09mous |
B |
Jan. 8, 2021, 5:03 p.m. |
OK |
Java 8 |
TESTS |
10 |
187 |
12800000 |
|
1700 |
103837115 |
ramuked |
B |
Jan. 9, 2021, 12:41 a.m. |
OK |
Java 8 |
TESTS |
10 |
187 |
12902400 |
|
1700 |
103836439 |
CepGamer |
B |
Jan. 9, 2021, 12:13 a.m. |
OK |
Kotlin |
TESTS |
10 |
249 |
1126400 |
|
1700 |
103803251 |
pallav12 |
B |
Jan. 8, 2021, 4:25 p.m. |
OK |
Kotlin |
TESTS |
10 |
358 |
29184000 |
|
1700 |
103825231 |
catforce |
B |
Jan. 8, 2021, 7:23 p.m. |
OK |
Kotlin |
TESTS |
10 |
389 |
34406400 |
|
1700 |
103808283 |
arvindf232 |
B |
Jan. 8, 2021, 4:34 p.m. |
OK |
Kotlin |
TESTS |
10 |
608 |
1638400 |
|
1700 |
103808830 |
stostap |
B |
Jan. 8, 2021, 4:34 p.m. |
OK |
MS C++ 2017 |
TESTS |
10 |
124 |
1228800 |
|
1700 |
103803597 |
dingzhao777 |
B |
Jan. 8, 2021, 4:26 p.m. |
OK |
MS C++ 2017 |
TESTS |
10 |
140 |
3584000 |
|
1700 |
103813737 |
Serendipity__ |
B |
Jan. 8, 2021, 5:21 p.m. |
OK |
MS C++ 2017 |
TESTS |
10 |
295 |
1228800 |
|
1700 |
103813069 |
jungin0507 |
B |
Jan. 8, 2021, 5:16 p.m. |
OK |
MS C++ 2017 |
TESTS |
10 |
296 |
1228800 |
|
1700 |
103846401 |
Archie98 |
B |
Jan. 9, 2021, 5:04 a.m. |
OK |
MS C++ 2017 |
TESTS |
10 |
327 |
2355200 |
|
1700 |
103811847 |
LucianWu |
B |
Jan. 8, 2021, 5:08 p.m. |
OK |
MS C++ 2017 |
TESTS |
10 |
327 |
3584000 |
|
1700 |
103816082 |
Tirutu |
B |
Jan. 8, 2021, 5:42 p.m. |
OK |
MS C++ 2017 |
TESTS |
10 |
358 |
1536000 |
|
1700 |
103813289 |
LucianWu |
B |
Jan. 8, 2021, 5:18 p.m. |
OK |
MS C++ 2017 |
TESTS |
10 |
358 |
3584000 |
|
1700 |
103816442 |
ustaritz |
B |
Jan. 8, 2021, 5:45 p.m. |
OK |
MS C++ 2017 |
TESTS |
10 |
374 |
1228800 |
|
1700 |
103811902 |
_CHANI |
B |
Jan. 8, 2021, 5:09 p.m. |
OK |
MS C++ 2017 |
TESTS |
10 |
389 |
2457600 |
|
1700 |
103808686 |
watarimaycry2 |
B |
Jan. 8, 2021, 4:34 p.m. |
OK |
Node.js |
TESTS |
10 |
233 |
34508800 |
|
1700 |
103831726 |
rsFalse |
B |
Jan. 8, 2021, 9:29 p.m. |
OK |
Perl |
TESTS |
10 |
920 |
43827200 |
|
1700 |
103838053 |
Ayushman_500 |
B |
Jan. 9, 2021, 1:12 a.m. |
OK |
PyPy 2 |
TESTS |
10 |
733 |
23347200 |
|
1700 |
103818205 |
strivetodeath |
B |
Jan. 8, 2021, 6:02 p.m. |
OK |
PyPy 3 |
TESTS |
10 |
295 |
24064000 |
|
1700 |
103817957 |
strivetodeath |
B |
Jan. 8, 2021, 6 p.m. |
OK |
PyPy 3 |
TESTS |
10 |
311 |
23961600 |
|
1700 |
103816556 |
YMSeah |
B |
Jan. 8, 2021, 5:47 p.m. |
OK |
PyPy 3 |
TESTS |
10 |
404 |
24064000 |
|
1700 |
103810753 |
manish.17 |
B |
Jan. 8, 2021, 5:03 p.m. |
OK |
PyPy 3 |
TESTS |
10 |
467 |
26931200 |
|
1700 |
103817820 |
silvertint |
B |
Jan. 8, 2021, 5:58 p.m. |
OK |
PyPy 3 |
TESTS |
10 |
514 |
26828800 |
|
1700 |
103847215 |
rajbit |
B |
Jan. 9, 2021, 5:21 a.m. |
OK |
PyPy 3 |
TESTS |
10 |
561 |
32256000 |
|
1700 |
103845162 |
MILOY |
B |
Jan. 9, 2021, 4:36 a.m. |
OK |
PyPy 3 |
TESTS |
10 |
592 |
26931200 |
|
1700 |
103816662 |
donuthole |
B |
Jan. 8, 2021, 5:47 p.m. |
OK |
PyPy 3 |
TESTS |
10 |
639 |
31129600 |
|
1700 |
103828321 |
utkarsh.sharma |
B |
Jan. 8, 2021, 8:12 p.m. |
OK |
PyPy 3 |
TESTS |
10 |
654 |
27033600 |
|
1700 |
103816582 |
Believer_Ayush |
B |
Jan. 8, 2021, 5:47 p.m. |
OK |
PyPy 3 |
TESTS |
10 |
655 |
27033600 |
|
1700 |
103825737 |
sh1194 |
B |
Jan. 8, 2021, 7:30 p.m. |
OK |
Python 3 |
TESTS |
10 |
436 |
22425600 |
|
1700 |
103808010 |
Aditi_aggarwal |
B |
Jan. 8, 2021, 4:33 p.m. |
OK |
Python 3 |
TESTS |
10 |
608 |
23449600 |
|
1700 |
103812733 |
gvineeth |
B |
Jan. 8, 2021, 5:14 p.m. |
OK |
Python 3 |
TESTS |
10 |
623 |
18022400 |
|
1700 |
103806543 |
codeforcessuperman |
B |
Jan. 8, 2021, 4:31 p.m. |
OK |
Python 3 |
TESTS |
10 |
670 |
23142400 |
|
1700 |
103825786 |
the_stone_dawg |
B |
Jan. 8, 2021, 7:31 p.m. |
OK |
Rust |
TESTS |
10 |
218 |
19968000 |
|
1700 |
remove filters
Back to search problems