Codeforces Round 1057 (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
2153 Codeforces Round 1057 (Div. 2) FINISHED False 8100 16298723 Oct. 10, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 6246 ) D Not Alone PROGRAMMING dp implementation

A circular array (b) of length (m) is nice if every element has at least one adjacent element(^{\text{∗}}) that is equal to it. Formally, for every (1\le i\le m), at least one of the following holds: (b_i = b_{(i+m-2)\bmod m\;+1}), or (b_i = b_{i\bmod m\;+1}), where (x \bmod y) denotes the remainder from dividing (x) by (y). You are given a circular array (a) of length (n). In one operation, you may increase or decrease any element of (a) by (1). Your task is to determine the minimum number of operations required to make array (a) nice. More formally, find the minimum value of (\sum_{i=1}^n |b_i - a_i|) among all nice circular arrays (b) of length (n). (^{\text{∗}})In a circular array of length (m): For each index (2\le i\le m - 1), the element at index (i) is adjacent to the elements at indices (i - 1) and (i + 1). The element at index (1) is adjacent to the elements at indices (2) and (m). The element at index (m) is adjacent to the elements at indices (m - 1) and (1). 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 a single integer (n) ((3\le n\le 2\cdot 10^5)) — the length of the circular array (a). The second line of each test case contains (n) integers (a_1, a_2, \ldots, a_n) ((1\le a_i\le 10^9)) — the elements of the circular array (a). 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 representing the minimum number of operations required to make array (a) nice. In the first test case, all elements of (a) are equal. Therefore, the circular array (a) is already nice and no operations are required. In the second test case, we can perform the following

Tutorials

