Codeforces Round 1069 (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
2174 Codeforces Round 1069 (Div. 1) FINISHED False 7200 11396723 Dec. 6, 2025, 8:15 a.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 3919 ) B Wishing Cards PROGRAMMING dp

It is said that writing wishing cards on New Year's Eve can bring good luck. You have written wishing cards and plan to give them to Little A. You have invited (n) friends to help you deliver the wishing cards. You plan to give the (i)-th friend (b_i) wishing cards. The friends will visit Little A's house in the order of (1) to (n), and each will hand over all his (b_i) wishing cards to Little A. Little A always remembers the friend who gives her the most wishing cards, so after the (j)-th friend's visit, she gains happiness equal to the largest number of cards received so far, that is, (\max(b_1, b_2, \ldots, b_j)). The (i)-th friend can carry at most (a_i) cards, and the total number of cards cannot exceed (k). Your task is to optimally choose values of (b_i) so that the total happiness of Little A after (n) visits is maximized under these constraints. Note that some friends may carry no cards at all, Little A won't get mad. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^3)). The description of the test cases follows. The first line of each test case contains two integers (n) and (k) ((1 \le n \le 10^5), (1 \le k \le 360)), the number of friends, and the maximum total number of cards. The second line of each test case contains (n) integers (a_1,a_2,\ldots,a_n) ((0 \le a_i \le k)), the maximum number of cards each friend can carry. It is guaranteed that the sum of (n) over all test cases does not exceed (5 \cdot 10^5) and the sum of (k) over all test cases does not exceed (1800). For each test case, output the maximum happiness Little A can get. In the first test case, the only way to distribute wishing cards is (b = 0,0,1). In the third test case, (b = 1,0,4) is invalid because you only have (k = 4) wishing cards. In the fourth test case, one of the optimal ways to distribut

Tutorials

