Codeforces Round 887 (Div. 1)

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.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
1852 Codeforces Round 887 (Div. 1) FINISHED False 9000 41700299 July 23, 2023, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 1622 ) C Ina of the Mountain PROGRAMMING data structures dp greedy math

B'To prepare her "Takodachi" dumbo octopuses for world domination, Ninomae Ina 'nis, a.k.a. Ina of the Mountain, orders Hoshimachi Suisei to throw boulders at them. Ina asks you, Kiryu Coco, to help choose where the boulders are thrown. There are n octopuses on a single-file trail on Ina 's mountain, numbered 1, 2, ldots, n . The i -th octopus has a certain initial health value a_i , where 1 <= q a_i <= q k . Each boulder crushes consecutive octopuses with indexes l, l+1, ldots, r , where 1 <= q l <= q r <= q n . You can choose the numbers l and r arbitrarily for each boulder. For each boulder, the health value of each octopus the boulder crushes is reduced by 1 . However, as octopuses are immortal, once they reach a health value of 0 , they will immediately regenerate to a health value of k . Given the octopuses ' initial health values, find the minimum number of boulders that need to be thrown to make the health of all octopuses equal to k . Each test contains multiple test cases. The first line contains the number of test cases t ( 1 <= t <= 10^5 ). The 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 <= 10^9 ) xe2 x80 x93 the number of octopuses, and the upper bound of a octopus 's health value. The second line contains n integers a_1, a_2, ldots, a_n ( 1 <= a_i <= k ) xe2 x80 x93 the initial health values of the octopuses. It is guaranteed that the sum of n over all test cases does not exceed 2 cdot 10^5 . For each test case, output the minimum number of boulders that need to be thrown to make the health values of all octopuses equal to k . In the first test case, the minimum number of boulders thrown is 2 : In the second test case, the minimum number of boulders thrown is 4 . The [l,r] ranges are [1,7], [2, 6], [3, 5], [4, '...

Tutorials

