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 |
|---|---|---|---|---|---|---|
| 2108 | Codeforces Round 1022 (Div. 2) | FINISHED | False | 7200 | 30295523 | May 1, 2025, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 14566 ) | C | Neo's Escape | PROGRAMMING | data structures dsu graphs greedy implementation |
Neo wants to escape from the Matrix. In front of him are (n) buttons arranged in a row. Each button has a weight given by an integer: (a_1, a_2, \ldots, a_n). Neo is immobilized, but he can create and move clones. This means he can perform an unlimited number of actions of the following two types in any order: Create a clone in front of a specific button. Move an existing clone one position to the left or right. As soon as a clone is in front of another button that has not yet been pressed—regardless of whether he was created or moved — he immediately presses it. If the button has already been pressed, a clone does nothing — buttons can only be pressed once. For Neo to escape, he needs to press all the buttons in such an order that the sequence of their weights is non-increasing — that is, if (b_1, b_2, \ldots, b_n) are the weights of the buttons in the order they are pressed, then it must hold that (b_1 \geq b_2 \geq \cdots \geq b_n). Your task is to determine the minimum number of clones that Neo needs to create in order to press all the buttons in a valid order. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^4)). The description of the test cases follows. The first line of each test case contains one integer (n) ((1 \leq n \leq 2 \cdot 10^5)) — the number of buttons. The second line of each test case contains (n) integers (a_1, a_2, \ldots, a_n) ((1 \leq a_i \leq 10^9)) — the weights of the buttons. It is guaranteed that the sum of (n) over all test cases does not exceed (2 \cdot 10^5). For each test case, output one integer — the minimum number of clones that need to be created to press all the buttons in a valid order. In the first test case, Neo can act as follows: Create a clone in front of the fifth button (with weight (5)). Create a clone in front of the first button (with weight (4)). Move the second clone from the first butt |
| Codeforces Round 1022 Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 318057042 | Equinox_Ya | C | May 2, 2025, 3:14 a.m. | OK | C# 10 | TESTS | 21 | 296 | 11059200 | ||
| 318062328 | night_manager_0025 | C | May 2, 2025, 4:45 a.m. | OK | C++17 (GCC 7-32) | TESTS | 21 | 77 | 102400 | ||
| 318055739 | WCKing | C | May 2, 2025, 2:52 a.m. | OK | C++17 (GCC 7-32) | TESTS | 21 | 78 | 0 | ||
| 318043820 | svandich | C | May 1, 2025, 9:42 p.m. | OK | C++17 (GCC 7-32) | TESTS | 21 | 92 | 102400 | ||
| 318038290 | RaisaZaman | C | May 1, 2025, 8:09 p.m. | OK | C++17 (GCC 7-32) | TESTS | 21 | 93 | 0 | ||
| 318032246 | svandich | C | May 1, 2025, 6:53 p.m. | OK | C++17 (GCC 7-32) | TESTS | 21 | 93 | 0 | ||
| 318032137 | Asp1k | C | May 1, 2025, 6:52 p.m. | OK | C++17 (GCC 7-32) | TESTS | 21 | 93 | 0 | ||
| 318021051 | Eradax | C | May 1, 2025, 5:21 p.m. | OK | C++17 (GCC 7-32) | TESTS | 21 | 93 | 0 | ||
| 318018154 | Errors | C | May 1, 2025, 5:04 p.m. | OK | C++17 (GCC 7-32) | TESTS | 21 | 93 | 0 | ||
| 318015403 | Hassan_Rashed | C | May 1, 2025, 4:34 p.m. | OK | C++17 (GCC 7-32) | TESTS | 20 | 93 | 0 | ||
| 318012621 | sunny077 | C | May 1, 2025, 4:30 p.m. | OK | C++17 (GCC 7-32) | TESTS | 20 | 93 | 0 | ||
| 318053451 | Tri-sex | C | May 2, 2025, 2:07 a.m. | OK | C++20 (GCC 13-64) | TESTS | 21 | 77 | 0 | ||
| 318052066 | check_D | C | May 2, 2025, 1:37 a.m. | OK | C++20 (GCC 13-64) | TESTS | 21 | 77 | 0 | ||
| 318050226 | FuyouSky | C | May 2, 2025, 12:47 a.m. | OK | C++20 (GCC 13-64) | TESTS | 21 | 77 | 0 | ||
| 318049545 | pylons | C | May 2, 2025, 12:23 a.m. | OK | C++20 (GCC 13-64) | TESTS | 21 | 77 | 0 | ||
| 318020710 | susenyang | C | May 1, 2025, 5:19 p.m. | OK | C++20 (GCC 13-64) | TESTS | 21 | 77 | 0 | ||
| 318058246 | MoonLe | C | May 2, 2025, 3:35 a.m. | OK | C++20 (GCC 13-64) | TESTS | 21 | 77 | 102400 | ||
| 318057250 | Alasco | C | May 2, 2025, 3:18 a.m. | OK | C++20 (GCC 13-64) | TESTS | 21 | 77 | 102400 | ||
| 318056644 | Arman42 | C | May 2, 2025, 3:08 a.m. | OK | C++20 (GCC 13-64) | TESTS | 21 | 77 | 102400 | ||
| 318050002 | Nexus_Raphael | C | May 2, 2025, 12:40 a.m. | OK | C++20 (GCC 13-64) | TESTS | 21 | 77 | 102400 | ||
| 318039326 | youfail | C | May 1, 2025, 8:24 p.m. | OK | C++20 (GCC 13-64) | TESTS | 21 | 77 | 102400 | ||
| 318055757 | cooluo | C | May 2, 2025, 2:52 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 21 | 61 | 2969600 | ||
| 318056370 | 424479543 | C | May 2, 2025, 3:04 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 21 | 62 | 102400 | ||
| 318022435 | Memory_leak_ | C | May 1, 2025, 5:29 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 21 | 62 | 2150400 | ||
| 318053775 | while_zeze | C | May 2, 2025, 2:14 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 21 | 62 | 17920000 | ||
| 318065565 | aminjon__ | C | May 2, 2025, 5:29 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 21 | 77 | 0 | ||
| 318063483 | sed404 | C | May 2, 2025, 5:02 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 21 | 77 | 0 | ||
| 318061417 | hopskiprabbit | C | May 2, 2025, 4:29 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 21 | 77 | 0 | ||
| 318059409 | xinxiniii | C | May 2, 2025, 3:55 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 21 | 77 | 0 | ||
| 318054829 | FireworksT_T | C | May 2, 2025, 2:34 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 21 | 77 | 0 | ||
| 318041025 | mertokilla | C | May 1, 2025, 8:50 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 21 | 77 | 0 | ||
| 318034583 | NenadDapic | C | May 1, 2025, 7:20 p.m. | OK | FPC | TESTS | 21 | 93 | 819200 | ||
| 318007499 | ruban | C | May 1, 2025, 4:18 p.m. | OK | FPC | TESTS | 20 | 124 | 8499200 | ||
| 318008626 | Yang_T | C | May 1, 2025, 4:21 p.m. | OK | GNU C11 | TESTS | 20 | 108 | 921600 | ||
| 318022348 | 1435730 | C | May 1, 2025, 5:29 p.m. | OK | GNU C11 | TESTS | 21 | 124 | 3174400 | ||
| 318006950 | kienndh031106 | C | May 1, 2025, 4:17 p.m. | OK | GNU C11 | TESTS | 20 | 139 | 1638400 | ||
| 318011465 | tranquyetthang281 | C | May 1, 2025, 4:27 p.m. | OK | Go | TESTS | 20 | 93 | 11776000 | ||
| 318019601 | Transformer911 | C | May 1, 2025, 5:12 p.m. | OK | Go | TESTS | 21 | 171 | 6656000 | ||
| 318064969 | Dg10 | C | May 2, 2025, 5:22 a.m. | OK | Java 21 | TESTS | 21 | 281 | 1126400 | ||
| 318058057 | sulabhambule | C | May 2, 2025, 3:31 a.m. | OK | Java 21 | TESTS | 21 | 374 | 13414400 | ||
| 318013141 | UdayRajVadeghar | C | May 1, 2025, 4:31 p.m. | OK | Java 21 | TESTS | 20 | 452 | 8908800 | ||
| 318040022 | the_bigShort | C | May 1, 2025, 8:35 p.m. | OK | Java 21 | TESTS | 21 | 468 | 8499200 | ||
| 318031443 | sarthaKKharKa_18 | C | May 1, 2025, 6:45 p.m. | OK | Java 21 | TESTS | 21 | 468 | 33177600 | ||
| 318010199 | testtest111ksjfrdvn | C | May 1, 2025, 4:25 p.m. | OK | Java 21 | TESTS | 20 | 468 | 39526400 | ||
| 318029673 | redreoicy | C | May 1, 2025, 6:27 p.m. | OK | Java 21 | TESTS | 21 | 499 | 13312000 | ||
| 318010661 | Satyam9665 | C | May 1, 2025, 4:26 p.m. | OK | Java 21 | TESTS | 20 | 515 | 8294400 | ||
| 318039145 | jerdno | C | May 1, 2025, 8:22 p.m. | OK | Java 21 | TESTS | 21 | 515 | 22016000 | ||
| 318030826 | dusty.and.rusty | C | May 1, 2025, 6:39 p.m. | OK | Java 21 | TESTS | 21 | 530 | 19968000 | ||
| 318025694 | Pranav_45 | C | May 1, 2025, 5:53 p.m. | OK | Java 8 | TESTS | 21 | 202 | 8806400 | ||
| 318033394 | yashdhokia | C | May 1, 2025, 7:05 p.m. | OK | Java 8 | TESTS | 21 | 218 | 4710400 | ||
| 318053552 | baixuejava | C | May 2, 2025, 2:09 a.m. | OK | Java 8 | TESTS | 21 | 249 | 0 | ||
| 318053518 | baixuejava | C | May 2, 2025, 2:09 a.m. | OK | Java 8 | TESTS | 21 | 249 | 0 | ||
| 318009008 | xmjlove | C | May 1, 2025, 4:22 p.m. | OK | Java 8 | TESTS | 20 | 312 | 19763200 | ||
| 318029700 | redreoicy | C | May 1, 2025, 6:27 p.m. | OK | Java 8 | TESTS | 21 | 437 | 6451200 | ||
| 318046766 | harxhhhh | C | May 1, 2025, 10:53 p.m. | OK | Java 8 | TESTS | 21 | 468 | 0 | ||
| 318068091 | Mr.Curious | C | May 2, 2025, 5:58 a.m. | OK | Java 8 | TESTS | 21 | 499 | 0 | ||
| 318007546 | shiva.__.18 | C | May 1, 2025, 4:18 p.m. | OK | Java 8 | TESTS | 20 | 546 | 0 | ||
| 318062980 | kartik__sethi | C | May 2, 2025, 4:55 a.m. | OK | Java 8 | TESTS | 21 | 702 | 39526400 | ||
| 318042539 | Akiii_2023 | C | May 1, 2025, 9:18 p.m. | OK | PyPy 3 | TESTS | 21 | 296 | 14131200 | ||
| 318030451 | DocinhoS | C | May 1, 2025, 6:35 p.m. | OK | PyPy 3 | TESTS | 21 | 342 | 14540800 | ||
| 318030834 | pipylon | C | May 1, 2025, 6:39 p.m. | OK | PyPy 3 | TESTS | 21 | 452 | 18227200 | ||
| 318021404 | kavorka | C | May 1, 2025, 5:23 p.m. | OK | PyPy 3-64 | TESTS | 21 | 155 | 25600000 | ||
| 318053971 | ege_erdil | C | May 2, 2025, 2:18 a.m. | OK | PyPy 3-64 | TESTS | 21 | 155 | 29593600 | ||
| 318024465 | azerbenmed1730 | C | May 1, 2025, 5:44 p.m. | OK | PyPy 3-64 | TESTS | 21 | 156 | 30720000 | ||
| 318017687 | Pulkit_gupta | C | May 1, 2025, 5:02 p.m. | OK | PyPy 3-64 | TESTS | 20 | 171 | 26931200 | ||
| 318018837 | rabitee | C | May 1, 2025, 5:08 p.m. | OK | PyPy 3-64 | TESTS | 21 | 171 | 27136000 | ||
| 318051420 | gardengnome | C | May 2, 2025, 1:20 a.m. | OK | PyPy 3-64 | TESTS | 21 | 171 | 28057600 | ||
| 318013573 | gejageju | C | May 1, 2025, 4:31 p.m. | OK | PyPy 3-64 | TESTS | 20 | 186 | 23040000 | ||
| 318035487 | Androidus | C | May 1, 2025, 7:31 p.m. | OK | PyPy 3-64 | TESTS | 21 | 186 | 25907200 | ||
| 318008490 | ktthree | C | May 1, 2025, 4:21 p.m. | OK | PyPy 3-64 | TESTS | 20 | 186 | 29593600 | ||
| 318045251 | Kolya259 | C | May 1, 2025, 10:15 p.m. | OK | PyPy 3-64 | TESTS | 21 | 187 | 26931200 | ||
| 318056375 | ruhittanvir14 | C | May 2, 2025, 3:04 a.m. | OK | Python 3 | TESTS | 21 | 171 | 19763200 | ||
| 318018252 | matisyo | C | May 1, 2025, 5:04 p.m. | OK | Python 3 | TESTS | 21 | 171 | 26624000 | ||
| 318021880 | AggarwalRaghav | C | May 1, 2025, 5:26 p.m. | OK | Python 3 | TESTS | 21 | 171 | 26828800 | ||
| 318014907 | Chuba | C | May 1, 2025, 4:33 p.m. | OK | Python 3 | TESTS | 20 | 186 | 26521600 | ||
| 318019314 | amod_24 | C | May 1, 2025, 5:11 p.m. | OK | Python 3 | TESTS | 21 | 186 | 26931200 | ||
| 318068784 | mdolikahmed | C | May 2, 2025, 6:05 a.m. | OK | Python 3 | TESTS | 21 | 187 | 25907200 | ||
| 318045289 | Ethan_Hunt_2004 | C | May 1, 2025, 10:16 p.m. | OK | Python 3 | TESTS | 21 | 202 | 26726400 | ||
| 318054100 | a_failed_coder | C | May 2, 2025, 2:20 a.m. | OK | Python 3 | TESTS | 21 | 265 | 26726400 | ||
| 318042786 | maanasverma | C | May 1, 2025, 9:23 p.m. | OK | Python 3 | TESTS | 21 | 343 | 29491200 | ||
| 318012716 | sanidhyaky | C | May 1, 2025, 4:30 p.m. | OK | Python 3 | TESTS | 20 | 358 | 56320000 | ||
| 318012689 | paranoidGhost | C | May 1, 2025, 4:30 p.m. | OK | Rust 2021 | TESTS | 20 | 92 | 2560000 | ||
| 318056899 | rishendraT | C | May 2, 2025, 3:12 a.m. | OK | Rust 2021 | TESTS | 21 | 92 | 14131200 | ||
| 318054844 | Spheniscine | C | May 2, 2025, 2:35 a.m. | OK | Rust 2021 | TESTS | 21 | 108 | 1740800 | ||
| 318036944 | Antumbra01 | C | May 1, 2025, 7:50 p.m. | OK | Rust 2021 | TESTS | 21 | 124 | 13721600 | ||
| 318066081 | silicalet | C | May 2, 2025, 5:36 a.m. | OK | Rust 2021 | TESTS | 21 | 186 | 18022400 |
Back to search problems