Codeforces Round 987 (Div. 2)

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
2031 Codeforces Round 987 (Div. 2) FINISHED False 7200 44731523 Nov. 15, 2024, 12:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 9642 ) D Penchick and Desert Rabbit PROGRAMMING data structures dfs and similar dp dsu greedy two pointers

Dedicated to pushing himself to his limits, Penchick challenged himself to survive the midday sun in the Arabian Desert! While trekking along a linear oasis, Penchick spots a desert rabbit preparing to jump along a line of palm trees. There are (n) trees, each with a height denoted by (a_i). The rabbit can jump from the (i)-th tree to the (j)-th tree if exactly one of the following conditions is true: (j < i) and (a_j > a_i): the rabbit can jump backward to a taller tree. (j > i) and (a_j < a_i): the rabbit can jump forward to a shorter tree. For each (i) from (1) to (n), determine the maximum height among all trees that the rabbit can reach if it starts from the (i)-th tree. The first line contains the number of test cases (t) ((1 \le t \le 5 \cdot 10^5)). The description of the test cases follows. The first line of each test case contains a single integer (n) ((1 \leq n \leq 5 \cdot 10^5)) — the number of trees. The second line of each test case contains (n) integers (a_1, a_2, \ldots, a_n) ((1 \le a_i \le n)) — the height of the trees. It is guaranteed that the sum of (n) over all test cases does not exceed (5 \cdot 10^5). For each test case, output (n) integers. The (i)-th integer should contain the maximum height among all trees that the rabbit can reach if it starts from the (i)-th tree. In the first test case, the initial heights of trees are (a = 2, 3, 1, 4). If the rabbit starts from the first tree, it can jump to the third tree as (3 > 1) and (1 < 2). Then, the rabbit can jump to the second tree as (2 < 3) and (3 > 1). It can be proved that the rabbit cannot reach the fourth tree; hence, the maximum height of the tree that the rabbit can reach is (a_2 = 3). If the rabbit starts from the fourth tree, it does not need to jump anywhere as it is already at the highest tree. In the second test case, the rabbit can jump to the first

Tutorials

