Codeforces Round 1023 (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
2107 Codeforces Round 1023 (Div. 2) FINISHED False 8100 29949923 May 5, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 497 ) F2 Cycling (Hard Version) PROGRAMMING binary search data structures dp geometry greedy

This is the hard version of the problem. The difference between the versions is that in this version, (1\le n\le 10^6) and you need to output the answer for each prefix. You can hack only if you solved all versions of this problem. Leo works as a programmer in the city center, and his lover teaches at a high school in the suburbs. Every weekend, Leo would ride his bike to the suburbs to spend a nice weekend with his lover. There are (n) cyclists riding in front of Leo on this road right now. They are numbered (1), (2), (\ldots), (n) from front to back. Initially, Leo is behind the (n)-th cyclist. The (i)-th cyclist has an agility value (a_i). Leo wants to get ahead of the (1)-st cyclist. Leo can take the following actions as many times as he wants: Assuming that the first person in front of Leo is cyclist (i), he can go in front of cyclist (i) for a cost of (a_i). This puts him behind cyclist (i - 1). Using his super powers, swap (a_i) and (a_j) ((1\le i < j\le n)) for a cost of ((j - i)). Leo wants to know the minimum cost to get in front of the (1)-st cyclist. In addition, he wants to know the answer for each (1\le i \le n), (a_1, a_2, \ldots, a_i) as the original array. The problems of different (i) are independent. To be more specific, in the (i)-th problem, Leo starts behind the (i)-th cyclist instead of the (n)-th cyclist, and cyclists numbered (i + 1, i + 2, \ldots, n) are not present. 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 positive integer (n) ((1 \leq n \leq 10^6)), representing the number of the cyclists. The second line of each test case contains (n) integers (a_1, \ldots, a_n) ((1 \leq a_i \leq 10^9)). It is guaranteed that the sum of (n) over all t

Tutorials

Codeforces Round 1023 (Div 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
318526474 potato167 F2 May 5, 2025, 4:44 p.m. OK C++17 (GCC 7-32) TESTS 53 874 21913600
318550914 Nxxlt F2 May 5, 2025, 7:54 p.m. OK C++17 (GCC 7-32) TESTS 53 937 12288000
318540865 dmraykhan F2 May 5, 2025, 6 p.m. OK C++17 (GCC 7-32) TESTS 53 1015 20582400
318558592 urosk F2 May 5, 2025, 10:29 p.m. OK C++17 (GCC 7-32) TESTS 53 1234 89702400
318526922 nikolapesic2802 F2 May 5, 2025, 4:45 p.m. OK C++17 (GCC 7-32) TESTS 53 2125 81920000
318574219 TianyiWei F2 May 6, 2025, 3:16 a.m. OK C++17 (GCC 7-32) TESTS 53 2187 118784000
318557511 kaiboy F2 May 5, 2025, 9:55 p.m. OK C++20 (GCC 13-64) TESTS 53 327 28160000
318545320 zeemanz F2 May 5, 2025, 6:43 p.m. OK C++20 (GCC 13-64) TESTS 53 358 21708800
318525787 medmdgm F2 May 5, 2025, 4:42 p.m. OK C++20 (GCC 13-64) TESTS 53 436 14438400
318546734 Noche_6 F2 May 5, 2025, 6:58 p.m. OK C++20 (GCC 13-64) TESTS 53 484 19763200
318524340 _VanGogh_ F2 May 5, 2025, 4:38 p.m. OK C++20 (GCC 13-64) TESTS 53 484 19763200
318526348 banti F2 May 5, 2025, 4:44 p.m. OK C++20 (GCC 13-64) TESTS 53 546 264601600
318542581 Tahirliyev F2 May 5, 2025, 6:15 p.m. OK C++20 (GCC 13-64) TESTS 53 562 12492800
318573219 sheercold F2 May 6, 2025, 2:55 a.m. OK C++20 (GCC 13-64) TESTS 53 593 12390400
318551205 AlexW08 F2 May 5, 2025, 7:58 p.m. OK C++20 (GCC 13-64) TESTS 53 593 20377600
318523594 div2halyva F2 May 5, 2025, 4:36 p.m. OK C++20 (GCC 13-64) TESTS 53 593 20377600
318575254 A_G F2 May 6, 2025, 3:35 a.m. OK C++23 (GCC 14-64, msys2) TESTS 53 328 8499200
318575108 A_G F2 May 6, 2025, 3:32 a.m. OK C++23 (GCC 14-64, msys2) TESTS 53 342 8499200
318576443 interlude F2 May 6, 2025, 3:57 a.m. OK C++23 (GCC 14-64, msys2) TESTS 53 343 28160000
318570244 Macesuted-Moe F2 May 6, 2025, 1:53 a.m. OK C++23 (GCC 14-64, msys2) TESTS 53 358 11878400
318539152 ibrm F2 May 5, 2025, 5:45 p.m. OK C++23 (GCC 14-64, msys2) TESTS 53 421 10342400
318553984 BluoCaroot F2 May 5, 2025, 8:43 p.m. OK C++23 (GCC 14-64, msys2) TESTS 53 468 21299200
318582403 krit3379 F2 May 6, 2025, 5:32 a.m. OK C++23 (GCC 14-64, msys2) TESTS 53 468 32870400
318575395 Auchenai01 F2 May 6, 2025, 3:37 a.m. OK C++23 (GCC 14-64, msys2) TESTS 53 484 46694400
318548165 MeIoN_is_UMP45 F2 May 5, 2025, 7:15 p.m. OK C++23 (GCC 14-64, msys2) TESTS 53 484 72396800
318547413 andreyDagger F2 May 5, 2025, 7:06 p.m. OK C++23 (GCC 14-64, msys2) TESTS 53 499 34201600
318538377 muradbhai F2 May 5, 2025, 5:40 p.m. OK GNU C11 TESTS 53 4890 48230400

remove filters

Back to search problems