Codeforces Round 1057 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
343059740 Tian_Ming_Yo D Oct. 11, 2025, 3:15 a.m. OK C++17 (GCC 7-32) TESTS 26 93 0
343050035 viobow D Oct. 10, 2025, 11:32 p.m. OK C++17 (GCC 7-32) TESTS 26 93 4812800
343067932 Adityarawat355 D Oct. 11, 2025, 5:02 a.m. OK C++17 (GCC 7-32) TESTS 26 93 6041600
343049191 Heman10x D Oct. 10, 2025, 11:07 p.m. OK C++17 (GCC 7-32) TESTS 26 108 1024000
343052665 2004rijukarmakar D Oct. 11, 2025, 12:55 a.m. OK C++17 (GCC 7-32) TESTS 26 108 6041600
343010094 sweetwibu2k8 D Oct. 10, 2025, 4:38 p.m. OK C++17 (GCC 7-32) TESTS 26 108 24064000
343069839 xz7517 D Oct. 11, 2025, 5:21 a.m. OK C++17 (GCC 7-32) TESTS 26 109 0
343064313 zzwwxx D Oct. 11, 2025, 4:22 a.m. OK C++17 (GCC 7-32) TESTS 26 109 0
343057624 chaitanya_2408 D Oct. 11, 2025, 2:42 a.m. OK C++17 (GCC 7-32) TESTS 26 109 0
343055172 Liu_Rui D Oct. 11, 2025, 1:56 a.m. OK C++17 (GCC 7-32) TESTS 26 109 0
343063207 Everly_Galahad D Oct. 11, 2025, 4:07 a.m. OK C++20 (GCC 13-64) TESTS 26 78 0
343061139 yuki_keshiki D Oct. 11, 2025, 3:36 a.m. OK C++20 (GCC 13-64) TESTS 26 78 0
343065647 50_yxs D Oct. 11, 2025, 4:39 a.m. OK C++20 (GCC 13-64) TESTS 26 78 102400
343051244 dev_cse D Oct. 11, 2025, 12:15 a.m. OK C++20 (GCC 13-64) TESTS 26 78 102400
343051058 dev_cse D Oct. 11, 2025, 12:07 a.m. OK C++20 (GCC 13-64) TESTS 26 78 102400
343060948 Ichinoseyang D Oct. 11, 2025, 3:33 a.m. OK C++20 (GCC 13-64) TESTS 26 78 4198400
343059910 Shepherdz D Oct. 11, 2025, 3:17 a.m. OK C++20 (GCC 13-64) TESTS 26 78 4198400
343070031 SuitokuinTenmu D Oct. 11, 2025, 5:24 a.m. OK C++20 (GCC 13-64) TESTS 26 78 4915200
343060843 divyanshthakur594 D Oct. 11, 2025, 3:32 a.m. OK C++20 (GCC 13-64) TESTS 26 78 6041600
343064983 dinosaur7 D Oct. 11, 2025, 4:30 a.m. OK C++20 (GCC 13-64) TESTS 26 92 0
343071613 BlazeH D Oct. 11, 2025, 5:39 a.m. OK C++23 (GCC 14-64, msys2) TESTS 26 62 3481600
343054905 _clint D Oct. 11, 2025, 1:50 a.m. OK C++23 (GCC 14-64, msys2) TESTS 26 77 0
343072406 jianjianj D Oct. 11, 2025, 5:46 a.m. OK C++23 (GCC 14-64, msys2) TESTS 26 77 102400
343063308 ReShining D Oct. 11, 2025, 4:08 a.m. OK C++23 (GCC 14-64, msys2) TESTS 26 77 102400
343058254 starflowrain D Oct. 11, 2025, 2:52 a.m. OK C++23 (GCC 14-64, msys2) TESTS 26 77 307200
343054599 cyq18 D Oct. 11, 2025, 1:43 a.m. OK C++23 (GCC 14-64, msys2) TESTS 26 77 2457600
343072124 Thirstarfish D Oct. 11, 2025, 5:44 a.m. OK C++23 (GCC 14-64, msys2) TESTS 26 77 2662400
343034085 464zzyx D Oct. 10, 2025, 7:25 p.m. OK C++23 (GCC 14-64, msys2) TESTS 26 77 8601600
343033895 464zzyx D Oct. 10, 2025, 7:24 p.m. OK C++23 (GCC 14-64, msys2) TESTS 26 77 8601600
343060962 Deep_Sea_Explorer D Oct. 11, 2025, 3:34 a.m. OK C++23 (GCC 14-64, msys2) TESTS 26 78 0
343024567 NenadDapic D Oct. 10, 2025, 6:17 p.m. OK FPC TESTS 26 109 2457600
343010863 WrongAnswerOnTestCase2 D Oct. 10, 2025, 4:40 p.m. OK Java 21 TESTS 26 374 6656000
343010985 kpiyush1024 D Oct. 10, 2025, 4:40 p.m. OK Java 21 TESTS 26 389 716800
343012624 GuLLu05 D Oct. 10, 2025, 4:44 p.m. OK Java 21 TESTS 26 390 1433600
343023948 Goutham_808 D Oct. 10, 2025, 6:14 p.m. OK Java 21 TESTS 26 405 1536000
343013327 Azad_Singh D Oct. 10, 2025, 4:45 p.m. OK Java 21 TESTS 26 499 40243200
343012704 bhaskar_aa45 D Oct. 10, 2025, 4:44 p.m. OK Java 21 TESTS 26 780 5120000
343014406 oishiki22 D Oct. 10, 2025, 4:47 p.m. OK Java 21 TESTS 26 827 1433600
343012541 advaithsai.n112 D Oct. 10, 2025, 4:43 p.m. OK Java 21 TESTS 26 827 1843200
343014820 ironman263 D Oct. 10, 2025, 4:48 p.m. OK Java 21 TESTS 26 828 18432000
343038330 hiddenhopes D Oct. 10, 2025, 8:07 p.m. OK Java 8 TESTS 26 202 409600
343069857 samamn_varshney D Oct. 11, 2025, 5:22 a.m. OK Java 8 TESTS 26 249 3686400
343011121 aditya0013 D Oct. 10, 2025, 4:40 p.m. OK Java 8 TESTS 26 249 5632000
343059942 xmjlove D Oct. 11, 2025, 3:17 a.m. OK Java 8 TESTS 26 281 0
343008184 jishan55444 D Oct. 10, 2025, 4:33 p.m. OK Java 8 TESTS 26 530 0
343013803 dbasu03 D Oct. 10, 2025, 4:46 p.m. OK Java 8 TESTS 26 624 512000
343053496 tauros D Oct. 11, 2025, 1:16 a.m. OK Kotlin 1.9 TESTS 26 296 1433600
343057557 sibani D Oct. 11, 2025, 2:41 a.m. OK PyPy 3 TESTS 26 796 39833600
343013445 vimaaan D Oct. 10, 2025, 4:45 p.m. OK PyPy 3 TESTS 26 1124 29491200
343014431 Akshar_7 D Oct. 10, 2025, 4:47 p.m. OK PyPy 3-64 TESTS 26 265 24780800
343030454 DT4V D Oct. 10, 2025, 6:55 p.m. OK PyPy 3-64 TESTS 26 265 27238400
343074494 SrEy_P-0-7 D Oct. 11, 2025, 6:03 a.m. OK PyPy 3-64 TESTS 26 265 29184000
343058314 lowjy D Oct. 11, 2025, 2:53 a.m. OK PyPy 3-64 TESTS 26 296 27955200
343067567 Yuyan_trying D Oct. 11, 2025, 4:59 a.m. OK PyPy 3-64 TESTS 26 296 28467200
343064716 LightHouse1 D Oct. 11, 2025, 4:27 a.m. OK PyPy 3-64 TESTS 26 296 28467200
343055785 hungchi17 D Oct. 11, 2025, 2:08 a.m. OK PyPy 3-64 TESTS 26 296 28467200
343028325 DT4V D Oct. 10, 2025, 6:40 p.m. OK PyPy 3-64 TESTS 26 296 28467200
343049042 gardengnome D Oct. 10, 2025, 11:03 p.m. OK PyPy 3-64 TESTS 26 296 29081600
343048151 gardengnome D Oct. 10, 2025, 10:40 p.m. OK PyPy 3-64 TESTS 26 327 29081600
343025856 p_2626 D Oct. 10, 2025, 6:25 p.m. OK Python 3 TESTS 26 499 26726400
343032819 davidmiheev D Oct. 10, 2025, 7:15 p.m. OK Python 3 TESTS 26 593 27033600
343010669 lyt-715 D Oct. 10, 2025, 4:39 p.m. OK Python 3 TESTS 26 905 41164800
343014858 lulameoh D Oct. 10, 2025, 4:48 p.m. OK Python 3 TESTS 26 1280 88780800
343015454 Sorcer_Supreme D Oct. 10, 2025, 4:49 p.m. OK Python 3 TESTS 26 1312 36454400
343030215 Ruby_Ocelot D Oct. 10, 2025, 6:54 p.m. OK Python 3 TESTS 26 1436 26624000
343013587 ffgfgf D Oct. 10, 2025, 4:46 p.m. OK Rust 2024 TESTS 26 93 2457600

remove filters

Back to search problems