Codeforces Round 987 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
291664060 petrenslavik D Nov. 15, 2024, 3:48 p.m. OK C# 10 TESTS 30 1140 51302400
291689310 mban259 D Nov. 15, 2024, 6:02 p.m. OK C# 10 TESTS 32 1187 79155200
291742419 dorjderem D Nov. 16, 2024, 5:40 a.m. OK C# 10 TESTS 34 1593 69427200
291730733 Jerrycyx D Nov. 16, 2024, 3:13 a.m. OK C++17 (GCC 7-32) TESTS 34 203 15155200
291744628 EternityLove D Nov. 16, 2024, 6 a.m. OK C++17 (GCC 7-32) TESTS 34 217 8089600
291677689 lyrrr D Nov. 15, 2024, 4:55 p.m. OK C++17 (GCC 7-32) TESTS 32 218 8089600
291733965 liwenbo114514 D Nov. 16, 2024, 3:56 a.m. OK C++17 (GCC 7-32) TESTS 34 218 8089600
291730459 Analysisss D Nov. 16, 2024, 3:09 a.m. OK C++17 (GCC 7-32) TESTS 34 218 8089600
291653534 Atom_Hoang D Nov. 15, 2024, 2:27 p.m. OK C++17 (GCC 7-32) TESTS 30 233 4096000
291719430 yeyou26 D Nov. 15, 2024, 11:44 p.m. OK C++17 (GCC 7-32) TESTS 33 233 8089600
291735877 anmattroi D Nov. 16, 2024, 4:23 a.m. OK C++17 (GCC 7-32) TESTS 34 233 8089600
291731214 xlab D Nov. 16, 2024, 3:19 a.m. OK C++17 (GCC 7-32) TESTS 34 233 8089600
291653279 Raigty D Nov. 15, 2024, 2:27 p.m. OK C++17 (GCC 7-32) TESTS 30 233 8294400
291740229 xiao_zong85 D Nov. 16, 2024, 5:18 a.m. OK C++20 (GCC 13-64) TESTS 34 156 4096000
291674790 xiaozong855 D Nov. 15, 2024, 4:42 p.m. OK C++20 (GCC 13-64) TESTS 32 171 4096000
291740791 bbyyd D Nov. 16, 2024, 5:24 a.m. OK C++20 (GCC 13-64) TESTS 34 171 10035200
291744056 Xx_star D Nov. 16, 2024, 5:54 a.m. OK C++20 (GCC 13-64) TESTS 34 171 10035200
291723483 byxxx D Nov. 16, 2024, 1:11 a.m. OK C++20 (GCC 13-64) TESTS 33 171 12083200
291741328 Darkmastergat D Nov. 16, 2024, 5:29 a.m. OK C++20 (GCC 13-64) TESTS 34 186 10035200
291653335 MajorLenox D Nov. 15, 2024, 2:27 p.m. OK C++20 (GCC 13-64) TESTS 30 187 2457600
291677060 kaitou1k41i2d D Nov. 15, 2024, 4:52 p.m. OK C++20 (GCC 13-64) TESTS 32 187 4403200
291666249 fishcathu. D Nov. 15, 2024, 3:59 p.m. OK C++20 (GCC 13-64) TESTS 30 187 6041600
291721828 Zvezdy D Nov. 16, 2024, 12:51 a.m. OK C++20 (GCC 13-64) TESTS 33 187 6041600
291655349 zhangjiale D Nov. 15, 2024, 2:31 p.m. OK C++23 (GCC 14-64, msys2) TESTS 30 140 62566400
291732154 Zhang_Wenjie D Nov. 16, 2024, 3:32 a.m. OK C++23 (GCC 14-64, msys2) TESTS 34 156 8089600
291730395 ssk_I D Nov. 16, 2024, 3:08 a.m. OK C++23 (GCC 14-64, msys2) TESTS 34 171 8089600
291654450 dagejiaoxian. D Nov. 15, 2024, 2:29 p.m. OK C++23 (GCC 14-64, msys2) TESTS 30 186 10035200
291735421 RomalTerix D Nov. 16, 2024, 4:16 a.m. OK C++23 (GCC 14-64, msys2) TESTS 34 186 16076800
291735544 RomalTerix D Nov. 16, 2024, 4:18 a.m. OK C++23 (GCC 14-64, msys2) TESTS 34 186 16076800
291727298 TtCF1302 D Nov. 16, 2024, 2:22 a.m. OK C++23 (GCC 14-64, msys2) TESTS 33 186 16076800
291733350 ZHANGGUIZHI D Nov. 16, 2024, 3:48 a.m. OK C++23 (GCC 14-64, msys2) TESTS 34 187 8089600
291743515 Wi1l_ D Nov. 16, 2024, 5:50 a.m. OK C++23 (GCC 14-64, msys2) TESTS 34 187 12083200
291718500 zaii D Nov. 15, 2024, 11:15 p.m. OK C++23 (GCC 14-64, msys2) TESTS 33 202 8089600
291742470 dorjderem D Nov. 16, 2024, 5:40 a.m. OK C# 8 TESTS 34 1671 69222400
291738050 sleepntsheep D Nov. 16, 2024, 4:53 a.m. OK GNU C11 TESTS 34 2468 37068800
291700228 yashjaiswal2509 D Nov. 15, 2024, 7:24 p.m. OK Java 21 TESTS 33 468 10956800
291680208 Soumadip_Mishra D Nov. 15, 2024, 5:10 p.m. OK Java 21 TESTS 32 562 8908800
291709782 PlayDate D Nov. 15, 2024, 8:56 p.m. OK Java 21 TESTS 33 609 10752000
291652428 ykgupta2411 D Nov. 15, 2024, 2:25 p.m. OK Java 21 TESTS 30 686 25088000
291652661 polsage D Nov. 15, 2024, 2:25 p.m. OK Java 21 TESTS 30 842 45977600
291680538 testtest111ksjfrdvn D Nov. 15, 2024, 5:12 p.m. OK Java 21 TESTS 32 874 77824000
291655811 sahasrad D Nov. 15, 2024, 2:32 p.m. OK Java 21 TESTS 30 1062 42496000
291692986 akshatsaxena552004.ss D Nov. 15, 2024, 6:26 p.m. OK Java 21 TESTS 32 1171 69939200
291677412 testtest111ksjfrdvn D Nov. 15, 2024, 4:54 p.m. OK Java 21 TESTS 32 1812 72089600
291680079 testtest111ksjfrdvn D Nov. 15, 2024, 5:09 p.m. OK Java 21 TESTS 32 1858 77619200
291662660 InfinityX D Nov. 15, 2024, 3:42 p.m. OK Java 8 TESTS 30 374 16896000
291662968 congege D Nov. 15, 2024, 3:43 p.m. OK Java 8 TESTS 30 374 26419200
291655847 mohit458 D Nov. 15, 2024, 2:32 p.m. OK Java 8 TESTS 30 437 16793600
291652304 yimLo D Nov. 15, 2024, 2:24 p.m. OK Java 8 TESTS 30 562 50380800
291665774 dauletomarov1130 D Nov. 15, 2024, 3:57 p.m. OK Java 8 TESTS 30 2405 0
291671267 bnmanubharadwaj D Nov. 15, 2024, 4:26 p.m. OK Node.js TESTS 31 499 88268800
291653169 Gaurav1 D Nov. 15, 2024, 2:26 p.m. OK PyPy 2 TESTS 30 2421 67891200
291717735 alexwice D Nov. 15, 2024, 10:54 p.m. OK PyPy 3-64 TESTS 33 343 69222400
291711641 RobinFromTheHood D Nov. 15, 2024, 9:19 p.m. OK PyPy 3-64 TESTS 33 405 64716800
291719469 rank007 D Nov. 15, 2024, 11:46 p.m. OK PyPy 3-64 TESTS 33 406 62156800
291715537 Povolotsky D Nov. 15, 2024, 10:12 p.m. OK PyPy 3-64 TESTS 33 436 60313600
291716503 Povolotsky D Nov. 15, 2024, 10:27 p.m. OK PyPy 3-64 TESTS 33 437 60416000
291704091 balalm10 D Nov. 15, 2024, 7:57 p.m. OK PyPy 3-64 TESTS 33 437 62976000
291707993 sksshivam007 D Nov. 15, 2024, 8:36 p.m. OK PyPy 3-64 TESTS 33 437 78540800
291652873 smilences D Nov. 15, 2024, 2:26 p.m. OK PyPy 3-64 TESTS 30 452 53452800
291693639 RobinFromTheHood D Nov. 15, 2024, 6:32 p.m. OK PyPy 3-64 TESTS 32 468 65536000
291743397 iygav1238 D Nov. 16, 2024, 5:49 a.m. OK PyPy 3-64 TESTS 34 499 63385600
291744842 binxoc D Nov. 16, 2024, 6:02 a.m. OK Python 3 TESTS 34 2124 95846400
291718557 kingcabrams D Nov. 15, 2024, 11:17 p.m. OK Rust 2021 TESTS 33 327 4300800
291717224 Hyrulia D Nov. 15, 2024, 10:41 p.m. OK Rust 2021 TESTS 33 1061 32460800
291690702 Allergy527 D Nov. 15, 2024, 6:11 p.m. OK Rust 2021 TESTS 32 1093 7270400
291667807 ArnedeB D Nov. 15, 2024, 4:08 p.m. OK Rust 2021 TESTS 31 1140 17817600
291668891 Allergy527 D Nov. 15, 2024, 4:14 p.m. OK Rust 2021 TESTS 31 1171 7782400
291708181 Cheshulko D Nov. 15, 2024, 8:38 p.m. OK Rust 2021 TESTS 33 1249 34508800

remove filters

Back to search problems