Codeforces Round 1124 (Div. 1)

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
2268 Codeforces Round 1124 (Div. 1) FINISHED False 9000 746666 Sept. 26, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 9799 ) A K Is Important PROGRAMMING constructive algorithms greedy

You are given an array (a) consisting of (n) positive integers, as well as an integer parameter (k). While the array has at least (k) elements, you need to perform one of the following two types of operations on (a): Remove (a_k) and add its value to your score, or Remove (a_{m-k+1}) and add its value to your score, where (m) is the length of (a) before this operation. After removing an element, the remaining elements keep their relative order. Your task is to determine the maximum possible score that can be obtained. 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 two integers (n) and (k) ((1 \le k \le n \le 10^5)) — the length of (a) and the parameter. The second line contains (n) integers (a_i) ((1 \le a_i \le 10^9)) — the elements of (a). It is guaranteed that the sum of (n) over all test cases does not exceed (10^5). For each test case, output a single integer — the maximum score that can be obtained. In the first test case, we can first remove (a_3 = 3). The score becomes (3), and the array becomes (1, 2, 4). Then we remove (a_2 = 2), so the score becomes (5), and the array becomes (1, 4). Finally, we remove (a_2 = 4), and the score becomes (9). Now the length of the array is less than (k=2), so no more operations can be performed. It can be proven that the maximum score is (9). In the second test case, we can only perform one operation, either removing (a_1 = 3) or (a_4 = 2). Obviously, it is better to remove (a_1 = 3) to get a score of (3).

Tutorials