Codeforces Round 1069 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
352215139 -firefly- B Dec. 6, 2025, 9:07 a.m. OK C# 13 TESTS 12 656 150835200
352220960 oceeff B Dec. 6, 2025, 9:21 a.m. OK C++17 (GCC 7-32) TESTS 12 46 3481600
352238473 gs17005 B Dec. 6, 2025, 10:10 a.m. OK C++17 (GCC 7-32) TESTS 12 62 2457600
352279589 21cs01033 B Dec. 6, 2025, 3:29 p.m. OK C++17 (GCC 7-32) TESTS 12 62 4096000
352279830 21cs01033 B Dec. 6, 2025, 3:31 p.m. OK C++17 (GCC 7-32) TESTS 12 62 32153600
352276511 21cs01033 B Dec. 6, 2025, 3:06 p.m. OK C++17 (GCC 7-32) TESTS 12 78 614400
352210340 antonis.white B Dec. 6, 2025, 8:56 a.m. OK C++17 (GCC 7-32) TESTS 12 78 1126400
352236740 wangxinyue B Dec. 6, 2025, 10:06 a.m. OK C++17 (GCC 7-32) TESTS 12 78 2560000
352278264 21cs01033 B Dec. 6, 2025, 3:19 p.m. OK C++17 (GCC 7-32) TESTS 12 93 102400
352277768 21cs01033 B Dec. 6, 2025, 3:15 p.m. OK C++17 (GCC 7-32) TESTS 12 93 102400
352218849 Linear_B B Dec. 6, 2025, 9:16 a.m. OK C++17 (GCC 7-32) TESTS 12 93 1024000
352201952 fydj B Dec. 6, 2025, 8:40 a.m. OK C++20 (GCC 13-64) TESTS 12 46 3584000
352235809 wenhao0 B Dec. 6, 2025, 10:03 a.m. OK C++20 (GCC 13-64) TESTS 12 46 5427200
352211897 www_bilibili_com B Dec. 6, 2025, 9 a.m. OK C++20 (GCC 13-64) TESTS 12 46 188723200
352212902 chaynflow B Dec. 6, 2025, 9:02 a.m. OK C++20 (GCC 13-64) TESTS 12 62 512000
352212450 Zachary_Gao B Dec. 6, 2025, 9:01 a.m. OK C++20 (GCC 13-64) TESTS 12 62 614400
352230155 lyhr02 B Dec. 6, 2025, 9:45 a.m. OK C++20 (GCC 13-64) TESTS 12 62 921600
352212463 Qiubai_love B Dec. 6, 2025, 9:01 a.m. OK C++20 (GCC 13-64) TESTS 12 62 1331200
352221805 zjq123 B Dec. 6, 2025, 9:23 a.m. OK C++20 (GCC 13-64) TESTS 12 62 1638400
352220254 jianylg B Dec. 6, 2025, 9:19 a.m. OK C++20 (GCC 13-64) TESTS 12 62 2969600
352222180 ShmilyTY B Dec. 6, 2025, 9:24 a.m. OK C++20 (GCC 13-64) TESTS 12 62 3379200
352201257 exgcd B Dec. 6, 2025, 8:39 a.m. OK C++23 (GCC 14-64, msys2) TESTS 12 46 102400
352207973 thr_c2025 B Dec. 6, 2025, 8:52 a.m. OK C++23 (GCC 14-64, msys2) TESTS 12 46 1126400
352207289 while_zeze B Dec. 6, 2025, 8:50 a.m. OK C++23 (GCC 14-64, msys2) TESTS 12 46 7270400
352342564 Zi_Qian B Dec. 7, 2025, 6:04 a.m. OK C++23 (GCC 14-64, msys2) TESTS 12 62 1433600
352220869 zsmihaly B Dec. 6, 2025, 9:21 a.m. OK C++23 (GCC 14-64, msys2) TESTS 12 78 0
352265350 Kira_1234 B Dec. 6, 2025, 1:49 p.m. OK C++23 (GCC 14-64, msys2) TESTS 12 78 102400
352229271 Proof_by_QED B Dec. 6, 2025, 9:43 a.m. OK C++23 (GCC 14-64, msys2) TESTS 12 78 409600
352212475 CHYYYY B Dec. 6, 2025, 9:01 a.m. OK C++23 (GCC 14-64, msys2) TESTS 12 78 512000
352212616 aastik231205 B Dec. 6, 2025, 9:01 a.m. OK C++23 (GCC 14-64, msys2) TESTS 12 78 614400
352268611 cool_milo B Dec. 6, 2025, 2:12 p.m. OK C++23 (GCC 14-64, msys2) TESTS 12 78 1024000
352215572 pengin_2000 B Dec. 6, 2025, 9:08 a.m. OK GNU C11 TESTS 12 109 3686400
352289484 cstemp B Dec. 6, 2025, 4:45 p.m. OK Java 21 TESTS 12 281 8294400
352268584 ccj123 B Dec. 6, 2025, 2:11 p.m. OK Java 21 TESTS 12 296 204800
352206518 gua069 B Dec. 6, 2025, 8:49 a.m. OK Java 8 TESTS 12 187 0
352207429 SirMrGuy B Dec. 6, 2025, 8:50 a.m. OK PyPy 3-64 TESTS 12 187 19968000
352279210 BoomTiwari B Dec. 6, 2025, 3:26 p.m. OK PyPy 3-64 TESTS 12 218 19865600
352235147 Ayis137 B Dec. 6, 2025, 10:01 a.m. OK PyPy 3-64 TESTS 12 468 22732800
352197482 gawkmaster069 B Dec. 6, 2025, 8:31 a.m. OK PyPy 3-64 TESTS 12 609 43724800
352209539 ETO-leader B Dec. 6, 2025, 8:55 a.m. OK PyPy 3-64 TESTS 12 609 132300800
352235348 Pulkit_gupta B Dec. 6, 2025, 10:01 a.m. OK PyPy 3-64 TESTS 12 812 25497600
352201475 sfiisf B Dec. 6, 2025, 8:39 a.m. OK PyPy 3-64 TESTS 12 843 30208000
352316780 ndelisle B Dec. 6, 2025, 9:19 p.m. OK PyPy 3-64 TESTS 12 1234 43315200
352233676 SPD_9X2 B Dec. 6, 2025, 9:56 a.m. OK PyPy 3-64 TESTS 12 1687 26828800
352228718 krism B Dec. 6, 2025, 9:41 a.m. OK PyPy 3-64 TESTS 12 1703 35635200
352277397 siddhantbashisth B Dec. 6, 2025, 3:12 p.m. OK Python 3 TESTS 12 1281 23040000
352209253 ACr0bat B Dec. 6, 2025, 8:54 a.m. OK Python 3 TESTS 12 1875 26009600
352332089 sansen B Dec. 7, 2025, 3:26 a.m. OK Rust 2021 TESTS 12 62 3379200
352199500 sansen B Dec. 6, 2025, 8:35 a.m. OK Rust 2021 TESTS 12 296 3379200
352202842 toomer B Dec. 6, 2025, 8:42 a.m. OK Rust 2021 TESTS 12 406 409600
352238074 despair B Dec. 6, 2025, 10:09 a.m. OK Rust 2024 TESTS 12 46 0
352199356 Egor B Dec. 6, 2025, 8:35 a.m. OK Rust 2024 TESTS 12 140 84377600
352222343 kanra824 B Dec. 6, 2025, 9:24 a.m. OK Rust 2024 TESTS 12 187 33382400
352230137 Monster027 B Dec. 6, 2025, 9:45 a.m. OK Rust 2024 TESTS 12 421 147046400

remove filters

Back to search problems