Codeforces Round 1083 (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
2205 Codeforces Round 1083 (Div. 2) FINISHED False 9000 4289123 Feb. 26, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 4713 ) D Simons and Beating Peaks PROGRAMMING data structures divide and conquer dp greedy implementation trees

We call an array (b) of length (m) cool if and only if: There exists no index (i) ((1 \lt i \lt m)) such that (b_i=\max(\{b_{i-1}, b_i, b_{i+1}\})). Simons has an array (a) of size (n). Initially, the array is a permutation(^{\text{∗}}). He must perform the following operation until the array is cool : Choose an index (i) ((1 \lt i \lt n)) such that (a_i=\max(\{a_{i-1}, a_i, a_{i+1}\})). Then, he can remove either (a_{i-1}) or (a_{i+1}) from the array. After removal, a gap appears in the array, and the left and right sides of the gap will be rejoined. Find the minimum number of operations for Simons to perform. (^{\text{∗}})A permutation of length (n) is an array consisting of (n) distinct integers from (1) to (n) in arbitrary order. For example, (2,3,1,5,4) is a permutation, but (1,2,2) is not a permutation ((2) appears twice in the array), and (1,3,4) is also not a permutation ((n=3) but there is (4) in the array). Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 5\cdot 10^4)). The description of the test cases follows. The first line contains an integer (n) ((3\le n\le 5\cdot 10^5)) — the size of (a). The second line contains (n) integers (a_1,a_2,\ldots,a_n) ((1\le a_i\le n), all (a_i)-s are distinct) — the array Simons has initially. It is guaranteed that the sum of (n) over all test cases does not exceed (5\cdot 10^5). For each test case, print a single integer — the minimum number of operations for Simons to perform. In the first test case, the array is cool initially, so Simons can't perform any operation. The answer is (0). In the second test case, Simons can perform as follows: Choose index (3), because (a_3=\max(\{a_2,a_3,a_4\})). Then, he removes (a_{2}) from the array. The array becomes (4,3,2,5). We can see the array is

Tutorials

Tutorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
364527110 _liujy D Feb. 26, 2026, 3:59 p.m. OK C++17 (GCC 7-32) TESTS 25 93 11059200
364527614 stuart220_chen D Feb. 26, 2026, 4:01 p.m. OK C++17 (GCC 7-32) TESTS 25 93 14336000
364577312 linruier D Feb. 27, 2026, 2:06 a.m. OK C++17 (GCC 7-32) TESTS 25 125 6144000
364535624 fakeapple D Feb. 26, 2026, 4:34 p.m. OK C++17 (GCC 7-32) TESTS 25 125 7372800
364534847 LiFeiYu D Feb. 26, 2026, 4:31 p.m. OK C++17 (GCC 7-32) TESTS 25 125 10035200
364532696 ABHIx1289 D Feb. 26, 2026, 4:21 p.m. OK C++17 (GCC 7-32) TESTS 25 140 2150400
364583404 warbubbles D Feb. 27, 2026, 4 a.m. OK C++17 (GCC 7-32) TESTS 25 140 2457600
364536794 jonatas57 D Feb. 26, 2026, 4:40 p.m. OK C++17 (GCC 7-32) TESTS 25 140 2457600
364527115 snailkim D Feb. 26, 2026, 3:59 p.m. OK C++17 (GCC 7-32) TESTS 25 140 6144000
364535510 -all-is-greedy- D Feb. 26, 2026, 4:34 p.m. OK C++17 (GCC 7-32) TESTS 25 140 6246400
364529673 WhoAmIFooling D Feb. 26, 2026, 4:09 p.m. OK C++20 (GCC 13-64) TESTS 25 62 16281600
364527087 hexahydride D Feb. 26, 2026, 3:59 p.m. OK C++20 (GCC 13-64) TESTS 25 78 17305600
364540857 threethreetwothree D Feb. 26, 2026, 4:58 p.m. OK C++20 (GCC 13-64) TESTS 25 93 20480000
364582968 yqr D Feb. 27, 2026, 3:53 a.m. OK C++20 (GCC 13-64) TESTS 25 93 70451200
364551675 impbz D Feb. 26, 2026, 6:46 p.m. OK C++20 (GCC 13-64) TESTS 25 109 11468800
364529250 Marytz D Feb. 26, 2026, 4:07 p.m. OK C++20 (GCC 13-64) TESTS 25 125 2252800
364525061 Xh_QwQ D Feb. 26, 2026, 3:52 p.m. OK C++20 (GCC 13-64) TESTS 25 125 2457600
364553903 Vanea D Feb. 26, 2026, 7:10 p.m. OK C++20 (GCC 13-64) TESTS 25 125 2457600
364579690 daniel_xue D Feb. 27, 2026, 2:52 a.m. OK C++20 (GCC 13-64) TESTS 25 125 2560000
364525082 vesitika D Feb. 26, 2026, 3:52 p.m. OK C++20 (GCC 13-64) TESTS 25 125 2867200
364526272 va1bh3v D Feb. 26, 2026, 3:56 p.m. OK C++23 (GCC 14-64, msys2) TESTS 25 109 2252800
364562585 istiaque007 D Feb. 26, 2026, 8:48 p.m. OK C++23 (GCC 14-64, msys2) TESTS 25 109 2560000
364552809 hs0ni D Feb. 26, 2026, 6:59 p.m. OK C++23 (GCC 14-64, msys2) TESTS 25 109 4608000
364574864 HurtinLuis D Feb. 27, 2026, 1:02 a.m. OK C++23 (GCC 14-64, msys2) TESTS 25 109 6246400
364550634 zihuata_nejo D Feb. 26, 2026, 6:34 p.m. OK C++23 (GCC 14-64, msys2) TESTS 25 109 6451200
364588428 Ecrain D Feb. 27, 2026, 5:29 a.m. OK C++23 (GCC 14-64, msys2) TESTS 25 109 13004800
364565734 IAmTiredAndSleepy D Feb. 26, 2026, 9:31 p.m. OK C++23 (GCC 14-64, msys2) TESTS 25 109 39526400
364541005 thehav0k D Feb. 26, 2026, 4:58 p.m. OK C++23 (GCC 14-64, msys2) TESTS 25 125 2150400
364577679 Yeqix D Feb. 27, 2026, 2:14 a.m. OK C++23 (GCC 14-64, msys2) TESTS 25 125 2560000
364558629 cHarLie9 D Feb. 26, 2026, 8:03 p.m. OK C++23 (GCC 14-64, msys2) TESTS 25 125 3276800
364534813 dhiraj_pgcat D Feb. 26, 2026, 4:31 p.m. OK GNU C11 TESTS 25 234 12083200
364536488 actualtsg D Feb. 26, 2026, 4:38 p.m. OK GNU C11 TESTS 25 250 11264000
364533318 pengin_2000 D Feb. 26, 2026, 4:24 p.m. OK GNU C11 TESTS 25 328 30105600
364538822 eycia D Feb. 26, 2026, 4:49 p.m. OK Go TESTS 25 171 53862400
364522959 timode-6 D Feb. 26, 2026, 3:45 p.m. OK Go TESTS 25 234 28262400
364522089 GreedyProof D Feb. 26, 2026, 3:43 p.m. OK Go TESTS 25 265 29184000
364527964 parmarmeet603 D Feb. 26, 2026, 4:02 p.m. OK Java 21 TESTS 25 265 8192000
364540397 UlaanBatat D Feb. 26, 2026, 4:56 p.m. OK Java 21 TESTS 25 281 6246400
364527349 BiggestFish06 D Feb. 26, 2026, 4 p.m. OK Java 21 TESTS 25 296 17715200
364542242 ziko_ahmed D Feb. 26, 2026, 5:03 p.m. OK Java 21 TESTS 25 359 12492800
364523270 vineetiwari D Feb. 26, 2026, 3:46 p.m. OK Java 21 TESTS 25 375 12800000
364532191 maruthipratap D Feb. 26, 2026, 4:19 p.m. OK Java 21 TESTS 25 375 22220800
364526992 arpite D Feb. 26, 2026, 3:59 p.m. OK Java 21 TESTS 25 375 25497600
364537705 prathamesh_lakhapati D Feb. 26, 2026, 4:44 p.m. OK Java 21 TESTS 25 390 9318400
364529489 the_atul_gour D Feb. 26, 2026, 4:08 p.m. OK Java 21 TESTS 25 390 12083200
364526020 Snigdha67 D Feb. 26, 2026, 3:55 p.m. OK Java 21 TESTS 25 390 14028800
364524955 ayushiagrawal0502 D Feb. 26, 2026, 3:52 p.m. OK Java 8 TESTS 25 265 17612800
364531117 Vivek_Shahi D Feb. 26, 2026, 4:15 p.m. OK Java 8 TESTS 25 265 17715200
364531483 divyansh515 D Feb. 26, 2026, 4:16 p.m. OK Java 8 TESTS 25 359 100454400
364546696 kevin_0911 D Feb. 26, 2026, 5:59 p.m. OK Java 8 TESTS 25 453 34816000
364535650 kevin_0911 D Feb. 26, 2026, 4:35 p.m. OK Java 8 TESTS 25 562 17920000
364585150 abhishek1445 D Feb. 27, 2026, 4:36 a.m. OK Java 8 TESTS 25 1000 17817600
364556828 xxxtentaclez D Feb. 26, 2026, 7:43 p.m. OK Kotlin 2.2 TESTS 25 1859 163123200
364536695 ctrlaltdefeat__ D Feb. 26, 2026, 4:39 p.m. OK Node.js TESTS 25 296 80384000
364529770 kumoRin D Feb. 26, 2026, 4:09 p.m. OK Node.js TESTS 25 484 84377600
364537679 chinesedfan D Feb. 26, 2026, 4:44 p.m. OK Node.js TESTS 25 562 48025600
364563843 reemzz D Feb. 26, 2026, 9:04 p.m. OK PyPy 2 TESTS 25 328 35328000
364530455 sharokku D Feb. 26, 2026, 4:12 p.m. OK PyPy 3 TESTS 25 515 37888000
364589819 PrathamB_math D Feb. 27, 2026, 5:49 a.m. OK PyPy 3 TESTS 25 703 41676800
364528067 raghav13aggarwal03 D Feb. 26, 2026, 4:03 p.m. OK PyPy 3 TESTS 25 796 43417600
364534054 Kandarp D Feb. 26, 2026, 4:27 p.m. OK PyPy 3 TESTS 25 812 119193600
364538609 Swear2go2sleepzZearly2mr D Feb. 26, 2026, 4:48 p.m. OK PyPy 3-64 TESTS 25 218 60313600
364553837 akane646 D Feb. 26, 2026, 7:09 p.m. OK PyPy 3-64 TESTS 25 218 65228800
364525824 Ajeesh_Sunil D Feb. 26, 2026, 3:54 p.m. OK PyPy 3-64 TESTS 25 234 61132800
364538190 vivekyarra D Feb. 26, 2026, 4:46 p.m. OK PyPy 3-64 TESTS 25 250 54886400
364534027 Akshar_7 D Feb. 26, 2026, 4:27 p.m. OK PyPy 3-64 TESTS 25 250 56729600
364522560 gameon030609 D Feb. 26, 2026, 3:44 p.m. OK PyPy 3-64 TESTS 25 250 60108800
364549392 jigitmax D Feb. 26, 2026, 6:22 p.m. OK PyPy 3-64 TESTS 25 250 60313600
364522322 mohantsk381 D Feb. 26, 2026, 3:43 p.m. OK PyPy 3-64 TESTS 25 250 66662400
364538918 biniyamnegasa D Feb. 26, 2026, 4:49 p.m. OK PyPy 3-64 TESTS 25 265 55500800
364533086 Cenix820 D Feb. 26, 2026, 4:23 p.m. OK PyPy 3-64 TESTS 25 265 60518400
364524235 Jimanbanashi D Feb. 26, 2026, 3:49 p.m. OK Python 2 TESTS 25 1656 48128000
364527574 kit27.am08 D Feb. 26, 2026, 4:01 p.m. OK Python 3 TESTS 25 343 41574400
364548991 tour1st_ D Feb. 26, 2026, 6:19 p.m. OK Python 3 TESTS 25 468 75673600
364527197 sn2008 D Feb. 26, 2026, 3:59 p.m. OK Python 3 TESTS 25 562 69529600
364533366 amod_24 D Feb. 26, 2026, 4:24 p.m. OK Python 3 TESTS 25 609 54681600
364536709 Nikrien D Feb. 26, 2026, 4:39 p.m. OK Python 3 TESTS 25 609 102809600
364526158 mannerithvik708 D Feb. 26, 2026, 3:56 p.m. OK Python 3 TESTS 25 671 74444800
364540100 Abhi-2006 D Feb. 26, 2026, 4:55 p.m. OK Python 3 TESTS 25 687 139059200
364524679 anirudh_08 D Feb. 26, 2026, 3:51 p.m. OK Python 3 TESTS 25 718 82329600
364541803 Monish2000 D Feb. 26, 2026, 5:01 p.m. OK Python 3 TESTS 25 812 73625600
364522601 lRaml D Feb. 26, 2026, 3:44 p.m. OK Python 3 TESTS 25 906 53248000
364589558 IKUN_111 D Feb. 27, 2026, 5:45 a.m. OK Rust 2024 TESTS 25 78 59801600
364584958 IKUN_111 D Feb. 27, 2026, 4:32 a.m. OK Rust 2024 TESTS 25 78 77824000
364524763 aryandadwal616 D Feb. 26, 2026, 3:51 p.m. OK Rust 2024 TESTS 25 109 68403200
364589026 IKUN_111 D Feb. 27, 2026, 5:38 a.m. OK Rust 2024 TESTS 25 109 89600000
364524581 my_bloody_valentine D Feb. 26, 2026, 3:50 p.m. OK Rust 2024 TESTS 25 234 30822400
364536499 ymy202602 D Feb. 26, 2026, 4:38 p.m. OK Scala TESTS 25 453 5529600

remove filters

Back to search problems