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 traps numbered from 1 to n . You will go through them one by one in order. The i -th trap deals a_i base damage to you. Instead of going through a trap, you can jump it over. You can jump over no more than k traps. If you jump over a trap, it does not deal any damage to you. But there is an additional rule: if you jump over a trap, all next traps damages increase by 1 (this is a bonus damage). Note that if you jump over a trap, you don't get any damage (neither base damage nor bonus damage). Also, the bonus damage stacks so, for example, if you go through a trap i with base damage a_i , and you have already jumped over 3 traps, you get (a_i + 3) damage. You have to find the minimal damage that it is possible to get if you are allowed to jump over no more than k traps. The input consists of multiple test cases. The first line contains a single integer t ( 1 <= t <= 100 ) -- the number of test cases. Description of the test cases follows. The first line of each test case contains two integers n and k ( 1 <= n <= 2 cdot 10^5 , 1 <= k <= n ) -- the number of traps and the number of jump overs that you are allowed to make. The second line of each test case contains n integers a_1, a_2, ldots, a_n ( 1 <= a_i <= 10^9 ) -- base damage values of all traps. 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 minimal total damage that it is possible to get if you are allowed to jump over no more than k traps. In the first test case it is allowed to jump over all traps and take 0 damage. In the second test case there are 5 ways to jump over some traps: Total damage: 5 + 10 + 11 + 5 = 31 . Total damage: underline{0} + (10 + 1) + (11 + 1) + (5 + 1) = 29 . Total damage: 5 + underline{0} + (11 + 1) + (5 "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
157743598 |
Bobocan |
D |
May 19, 2022, 7:26 p.m. |
OK |
GNU C11 |
TESTS |
77 |
62 |
8499200 |
|
1700 |
157757246 |
Milesian |
D |
May 20, 2022, 1:52 a.m. |
OK |
GNU C++14 |
TESTS |
77 |
77 |
1638400 |
|
1700 |
157760094 |
AIM-9M |
D |
May 20, 2022, 2:57 a.m. |
OK |
GNU C++14 |
TESTS |
77 |
78 |
819200 |
|
1700 |
157759796 |
psc233 |
D |
May 20, 2022, 2:51 a.m. |
OK |
GNU C++14 |
TESTS |
77 |
78 |
819200 |
|
1700 |
157752023 |
delai |
D |
May 19, 2022, 10:48 p.m. |
OK |
GNU C++14 |
TESTS |
77 |
78 |
819200 |
|
1700 |
157768105 |
duoluoluo |
D |
May 20, 2022, 5:24 a.m. |
OK |
GNU C++14 |
TESTS |
77 |
78 |
819200 |
|
1700 |
157765948 |
Arun_kumar_chawda |
D |
May 20, 2022, 4:50 a.m. |
OK |
GNU C++14 |
TESTS |
77 |
78 |
819200 |
|
1700 |
157755250 |
fengqiyuka |
D |
May 20, 2022, 12:49 a.m. |
OK |
GNU C++14 |
TESTS |
77 |
78 |
1638400 |
|
1700 |
157758866 |
Yuki991 |
D |
May 20, 2022, 2:30 a.m. |
OK |
GNU C++14 |
TESTS |
77 |
78 |
1638400 |
|
1700 |
157724257 |
wang_yue_xi |
D |
May 19, 2022, 4:22 p.m. |
OK |
GNU C++14 |
TESTS |
77 |
78 |
2662400 |
|
1700 |
157758965 |
1287971889 |
D |
May 20, 2022, 2:32 a.m. |
OK |
GNU C++14 |
TESTS |
77 |
78 |
2662400 |
|
1700 |
157767102 |
et3_tsy3.0 |
D |
May 20, 2022, 5:09 a.m. |
OK |
GNU C++17 |
TESTS |
77 |
46 |
1740800 |
|
1700 |
157768825 |
SiRiehn_nx |
D |
May 20, 2022, 5:36 a.m. |
OK |
GNU C++17 |
TESTS |
77 |
46 |
1740800 |
|
1700 |
157733279 |
TomoriNao |
D |
May 19, 2022, 5:45 p.m. |
OK |
GNU C++17 |
TESTS |
77 |
46 |
6348800 |
|
1700 |
157759906 |
jhc_123 |
D |
May 20, 2022, 2:53 a.m. |
OK |
GNU C++17 |
TESTS |
77 |
46 |
19251200 |
|
1700 |
157761645 |
hxsfw |
D |
May 20, 2022, 3:28 a.m. |
OK |
GNU C++17 |
TESTS |
77 |
62 |
1638400 |
|
1700 |
157767251 |
Abhinaba |
D |
May 20, 2022, 5:11 a.m. |
OK |
GNU C++17 |
TESTS |
77 |
78 |
819200 |
|
1700 |
157764579 |
chinaxszyx |
D |
May 20, 2022, 4:26 a.m. |
OK |
GNU C++17 |
TESTS |
77 |
78 |
1024000 |
|
1700 |
157758851 |
acwing_meow |
D |
May 20, 2022, 2:29 a.m. |
OK |
GNU C++17 |
TESTS |
77 |
78 |
1536000 |
|
1700 |
157755783 |
AhoCorasick |
D |
May 20, 2022, 1:07 a.m. |
OK |
GNU C++17 |
TESTS |
77 |
78 |
1638400 |
|
1700 |
157746597 |
new_account00 |
D |
May 19, 2022, 8:17 p.m. |
OK |
GNU C++17 |
TESTS |
77 |
78 |
1843200 |
|
1700 |
157757633 |
xiece666 |
D |
May 20, 2022, 2:01 a.m. |
OK |
GNU C++17 (64) |
TESTS |
77 |
31 |
1843200 |
|
1700 |
157763182 |
Terryjoy_fan |
D |
May 20, 2022, 4 a.m. |
OK |
GNU C++17 (64) |
TESTS |
77 |
62 |
819200 |
|
1700 |
157758064 |
lijiatu10086 |
D |
May 20, 2022, 2:11 a.m. |
OK |
GNU C++17 (64) |
TESTS |
77 |
62 |
819200 |
|
1700 |
157749116 |
Makcum888 |
D |
May 19, 2022, 9:16 p.m. |
OK |
GNU C++17 (64) |
TESTS |
77 |
62 |
819200 |
|
1700 |
157766259 |
ranni0225 |
D |
May 20, 2022, 4:55 a.m. |
OK |
GNU C++17 (64) |
TESTS |
77 |
62 |
1638400 |
|
1700 |
157769038 |
codertonk |
D |
May 20, 2022, 5:39 a.m. |
OK |
GNU C++17 (64) |
TESTS |
77 |
62 |
1638400 |
|
1700 |
157758735 |
azhe-no-hand |
D |
May 20, 2022, 2:27 a.m. |
OK |
GNU C++17 (64) |
TESTS |
77 |
62 |
1638400 |
|
1700 |
157758046 |
leo22 |
D |
May 20, 2022, 2:11 a.m. |
OK |
GNU C++17 (64) |
TESTS |
77 |
62 |
1638400 |
|
1700 |
157756023 |
Rick_GT |
D |
May 20, 2022, 1:16 a.m. |
OK |
GNU C++17 (64) |
TESTS |
77 |
62 |
1638400 |
|
1700 |
157734618 |
Kyooma |
D |
May 19, 2022, 5:51 p.m. |
OK |
GNU C++17 (64) |
TESTS |
77 |
62 |
2048000 |
|
1700 |
157756086 |
L1ngYu233 |
D |
May 20, 2022, 1:18 a.m. |
OK |
GNU C++20 (64) |
TESTS |
77 |
31 |
10035200 |
|
1700 |
157759651 |
xls_is_real_dd |
D |
May 20, 2022, 2:48 a.m. |
OK |
GNU C++20 (64) |
TESTS |
77 |
46 |
819200 |
|
1700 |
157759421 |
jaychentank |
D |
May 20, 2022, 2:42 a.m. |
OK |
GNU C++20 (64) |
TESTS |
77 |
46 |
819200 |
|
1700 |
157752825 |
lto5 |
D |
May 19, 2022, 11:21 p.m. |
OK |
GNU C++20 (64) |
TESTS |
77 |
46 |
819200 |
|
1700 |
157749821 |
kennyleet |
D |
May 19, 2022, 9:33 p.m. |
OK |
GNU C++20 (64) |
TESTS |
77 |
46 |
819200 |
|
1700 |
157760118 |
xuem7294 |
D |
May 20, 2022, 2:58 a.m. |
OK |
GNU C++20 (64) |
TESTS |
77 |
46 |
819200 |
|
1700 |
157764397 |
scholar101518 |
D |
May 20, 2022, 4:22 a.m. |
OK |
GNU C++20 (64) |
TESTS |
77 |
46 |
1638400 |
|
1700 |
157763983 |
ultimate_pal |
D |
May 20, 2022, 4:15 a.m. |
OK |
GNU C++20 (64) |
TESTS |
77 |
46 |
1638400 |
|
1700 |
157762976 |
uaena_mao |
D |
May 20, 2022, 3:56 a.m. |
OK |
GNU C++20 (64) |
TESTS |
77 |
46 |
1638400 |
|
1700 |
157766214 |
imalok10 |
D |
May 20, 2022, 4:55 a.m. |
OK |
GNU C++20 (64) |
TESTS |
77 |
46 |
1638400 |
|
1700 |
157737528 |
koqo |
D |
May 19, 2022, 6:12 p.m. |
OK |
Go |
TESTS |
77 |
202 |
9113600 |
|
1700 |
157739639 |
LXL |
D |
May 19, 2022, 6:33 p.m. |
OK |
Go |
TESTS |
77 |
530 |
43724800 |
|
1700 |
157767622 |
garg_lucifer |
D |
May 20, 2022, 5:17 a.m. |
OK |
Java 11 |
TESTS |
77 |
248 |
1536000 |
|
1700 |
157755294 |
PikaChu999 |
D |
May 20, 2022, 12:50 a.m. |
OK |
Java 11 |
TESTS |
77 |
249 |
1843200 |
|
1700 |
157765140 |
harshman_01 |
D |
May 20, 2022, 4:36 a.m. |
OK |
Java 11 |
TESTS |
77 |
311 |
6041600 |
|
1700 |
157770408 |
mayank.singh19 |
D |
May 20, 2022, 5:58 a.m. |
OK |
Java 11 |
TESTS |
77 |
312 |
5632000 |
|
1700 |
157751515 |
yudi23 |
D |
May 19, 2022, 10:27 p.m. |
OK |
Java 11 |
TESTS |
77 |
327 |
5632000 |
|
1700 |
157732935 |
ArchitSharma |
D |
May 19, 2022, 5:43 p.m. |
OK |
Java 11 |
TESTS |
77 |
327 |
29388800 |
|
1700 |
157741868 |
h_u_s_t_l_e_r |
D |
May 19, 2022, 7:02 p.m. |
OK |
Java 11 |
TESTS |
77 |
327 |
30105600 |
|
1700 |
157737241 |
h_u_s_t_l_e_r |
D |
May 19, 2022, 6:10 p.m. |
OK |
Java 11 |
TESTS |
77 |
343 |
31027200 |
|
1700 |
157747945 |
profchi |
D |
May 19, 2022, 8:46 p.m. |
OK |
Java 11 |
TESTS |
77 |
343 |
34918400 |
|
1700 |
157769631 |
step-off-bitch |
D |
May 20, 2022, 5:47 a.m. |
OK |
Java 11 |
TESTS |
77 |
358 |
5529600 |
|
1700 |
157760435 |
RetARDed1111 |
D |
May 20, 2022, 3:04 a.m. |
OK |
Java 8 |
TESTS |
77 |
171 |
5120000 |
|
1700 |
157768511 |
aryaman_571 |
D |
May 20, 2022, 5:31 a.m. |
OK |
Java 8 |
TESTS |
77 |
187 |
7168000 |
|
1700 |
157726088 |
kkkkush |
D |
May 19, 2022, 4:27 p.m. |
OK |
Java 8 |
TESTS |
77 |
280 |
34304000 |
|
1700 |
157763848 |
Sussykin |
D |
May 20, 2022, 4:13 a.m. |
OK |
Java 8 |
TESTS |
77 |
343 |
10547200 |
|
1700 |
157734000 |
ushikawa |
D |
May 19, 2022, 5:48 p.m. |
OK |
Java 8 |
TESTS |
77 |
343 |
27340800 |
|
1700 |
157744393 |
Tri14Bhar |
D |
May 19, 2022, 7:38 p.m. |
OK |
Java 8 |
TESTS |
77 |
389 |
19763200 |
|
1700 |
157761271 |
sankcan55 |
D |
May 20, 2022, 3:21 a.m. |
OK |
Java 8 |
TESTS |
77 |
405 |
0 |
|
1700 |
157724268 |
dyim0403 |
D |
May 19, 2022, 4:22 p.m. |
OK |
Java 8 |
TESTS |
77 |
405 |
38502400 |
|
1700 |
157748602 |
invincible777 |
D |
May 19, 2022, 9:02 p.m. |
OK |
Java 8 |
TESTS |
77 |
467 |
36454400 |
|
1700 |
157735955 |
_spiralJava_ |
D |
May 19, 2022, 6 p.m. |
OK |
Java 8 |
TESTS |
77 |
498 |
30822400 |
|
1700 |
157767042 |
sid9406 |
D |
May 20, 2022, 5:08 a.m. |
OK |
Kotlin 1.4 |
TESTS |
77 |
311 |
18944000 |
|
1700 |
157766678 |
Killer_No.47 |
D |
May 20, 2022, 5:02 a.m. |
OK |
MS C++ 2017 |
TESTS |
77 |
93 |
5632000 |
|
1700 |
157753796 |
hcp |
D |
May 20, 2022, midnight |
OK |
MS C++ 2017 |
TESTS |
77 |
109 |
8806400 |
|
1700 |
157726516 |
BusIgor |
D |
May 19, 2022, 4:29 p.m. |
OK |
MS C++ 2017 |
TESTS |
77 |
218 |
5939200 |
|
1700 |
157765340 |
fatant |
D |
May 20, 2022, 4:40 a.m. |
OK |
MS C++ 2017 |
TESTS |
77 |
233 |
8294400 |
|
1700 |
157726172 |
ItamarNir |
D |
May 19, 2022, 4:28 p.m. |
OK |
MS C++ 2017 |
TESTS |
77 |
234 |
5939200 |
|
1700 |
157734192 |
De_nis |
D |
May 19, 2022, 5:49 p.m. |
OK |
MS C++ 2017 |
TESTS |
77 |
234 |
6144000 |
|
1700 |
157765907 |
bhdtr |
D |
May 20, 2022, 4:49 a.m. |
OK |
MS C++ 2017 |
TESTS |
77 |
249 |
6758400 |
|
1700 |
157726704 |
arkshart2 |
D |
May 19, 2022, 4:29 p.m. |
OK |
MS C++ 2017 |
TESTS |
77 |
265 |
12697600 |
|
1700 |
157734156 |
1_2_3_4_5_9 |
D |
May 19, 2022, 5:49 p.m. |
OK |
PyPy 2 |
TESTS |
77 |
218 |
39936000 |
|
1700 |
157725304 |
ruimina |
D |
May 19, 2022, 4:25 p.m. |
OK |
PyPy 3 |
TESTS |
77 |
218 |
37171200 |
|
1700 |
157745021 |
MrDrogon |
D |
May 19, 2022, 7:49 p.m. |
OK |
PyPy 3 |
TESTS |
77 |
233 |
41881600 |
|
1700 |
157740056 |
MrDrogon |
D |
May 19, 2022, 6:38 p.m. |
OK |
PyPy 3 |
TESTS |
77 |
295 |
46592000 |
|
1700 |
157732816 |
abc_2002 |
D |
May 19, 2022, 5:43 p.m. |
OK |
PyPy 3 |
TESTS |
77 |
358 |
37478400 |
|
1700 |
157749130 |
zile151 |
D |
May 19, 2022, 9:16 p.m. |
OK |
PyPy 3 |
TESTS |
77 |
826 |
28876800 |
|
1700 |
157755207 |
ankan2526 |
D |
May 20, 2022, 12:48 a.m. |
OK |
PyPy 3 |
TESTS |
77 |
904 |
23859200 |
|
1700 |
157764547 |
_N_0_0_B_ |
D |
May 20, 2022, 4:26 a.m. |
OK |
PyPy 3-64 |
TESTS |
77 |
171 |
29491200 |
|
1700 |
157748534 |
ossau_guildo |
D |
May 19, 2022, 9 p.m. |
OK |
PyPy 3-64 |
TESTS |
77 |
171 |
31232000 |
|
1700 |
157756281 |
abhijeet.panihar.cse20 |
D |
May 20, 2022, 1:24 a.m. |
OK |
PyPy 3-64 |
TESTS |
77 |
202 |
62054400 |
|
1700 |
157748235 |
monsterrazzy |
D |
May 19, 2022, 8:52 p.m. |
OK |
PyPy 3-64 |
TESTS |
77 |
280 |
29491200 |
|
1700 |
157744356 |
aman404found |
D |
May 19, 2022, 7:37 p.m. |
OK |
PyPy 3-64 |
TESTS |
77 |
296 |
57651200 |
|
1700 |
157744330 |
aman404found |
D |
May 19, 2022, 7:37 p.m. |
OK |
PyPy 3-64 |
TESTS |
77 |
296 |
57753600 |
|
1700 |
157747579 |
beethoven97 |
D |
May 19, 2022, 8:37 p.m. |
OK |
PyPy 3-64 |
TESTS |
77 |
296 |
63692800 |
|
1700 |
157738650 |
pajenegod |
D |
May 19, 2022, 6:22 p.m. |
OK |
PyPy 3-64 |
TESTS |
77 |
311 |
51302400 |
|
1700 |
157744037 |
samchen123 |
D |
May 19, 2022, 7:33 p.m. |
OK |
PyPy 3-64 |
TESTS |
77 |
312 |
57241600 |
|
1700 |
157726277 |
Invinc3 |
D |
May 19, 2022, 4:28 p.m. |
OK |
PyPy 3-64 |
TESTS |
77 |
327 |
61747200 |
|
1700 |
157743823 |
Eldababa |
D |
May 19, 2022, 7:29 p.m. |
OK |
Python 3 |
TESTS |
77 |
296 |
21401600 |
|
1700 |
157751935 |
maxglo |
D |
May 19, 2022, 10:45 p.m. |
OK |
Python 3 |
TESTS |
77 |
327 |
16998400 |
|
1700 |
157763140 |
CodeLord1104 |
D |
May 20, 2022, 3:59 a.m. |
OK |
Python 3 |
TESTS |
77 |
373 |
16486400 |
|
1700 |
157743934 |
hannibal404 |
D |
May 19, 2022, 7:31 p.m. |
OK |
Python 3 |
TESTS |
77 |
483 |
26828800 |
|
1700 |
157749272 |
zile151 |
D |
May 19, 2022, 9:19 p.m. |
OK |
Python 3 |
TESTS |
77 |
514 |
27545600 |
|
1700 |
157749151 |
zile151 |
D |
May 19, 2022, 9:17 p.m. |
OK |
Python 3 |
TESTS |
77 |
545 |
26419200 |
|
1700 |
157728197 |
praditha_alwis |
D |
May 19, 2022, 4:33 p.m. |
OK |
Python 3 |
TESTS |
77 |
608 |
25600000 |
|
1700 |
157725002 |
notposeidon |
D |
May 19, 2022, 4:24 p.m. |
OK |
Python 3 |
TESTS |
77 |
623 |
31334400 |
|
1700 |
157768830 |
vp2002 |
D |
May 20, 2022, 5:36 a.m. |
OK |
Python 3 |
TESTS |
77 |
624 |
22016000 |
|
1700 |
157734171 |
akshaywairagade2 |
D |
May 19, 2022, 5:49 p.m. |
OK |
Python 3 |
TESTS |
77 |
654 |
29696000 |
|
1700 |
157766918 |
Spheniscine |
D |
May 20, 2022, 5:06 a.m. |
OK |
Rust 2021 |
TESTS |
77 |
46 |
5529600 |
|
1700 |
remove filters
Back to search problems