157140

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
392183240 vito1036 A Sept. 26, 2026, 2:46 p.m. OK C++17 (GCC 7-32) TESTS 16 46 409600
392286674 Flechazo1314 A Sept. 27, 2026, 5:44 a.m. OK C++17 (GCC 7-32) TESTS 16 62 0
392280606 ReTuRN071007 A Sept. 27, 2026, 4:12 a.m. OK C++17 (GCC 7-32) TESTS 16 62 0
392246908 SEBB A Sept. 26, 2026, 6:58 p.m. OK C++17 (GCC 7-32) TESTS 16 62 0
392245840 samir020 A Sept. 26, 2026, 6:45 p.m. OK C++17 (GCC 7-32) TESTS 16 62 0
392245539 GregCodez A Sept. 26, 2026, 6:42 p.m. OK C++17 (GCC 7-32) TESTS 16 62 0
392242251 akshattiwari487 A Sept. 26, 2026, 6:10 p.m. OK C++17 (GCC 7-32) TESTS 16 62 0
392189991 DemberS06 A Sept. 26, 2026, 2:57 p.m. OK C++17 (GCC 7-32) TESTS 16 62 0
392188051 chwiz A Sept. 26, 2026, 2:53 p.m. OK C++17 (GCC 7-32) TESTS 16 62 0
392187143 mo0dman A Sept. 26, 2026, 2:52 p.m. OK C++17 (GCC 7-32) TESTS 16 62 0
392185066 lyt-715 A Sept. 26, 2026, 2:48 p.m. OK C++20 (GCC 13-64) TESTS 16 31 614400
392281806 mozart_elegance A Sept. 27, 2026, 4:35 a.m. OK C++20 (GCC 13-64) TESTS 16 46 0
392278029 master_luo A Sept. 27, 2026, 3:22 a.m. OK C++20 (GCC 13-64) TESTS 16 46 0
392208497 Payea A Sept. 26, 2026, 3:38 p.m. OK C++20 (GCC 13-64) TESTS 16 46 0
392204036 bruhify A Sept. 26, 2026, 3:27 p.m. OK C++20 (GCC 13-64) TESTS 16 46 0
392196124 not10hour A Sept. 26, 2026, 3:09 p.m. OK C++20 (GCC 13-64) TESTS 16 46 0
392194362 Ggg_ A Sept. 26, 2026, 3:05 p.m. OK C++20 (GCC 13-64) TESTS 16 46 0
392190992 shingo0909 A Sept. 26, 2026, 2:59 p.m. OK C++20 (GCC 13-64) TESTS 16 46 0
392190038 pooty A Sept. 26, 2026, 2:57 p.m. OK C++20 (GCC 13-64) TESTS 16 46 0
392188063 Alish_1_2100 A Sept. 26, 2026, 2:53 p.m. OK C++20 (GCC 13-64) TESTS 16 46 0
392182287 permutation A Sept. 26, 2026, 2:44 p.m. OK C++23 (GCC 14-64, msys2) TESTS 16 31 0
392180140 b6e0 A Sept. 26, 2026, 2:42 p.m. OK C++23 (GCC 14-64, msys2) TESTS 16 31 3686400
392243408 jlass_ A Sept. 26, 2026, 6:21 p.m. OK C++23 (GCC 14-64, msys2) TESTS 16 46 0
392288019 Artist1e9X A Sept. 27, 2026, 5:56 a.m. OK C++23 (GCC 14-64, msys2) TESTS 16 46 0
392279059 asaltfish A Sept. 27, 2026, 3:43 a.m. OK C++23 (GCC 14-64, msys2) TESTS 16 46 0
392278042 ShlokHShah A Sept. 27, 2026, 3:23 a.m. OK C++23 (GCC 14-64, msys2) TESTS 16 46 0
392275594 lftroq A Sept. 27, 2026, 2:25 a.m. OK C++23 (GCC 14-64, msys2) TESTS 16 46 0
392260755 rns_rgg1 A Sept. 27, 2026, 12:09 a.m. OK C++23 (GCC 14-64, msys2) TESTS 16 46 0
392258604 MEDAAA A Sept. 26, 2026, 10:43 p.m. OK C++23 (GCC 14-64, msys2) TESTS 16 46 0
392249191 JovanB A Sept. 26, 2026, 7:30 p.m. OK C++23 (GCC 14-64, msys2) TESTS 16 46 0
392180439 Gassa A Sept. 26, 2026, 2:42 p.m. OK D TESTS 16 62 3072000
392185546 Cybuster A Sept. 26, 2026, 2:49 p.m. OK D TESTS 16 78 10035200
392238528 nnengine A Sept. 26, 2026, 5:39 p.m. OK GNU C11 TESTS 16 46 1331200
392235868 Ayushek A Sept. 26, 2026, 5:19 p.m. OK GNU C11 TESTS 16 1531 409600
392204743 hardiknarang2509 A Sept. 26, 2026, 3:29 p.m. OK Java 21 TESTS 16 250 614400
392192281 MaxBuzz A Sept. 26, 2026, 3:01 p.m. OK Java 21 TESTS 16 265 819200
392188800 aaryannage.dev A Sept. 26, 2026, 2:55 p.m. OK Java 21 TESTS 16 281 921600
392178584 LT1 A Sept. 26, 2026, 2:40 p.m. OK Java 21 TESTS 16 296 512000
392191880 WaterBottlle A Sept. 26, 2026, 3 p.m. OK Java 21 TESTS 16 328 921600
392239445 aditya_sah_11 A Sept. 26, 2026, 5:46 p.m. OK Java 21 TESTS 16 421 2355200
392183199 AJ123496 A Sept. 26, 2026, 2:46 p.m. OK Java 21 TESTS 16 437 819200
392243184 HARSHSHRINGI A Sept. 26, 2026, 6:19 p.m. OK Java 21 TESTS 16 484 1228800
392237639 vishal_gadad A Sept. 26, 2026, 5:32 p.m. OK Java 21 TESTS 16 859 1331200
392219143 dark_slayer007 A Sept. 26, 2026, 4:08 p.m. OK Java 8 TESTS 16 140 0
392187040 malachi_toney_goat A Sept. 26, 2026, 2:52 p.m. OK Java 8 TESTS 16 140 0
392245793 Basharath_S A Sept. 26, 2026, 6:45 p.m. OK Java 8 TESTS 16 1375 0
392186921 Tlatoani A Sept. 26, 2026, 2:51 p.m. OK Kotlin 2.2 TESTS 16 218 8601600
392191276 DeadRhino A Sept. 26, 2026, 2:59 p.m. OK PyPy 3 TESTS 16 343 11161600
392193892 chhillarankit74 A Sept. 26, 2026, 3:04 p.m. OK PyPy 3-64 TESTS 16 93 13107200
392181443 glebisbusy A Sept. 26, 2026, 2:43 p.m. OK PyPy 3-64 TESTS 16 109 14745600
392185796 Haire A Sept. 26, 2026, 2:49 p.m. OK PyPy 3-64 TESTS 16 125 15257600
392183947 x0rque A Sept. 26, 2026, 2:46 p.m. OK PyPy 3-64 TESTS 16 140 13926400
392181863 stan23456 A Sept. 26, 2026, 2:44 p.m. OK PyPy 3-64 TESTS 16 140 13926400
392184917 hxu10 A Sept. 26, 2026, 2:48 p.m. OK PyPy 3-64 TESTS 16 156 15974400
392181269 _______________________ A Sept. 26, 2026, 2:43 p.m. OK PyPy 3-64 TESTS 16 156 16793600
392263282 Little_Sheep_Yawn A Sept. 27, 2026, 1:26 a.m. OK PyPy 3-64 TESTS 16 156 20172800
392180043 harurun4635 A Sept. 26, 2026, 2:41 p.m. OK PyPy 3-64 TESTS 16 171 11878400
392180882 Kuro_neko A Sept. 26, 2026, 2:42 p.m. OK PyPy 3-64 TESTS 16 171 14950400
392202456 Jimanbanashi A Sept. 26, 2026, 3:23 p.m. OK Python 2 TESTS 16 140 4812800
392258536 jorgevmg31 A Sept. 26, 2026, 10:41 p.m. OK Python 3 TESTS 16 78 12902400
392236555 Afropotential A Sept. 26, 2026, 5:24 p.m. OK Python 3 TESTS 16 125 13004800
392238281 prabhatshah24 A Sept. 26, 2026, 5:37 p.m. OK Python 3 TESTS 16 718 13107200
392249293 nazerawig A Sept. 26, 2026, 7:31 p.m. OK Python 3 TESTS 16 1093 12595200
392243126 Nishant_IITD A Sept. 26, 2026, 6:18 p.m. OK Python 3 TESTS 16 1156 13209600
392184969 darkkcyan A Sept. 26, 2026, 2:48 p.m. OK Rust 2024 TESTS 16 46 0
392185647 qwerty787788 A Sept. 26, 2026, 2:49 p.m. OK Rust 2024 TESTS 16 46 102400
392192702 Kevin-27 A Sept. 26, 2026, 3:02 p.m. OK Rust 2024 TESTS 16 46 204800
392179987 DanielAnker A Sept. 26, 2026, 2:41 p.m. OK Rust 2024 TESTS 16 46 204800
392188493 cvs-650 A Sept. 26, 2026, 2:54 p.m. OK Rust 2024 TESTS 16 46 1024000

remove filters

Back to search problems