Codeforces Round 887 (Div 1, Div 2) Tutorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
215259256 hos.lyric C July 23, 2023, 6:19 p.m. OK D TESTS 106 390 16281600
215245511 ITworker_Z C July 23, 2023, 4:43 p.m. OK GNU C++14 TESTS 106 46 5324800
215235542 jiangtaizhe001 C July 23, 2023, 4:06 p.m. OK GNU C++14 TESTS 106 109 18944000
215239866 yutabi C July 23, 2023, 4:21 p.m. OK GNU C++14 TESTS 106 124 1638400
215246491 harinboy C July 23, 2023, 4:47 p.m. OK GNU C++14 TESTS 106 124 3174400
215293225 clap C July 24, 2023, 3:07 a.m. OK GNU C++14 TESTS 106 124 4812800
215283777 yeminghan C July 24, 2023, 12:55 a.m. OK GNU C++14 TESTS 106 139 5836800
215246682 Iratis C July 23, 2023, 4:48 p.m. OK GNU C++14 TESTS 106 139 6348800
215227824 CJ_xde_lt C July 23, 2023, 3:42 p.m. OK GNU C++14 TESTS 106 140 5632000
215263908 liar_frisky C July 23, 2023, 7:06 p.m. OK GNU C++14 TESTS 106 140 15974400
215237856 jinqihao2026 C July 23, 2023, 4:14 p.m. OK GNU C++14 TESTS 106 155 6451200
215289269 11231123 C July 24, 2023, 2:17 a.m. OK GNU C++17 TESTS 106 124 2457600
215265160 Yzm007 C July 23, 2023, 7:23 p.m. OK GNU C++17 TESTS 106 124 2457600
215260516 Ant_Man C July 23, 2023, 6:31 p.m. OK GNU C++17 TESTS 106 124 2457600
215221354 yuto1115 C July 23, 2023, 3:25 p.m. OK GNU C++17 TESTS 106 124 2457600
215248400 Natsuzora C July 23, 2023, 4:54 p.m. OK GNU C++17 TESTS 106 124 3174400
215220423 liympanda C July 23, 2023, 3:23 p.m. OK GNU C++17 TESTS 106 124 3276800
215236087 pineapple_tree_34 C July 23, 2023, 4:08 p.m. OK GNU C++17 TESTS 106 124 4812800
215292728 Nson C July 24, 2023, 3:01 a.m. OK GNU C++17 TESTS 106 139 2457600
215287740 jhdonghj112 C July 24, 2023, 1:56 a.m. OK GNU C++17 TESTS 106 139 3993600
215232701 chaeyihwan C July 23, 2023, 3:56 p.m. OK GNU C++17 TESTS 106 139 4812800
215239914 Hackenbush C July 23, 2023, 4:21 p.m. OK GNU C++17 (64) TESTS 106 77 3993600
215231307 cxaphoenix C July 23, 2023, 3:52 p.m. OK GNU C++17 (64) TESTS 106 93 5836800
215239342 Kude C July 23, 2023, 4:19 p.m. OK GNU C++17 (64) TESTS 106 108 2969600
215217990 kotatsugame C July 23, 2023, 3:17 p.m. OK GNU C++17 (64) TESTS 106 108 3174400
215218361 hitonanode C July 23, 2023, 3:18 p.m. OK GNU C++17 (64) TESTS 106 108 3788800
215231797 YeongTree C July 23, 2023, 3:54 p.m. OK GNU C++17 (64) TESTS 106 108 3993600
215230553 minato C July 23, 2023, 3:50 p.m. OK GNU C++17 (64) TESTS 106 108 7475200
215223586 rniya C July 23, 2023, 3:30 p.m. OK GNU C++17 (64) TESTS 106 108 7475200
215294582 Karuna C July 24, 2023, 3:22 a.m. OK GNU C++17 (64) TESTS 106 109 2969600
215237912 MateoCV C July 23, 2023, 4:14 p.m. OK GNU C++17 (64) TESTS 106 109 5836800
215227528 shiomusubi496 C July 23, 2023, 3:41 p.m. OK GNU C++20 (64) TESTS 106 46 2867200
215219919 Sulfox C July 23, 2023, 3:21 p.m. OK GNU C++20 (64) TESTS 106 46 6860800
215273543 maxplus C July 23, 2023, 9:09 p.m. OK GNU C++20 (64) TESTS 106 62 2150400
215225751 dreamoon_love_AA C July 23, 2023, 3:36 p.m. OK GNU C++20 (64) TESTS 106 62 6348800
215213920 maspy C July 23, 2023, 3:08 p.m. OK GNU C++20 (64) TESTS 106 62 7475200
215282317 Fido_Puppy C July 24, 2023, 12:25 a.m. OK GNU C++20 (64) TESTS 106 77 2969600
215240585 BlueBottle C July 23, 2023, 4:24 p.m. OK GNU C++20 (64) TESTS 106 77 3788800
215292706 _Purslane_ C July 24, 2023, 3 a.m. OK GNU C++20 (64) TESTS 106 77 4198400
215263671 tfg C July 23, 2023, 7:03 p.m. OK GNU C++20 (64) TESTS 106 78 2150400
215278741 askd C July 23, 2023, 10:59 p.m. OK GNU C++20 (64) TESTS 106 78 2969600
215227595 Tlatoani C July 23, 2023, 3:41 p.m. OK Kotlin 1.6 TESTS 106 873 26521600
215236278 Hakiobo C July 23, 2023, 4:08 p.m. OK Kotlin 1.7 TESTS 106 607 43520000
215216743 conqueror_of_tourist C July 23, 2023, 3:14 p.m. OK PyPy 3-64 TESTS 106 265 30003200
215247353 delena0702 C July 23, 2023, 4:50 p.m. OK PyPy 3-64 TESTS 106 358 27852800
215261958 hxu10 C July 23, 2023, 6:44 p.m. OK PyPy 3-64 TESTS 106 358 30924800
215238596 toam C July 23, 2023, 4:16 p.m. OK PyPy 3-64 TESTS 106 374 36147200
215212981 chinerist C July 23, 2023, 3:06 p.m. OK PyPy 3-64 TESTS 106 404 33894400
215241926 tassei903 C July 23, 2023, 4:29 p.m. OK PyPy 3-64 TESTS 106 405 29081600

remove filters

Back to search problems