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 piles of sand where the i -th pile has a_i blocks of sand. The i -th pile is called too tall if 1 < i < n and a_i > a_{i-1} + a_{i+1} . That is, a pile is too tall if it has more sand than its two neighbours combined. (Note that piles on the ends of the array cannot be too tall.) You are given an integer k . An operation consists of picking k consecutive piles of sand and adding one unit of sand to them all. Formally, pick 1 <= q l,r <= q n such that r-l+1=k . Then for all l <= q i <= q r , update a_i gets a_i+1 . What is the maximum number of piles that can simultaneously be too tall after some (possibly zero) operations? The input consists of multiple test cases. The first line contains an integer t ( 1 <= q t <= q 1000 ) -- the number of test cases. The description of the test cases follows. The first line of each test case contains two integers n and k ( 3 <= q n <= q 2 cdot 10^5 ; 1 <= q k <= q n ) -- the number of piles of sand and the size of the operation, respectively. The second line of each test case contains n integers a_1, a_2, ldots, a_n ( 1 <= a_i <= 10^9 ) -- the sizes of the piles. It is guaranteed that the sum of n over all test cases does not exceed 2 cdot 10^5 . For each test case, output a single integer -- the maximum number of piles that are simultaneously too tall after some (possibly zero) operations. In the first test case, we can perform the following three operations: In the second test case, any operation will increase all piles by 1 unit, so the number of too tall piles will always be 0 . In the third test case, we can increase any pile by 1 unit of sand. It can be shown that the maximum number of too tall piles is 1 . '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
162200808 |
TIT_0 |
B |
June 29, 2022, 5:11 a.m. |
OK |
Clang++17 Diagnostics |
TESTS |
7 |
951 |
1024000 |
|
|
162191161 |
xkys |
B |
June 29, 2022, 2:32 a.m. |
OK |
Clang++17 Diagnostics |
TESTS |
7 |
967 |
819200 |
|
|
162192540 |
ldu-LC |
B |
June 29, 2022, 2:57 a.m. |
OK |
Clang++20 Diagnostics |
TESTS |
7 |
889 |
819200 |
|
|
162171069 |
Ambh |
B |
June 28, 2022, 7:18 p.m. |
OK |
GNU C11 |
TESTS |
7 |
46 |
0 |
|
|
162192470 |
gxlois |
B |
June 29, 2022, 2:56 a.m. |
OK |
GNU C11 |
TESTS |
7 |
46 |
819200 |
|
|
162157289 |
Devansh_2021460 |
B |
June 28, 2022, 5:23 p.m. |
OK |
GNU C11 |
TESTS |
7 |
46 |
819200 |
|
|
162169334 |
NagashSRB |
B |
June 28, 2022, 6:56 p.m. |
OK |
GNU C11 |
TESTS |
7 |
46 |
819200 |
|
|
162196339 |
antuda |
B |
June 29, 2022, 4:02 a.m. |
OK |
GNU C11 |
TESTS |
7 |
46 |
1638400 |
|
|
162154165 |
abdullah__92 |
B |
June 28, 2022, 4:49 p.m. |
OK |
GNU C11 |
TESTS |
7 |
46 |
3993600 |
|
|
162191279 |
JA2012 |
B |
June 29, 2022, 2:34 a.m. |
OK |
GNU C++14 |
TESTS |
7 |
15 |
1843200 |
|
|
162183403 |
cccccccelery |
B |
June 28, 2022, 11:39 p.m. |
OK |
GNU C++14 |
TESTS |
7 |
31 |
819200 |
|
|
162193165 |
Woof_woof |
B |
June 29, 2022, 3:08 a.m. |
OK |
GNU C++14 |
TESTS |
7 |
46 |
819200 |
|
|
162190798 |
JoesSR |
B |
June 29, 2022, 2:25 a.m. |
OK |
GNU C++14 |
TESTS |
7 |
46 |
819200 |
|
|
162198644 |
Shubh_30 |
B |
June 29, 2022, 4:38 a.m. |
OK |
GNU C++14 |
TESTS |
7 |
46 |
819200 |
|
|
162198499 |
niberber |
B |
June 29, 2022, 4:36 a.m. |
OK |
GNU C++14 |
TESTS |
7 |
46 |
819200 |
|
|
162198199 |
Tree2003 |
B |
June 29, 2022, 4:32 a.m. |
OK |
GNU C++14 |
TESTS |
7 |
46 |
819200 |
|
|
162193350 |
alkido |
B |
June 29, 2022, 3:11 a.m. |
OK |
GNU C++14 |
TESTS |
7 |
46 |
819200 |
|
|
162202758 |
star_force |
B |
June 29, 2022, 5:38 a.m. |
OK |
GNU C++14 |
TESTS |
7 |
46 |
819200 |
|
|
162202321 |
liuyunfei |
B |
June 29, 2022, 5:32 a.m. |
OK |
GNU C++14 |
TESTS |
7 |
46 |
819200 |
|
|
162187802 |
kk19212 |
B |
June 29, 2022, 1:33 a.m. |
OK |
GNU C++17 |
TESTS |
7 |
15 |
1843200 |
|
|
162159216 |
Bobocan |
B |
June 28, 2022, 5:34 p.m. |
OK |
GNU C++17 |
TESTS |
7 |
30 |
1331200 |
|
|
162163756 |
Mahmoud-Khalid |
B |
June 28, 2022, 6:05 p.m. |
OK |
GNU C++17 |
TESTS |
7 |
31 |
819200 |
|
|
162192700 |
Beginner343 |
B |
June 29, 2022, 3 a.m. |
OK |
GNU C++17 |
TESTS |
7 |
31 |
819200 |
|
|
162202249 |
anshu_13 |
B |
June 29, 2022, 5:31 a.m. |
OK |
GNU C++17 |
TESTS |
7 |
31 |
819200 |
|
|
162180880 |
qianyue |
B |
June 28, 2022, 10:19 p.m. |
OK |
GNU C++17 |
TESTS |
7 |
31 |
819200 |
|
|
162167691 |
adbak77 |
B |
June 28, 2022, 6:39 p.m. |
OK |
GNU C++17 |
TESTS |
7 |
31 |
819200 |
|
|
162190850 |
dianzikejidaxue |
B |
June 29, 2022, 2:26 a.m. |
OK |
GNU C++17 |
TESTS |
7 |
31 |
7987200 |
|
|
162204146 |
oval_m |
B |
June 29, 2022, 5:56 a.m. |
OK |
GNU C++17 |
TESTS |
7 |
46 |
819200 |
|
|
162204166 |
Mahesh_001 |
B |
June 29, 2022, 5:57 a.m. |
OK |
GNU C++17 |
TESTS |
7 |
46 |
819200 |
|
|
162184618 |
xiece666 |
B |
June 29, 2022, 12:17 a.m. |
OK |
GNU C++17 (64) |
TESTS |
7 |
15 |
1843200 |
|
|
162178213 |
davidchi |
B |
June 28, 2022, 9:12 p.m. |
OK |
GNU C++17 (64) |
TESTS |
7 |
30 |
819200 |
|
|
162188825 |
RetsaZC19 |
B |
June 29, 2022, 1:51 a.m. |
OK |
GNU C++17 (64) |
TESTS |
7 |
30 |
819200 |
|
|
162168192 |
maxcruickshanks |
B |
June 28, 2022, 6:44 p.m. |
OK |
GNU C++17 (64) |
TESTS |
7 |
30 |
819200 |
|
|
162165835 |
jagerknight |
B |
June 28, 2022, 6:22 p.m. |
OK |
GNU C++17 (64) |
TESTS |
7 |
30 |
1638400 |
|
|
162161272 |
rohan_101 |
B |
June 28, 2022, 5:48 p.m. |
OK |
GNU C++17 (64) |
TESTS |
7 |
30 |
1638400 |
|
|
162194472 |
Th_K |
B |
June 29, 2022, 3:30 a.m. |
OK |
GNU C++17 (64) |
TESTS |
7 |
31 |
819200 |
|
|
162190271 |
Roshin |
B |
June 29, 2022, 2:16 a.m. |
OK |
GNU C++17 (64) |
TESTS |
7 |
31 |
819200 |
|
|
162183730 |
NellerP21 |
B |
June 28, 2022, 11:49 p.m. |
OK |
GNU C++17 (64) |
TESTS |
7 |
31 |
819200 |
|
|
162183394 |
PCC |
B |
June 28, 2022, 11:39 p.m. |
OK |
GNU C++17 (64) |
TESTS |
7 |
31 |
819200 |
|
|
162197864 |
izumiQR |
B |
June 29, 2022, 4:26 a.m. |
OK |
GNU C++20 (64) |
TESTS |
7 |
15 |
819200 |
|
|
162186325 |
JustJie |
B |
June 29, 2022, 1:01 a.m. |
OK |
GNU C++20 (64) |
TESTS |
7 |
15 |
819200 |
|
|
162162527 |
zhenagajo234 |
B |
June 28, 2022, 5:56 p.m. |
OK |
GNU C++20 (64) |
TESTS |
7 |
15 |
819200 |
|
|
162160823 |
Shady.scof |
B |
June 28, 2022, 5:44 p.m. |
OK |
GNU C++20 (64) |
TESTS |
7 |
15 |
819200 |
|
|
162202873 |
clams |
B |
June 29, 2022, 5:40 a.m. |
OK |
GNU C++20 (64) |
TESTS |
7 |
15 |
819200 |
|
|
162172948 |
himanshuyadav2002 |
B |
June 28, 2022, 7:43 p.m. |
OK |
GNU C++20 (64) |
TESTS |
7 |
15 |
1638400 |
|
|
162182478 |
tanvir___ju |
B |
June 28, 2022, 11:09 p.m. |
OK |
GNU C++20 (64) |
TESTS |
7 |
15 |
1638400 |
|
|
162187100 |
dimpal_112 |
B |
June 29, 2022, 1:19 a.m. |
OK |
GNU C++20 (64) |
TESTS |
7 |
15 |
1638400 |
|
|
162194267 |
Asahi_ |
B |
June 29, 2022, 3:27 a.m. |
OK |
GNU C++20 (64) |
TESTS |
7 |
15 |
1638400 |
|
|
162197863 |
yuluosheng |
B |
June 29, 2022, 4:26 a.m. |
OK |
GNU C++20 (64) |
TESTS |
7 |
15 |
1638400 |
|
|
162154481 |
paul_ss |
B |
June 28, 2022, 4:49 p.m. |
OK |
Go |
TESTS |
7 |
155 |
4608000 |
|
|
162159808 |
LazyHaskell |
B |
June 28, 2022, 5:38 p.m. |
OK |
Haskell |
TESTS |
7 |
124 |
19968000 |
|
|
162156898 |
LazyHaskell |
B |
June 28, 2022, 5:21 p.m. |
OK |
Haskell |
TESTS |
7 |
155 |
45158400 |
|
|
162176885 |
satyaa_78 |
B |
June 28, 2022, 8:45 p.m. |
OK |
Java 11 |
TESTS |
7 |
155 |
0 |
|
|
162203070 |
poopoop |
B |
June 29, 2022, 5:42 a.m. |
OK |
Java 11 |
TESTS |
7 |
155 |
0 |
|
|
162192959 |
Longgggggggg |
B |
June 29, 2022, 3:04 a.m. |
OK |
Java 11 |
TESTS |
7 |
171 |
0 |
|
|
162199481 |
the_unseen |
B |
June 29, 2022, 4:51 a.m. |
OK |
Java 11 |
TESTS |
7 |
186 |
0 |
|
|
162192913 |
KarMa_ |
B |
June 29, 2022, 3:03 a.m. |
OK |
Java 11 |
TESTS |
7 |
202 |
0 |
|
|
162164940 |
Kabirrrr19 |
B |
June 28, 2022, 6:15 p.m. |
OK |
Java 11 |
TESTS |
7 |
202 |
0 |
|
|
162156760 |
Kaldaruly |
B |
June 28, 2022, 5:21 p.m. |
OK |
Java 11 |
TESTS |
7 |
202 |
0 |
|
|
162161101 |
Nimit_3 |
B |
June 28, 2022, 5:46 p.m. |
OK |
Java 11 |
TESTS |
7 |
202 |
204800 |
|
|
162197135 |
malay1987 |
B |
June 29, 2022, 4:14 a.m. |
OK |
Java 11 |
TESTS |
7 |
217 |
0 |
|
|
162196510 |
blindingbythelights |
B |
June 29, 2022, 4:05 a.m. |
OK |
Java 11 |
TESTS |
7 |
217 |
0 |
|
|
162190623 |
zp16630309290 |
B |
June 29, 2022, 2:22 a.m. |
OK |
Java 17 |
TESTS |
7 |
420 |
1228800 |
|
|
162178068 |
WalrusRamen21 |
B |
June 28, 2022, 9:08 p.m. |
OK |
Java 17 |
TESTS |
7 |
530 |
716800 |
|
|
162158206 |
sidmal45 |
B |
June 28, 2022, 5:28 p.m. |
OK |
Java 8 |
TESTS |
7 |
109 |
2662400 |
|
|
162190015 |
ikillmyself |
B |
June 29, 2022, 2:11 a.m. |
OK |
Java 8 |
TESTS |
7 |
124 |
0 |
|
|
162176566 |
AhmedEl-Gohary |
B |
June 28, 2022, 8:40 p.m. |
OK |
Java 8 |
TESTS |
7 |
124 |
2764800 |
|
|
162171397 |
gagan1729 |
B |
June 28, 2022, 7:22 p.m. |
OK |
Java 8 |
TESTS |
7 |
124 |
2764800 |
|
|
162161119 |
Ahmed_yehia_hosny |
B |
June 28, 2022, 5:46 p.m. |
OK |
Java 8 |
TESTS |
7 |
139 |
2764800 |
|
|
162201118 |
RR2000 |
B |
June 29, 2022, 5:15 a.m. |
OK |
Java 8 |
TESTS |
7 |
140 |
2764800 |
|
|
162171510 |
Koka |
B |
June 28, 2022, 7:24 p.m. |
OK |
Java 8 |
TESTS |
7 |
140 |
2969600 |
|
|
162170796 |
handle007 |
B |
June 28, 2022, 7:14 p.m. |
OK |
Java 8 |
TESTS |
7 |
140 |
2969600 |
|
|
162174668 |
Islam12123 |
B |
June 28, 2022, 8:08 p.m. |
OK |
Java 8 |
TESTS |
7 |
358 |
0 |
|
|
162187880 |
Islam12123 |
B |
June 29, 2022, 1:34 a.m. |
OK |
Java 8 |
TESTS |
7 |
373 |
0 |
|
|
162185837 |
trycod3 |
B |
June 29, 2022, 12:49 a.m. |
OK |
JavaScript |
TESTS |
7 |
109 |
19251200 |
|
|
162177857 |
xxxtentaclez |
B |
June 28, 2022, 9:04 p.m. |
OK |
Kotlin 1.4 |
TESTS |
7 |
249 |
17100800 |
|
|
162176025 |
Kremlebot13 |
B |
June 28, 2022, 8:30 p.m. |
OK |
Kotlin 1.6 |
TESTS |
7 |
311 |
17305600 |
|
|
162197011 |
merzgling |
B |
June 29, 2022, 4:12 a.m. |
OK |
MS C++ 2017 |
TESTS |
7 |
171 |
819200 |
|
|
162175120 |
AlekseyHrisanfov |
B |
June 28, 2022, 8:16 p.m. |
OK |
MS C++ 2017 |
TESTS |
7 |
187 |
819200 |
|
|
162156622 |
rahul_Lalani_7 |
B |
June 28, 2022, 5:20 p.m. |
OK |
MS C++ 2017 |
TESTS |
7 |
202 |
1638400 |
|
|
162162286 |
touristjiangly |
B |
June 28, 2022, 5:55 p.m. |
OK |
Perl |
TESTS |
7 |
139 |
19865600 |
|
|
162161771 |
784 |
B |
June 28, 2022, 5:51 p.m. |
OK |
Perl |
TESTS |
7 |
139 |
19865600 |
|
|
162160648 |
yoralbayev |
B |
June 28, 2022, 5:43 p.m. |
OK |
PHP |
TESTS |
7 |
124 |
23142400 |
|
|
162164156 |
progin |
B |
June 28, 2022, 6:08 p.m. |
OK |
PHP |
TESTS |
7 |
124 |
25190400 |
|
|
162163416 |
pavanfknkarthik |
B |
June 28, 2022, 6:03 p.m. |
OK |
PyPy 3 |
TESTS |
7 |
218 |
21708800 |
|
|
162190988 |
jscn |
B |
June 29, 2022, 2:29 a.m. |
OK |
PyPy 3 |
TESTS |
7 |
233 |
15360000 |
|
|
162163368 |
MegaCharizrdZ |
B |
June 28, 2022, 6:02 p.m. |
OK |
PyPy 3 |
TESTS |
7 |
249 |
16179200 |
|
|
162164398 |
AdeelFeroz |
B |
June 28, 2022, 6:10 p.m. |
OK |
PyPy 3 |
TESTS |
7 |
249 |
18841600 |
|
|
162190965 |
Shrink |
B |
June 29, 2022, 2:28 a.m. |
OK |
PyPy 3 |
TESTS |
7 |
249 |
19046400 |
|
|
162161410 |
WalrusRamen21 |
B |
June 28, 2022, 5:49 p.m. |
OK |
PyPy 3 |
TESTS |
7 |
265 |
18841600 |
|
|
162171497 |
Yansou |
B |
June 28, 2022, 7:24 p.m. |
OK |
PyPy 3-64 |
TESTS |
7 |
139 |
15155200 |
|
|
162180762 |
radoan.sharkar.richi |
B |
June 28, 2022, 10:16 p.m. |
OK |
PyPy 3-64 |
TESTS |
7 |
139 |
15257600 |
|
|
162181444 |
zubra.bubra |
B |
June 28, 2022, 10:36 p.m. |
OK |
PyPy 3-64 |
TESTS |
7 |
139 |
19558400 |
|
|
162171940 |
Istarchick |
B |
June 28, 2022, 7:29 p.m. |
OK |
PyPy 3-64 |
TESTS |
7 |
140 |
19251200 |
|
|
162170570 |
MistaAsh |
B |
June 28, 2022, 7:11 p.m. |
OK |
PyPy 3-64 |
TESTS |
7 |
140 |
19865600 |
|
|
162153903 |
wazir90 |
B |
June 28, 2022, 4:48 p.m. |
OK |
PyPy 3-64 |
TESTS |
7 |
155 |
19353600 |
|
|
162183949 |
Codertang |
B |
June 28, 2022, 11:56 p.m. |
OK |
PyPy 3-64 |
TESTS |
7 |
171 |
19558400 |
|
|
162191371 |
Youarenotgood |
B |
June 29, 2022, 2:36 a.m. |
OK |
PyPy 3-64 |
TESTS |
7 |
171 |
19660800 |
|
|
162194634 |
congthanh123 |
B |
June 29, 2022, 3:33 a.m. |
OK |
PyPy 3-64 |
TESTS |
7 |
186 |
15462400 |
|
|
162187826 |
MuhammadAMMAR |
B |
June 29, 2022, 1:34 a.m. |
OK |
PyPy 3-64 |
TESTS |
7 |
187 |
18739200 |
|
|
162174241 |
Mad_Andrei |
B |
June 28, 2022, 8:01 p.m. |
OK |
Python 3 |
TESTS |
7 |
124 |
15667200 |
|
|
162200228 |
Dinesh_devanaboina |
B |
June 29, 2022, 5:02 a.m. |
OK |
Python 3 |
TESTS |
7 |
139 |
16076800 |
|
|
162186489 |
happywater |
B |
June 29, 2022, 1:05 a.m. |
OK |
Python 3 |
TESTS |
7 |
139 |
16076800 |
|
|
162163212 |
T.S.Joy |
B |
June 28, 2022, 6:01 p.m. |
OK |
Python 3 |
TESTS |
7 |
139 |
16076800 |
|
|
162174629 |
mikimikim |
B |
June 28, 2022, 8:08 p.m. |
OK |
Python 3 |
TESTS |
7 |
139 |
16179200 |
|
|
162203965 |
aswinva |
B |
June 29, 2022, 5:54 a.m. |
OK |
Python 3 |
TESTS |
7 |
140 |
15667200 |
|
|
162192292 |
hongrae331 |
B |
June 29, 2022, 2:53 a.m. |
OK |
Python 3 |
TESTS |
7 |
140 |
15667200 |
|
|
162193034 |
aniketk28 |
B |
June 29, 2022, 3:05 a.m. |
OK |
Python 3 |
TESTS |
7 |
155 |
15667200 |
|
|
162173405 |
r-tron18 |
B |
June 28, 2022, 7:49 p.m. |
OK |
Python 3 |
TESTS |
7 |
155 |
15667200 |
|
|
162184338 |
Maskur_ICT_MBSTU |
B |
June 29, 2022, 12:08 a.m. |
OK |
Python 3 |
TESTS |
7 |
155 |
15974400 |
|
|
162156762 |
kokkuri |
B |
June 28, 2022, 5:21 p.m. |
OK |
Ruby 3 |
TESTS |
7 |
483 |
19148800 |
|
|
162173125 |
Akash_123 |
B |
June 28, 2022, 7:46 p.m. |
OK |
Rust 2021 |
TESTS |
7 |
15 |
7884800 |
|
|
162164530 |
Akash_123 |
B |
June 28, 2022, 6:11 p.m. |
OK |
Rust 2021 |
TESTS |
7 |
31 |
7884800 |
|
|
remove filters
Back to search problems