Codeforces Round 1042 (Div. 3)

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
2131 Codeforces Round 1042 (Div. 3) FINISHED False 8100 21569123 Aug. 10, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 3735 ) G Wafu! PROGRAMMING bitmasks brute force dp math

To help improve her math, Kudryavka is given a set (S) that consists of (n) distinct positive integers. Initially, her score is (1). She can perform an arbitrary number of the following operations on the set if it is not empty: Let the minimum value of (S) be (m). Multiply her score by (m). Remove (m) from (S). For every integer (i) such that (1 \le i < m), add (i) to the set (S). It can be shown that no duplicates are added during this step. She is addicted to performing operations, but after (k) operations, she realizes she forgot her score . Please help her determine her score , modulo (10^9+7). 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 n \le 2 \cdot 10^5), (1 \le k \le 10^9)). The second line of each test case contains (n) integers (s_1, s_2, \dots, s_n) ((1 \le s_i \le 10^9), (s_i \neq s_j)) — the elements of the initial set (S). It is guaranteed that the set (S) is not empty before each of the (k) operations is performed. It is guaranteed that the sum of (n) over all test cases does not exceed (2 \cdot 10^5). For each test case, output an integer indicating the answer modulo (10^9+7). Let us simulate the process in the first test case: () \{1,3\} \xrightarrow{\text{remove}\ 1} \{3\} \xrightarrow\text{add}\ 1,2{\text{remove}\ 3} \{1,2\} \xrightarrow{\text{remove}\ 1} \{2\} () The removed values are (1), (3) and (1) respectively, so her score is (1\times 3\times 1 = 3). In the second test case, the answer is (1 \times 4 \times 1 \times 2 \times 1 \times 3 = 24).

Tutorials

Codeforces Round 1042 (Div. 3) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
333450626 og.kostya G Aug. 10, 2025, 5:16 p.m. OK C# 13 TESTS 18 187 2457600
333449375 dpsvoyager.16 G Aug. 10, 2025, 5:08 p.m. OK C++17 (GCC 7-32) TESTS 18 93 0
333486500 414s_boy G Aug. 11, 2025, 3:24 a.m. OK C++17 (GCC 7-32) TESTS 18 108 819200
333485380 cauemb G Aug. 11, 2025, 3:08 a.m. OK C++17 (GCC 7-32) TESTS 18 109 0
333443396 movies933522 G Aug. 10, 2025, 4:47 p.m. OK C++17 (GCC 7-32) TESTS 18 109 0
333452563 twotb G Aug. 10, 2025, 5:30 p.m. OK C++17 (GCC 7-32) TESTS 18 109 102400
333449735 ctgg G Aug. 10, 2025, 5:10 p.m. OK C++17 (GCC 7-32) TESTS 18 109 819200
333447076 xuan_never G Aug. 10, 2025, 4:56 p.m. OK C++17 (GCC 7-32) TESTS 18 109 3276800
333452515 Wrong_answer_on_Test_0 G Aug. 10, 2025, 5:29 p.m. OK C++17 (GCC 7-32) TESTS 18 109 4198400
333496790 ylh_ G Aug. 11, 2025, 5:42 a.m. OK C++17 (GCC 7-32) TESTS 18 124 0
333466634 pritish171 G Aug. 10, 2025, 8:08 p.m. OK C++17 (GCC 7-32) TESTS 18 124 0
333471427 sam990 G Aug. 10, 2025, 9:47 p.m. OK C++20 (GCC 13-64) TESTS 18 78 0
333452262 ji_114514 G Aug. 10, 2025, 5:28 p.m. OK C++20 (GCC 13-64) TESTS 18 78 0
333485886 Rating_10101010 G Aug. 11, 2025, 3:16 a.m. OK C++20 (GCC 13-64) TESTS 18 93 0
333479094 Ichinoseyang G Aug. 11, 2025, 1:38 a.m. OK C++20 (GCC 13-64) TESTS 18 93 0
333471755 crystal_castles G Aug. 10, 2025, 9:56 p.m. OK C++20 (GCC 13-64) TESTS 18 93 0
333469499 NeonCaesium G Aug. 10, 2025, 9:01 p.m. OK C++20 (GCC 13-64) TESTS 18 93 0
333465222 rayban G Aug. 10, 2025, 7:45 p.m. OK C++20 (GCC 13-64) TESTS 18 93 0
333457649 Ayanokoji7 G Aug. 10, 2025, 6:14 p.m. OK C++20 (GCC 13-64) TESTS 18 93 0
333453776 _ZaVi G Aug. 10, 2025, 5:39 p.m. OK C++20 (GCC 13-64) TESTS 18 93 0
333452486 soham_c04 G Aug. 10, 2025, 5:29 p.m. OK C++20 (GCC 13-64) TESTS 18 93 0
333496228 rgrgtgrf G Aug. 11, 2025, 5:40 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 93 0
333488815 hosizora G Aug. 11, 2025, 3:58 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 93 0
333488501 LoveSiyan G Aug. 11, 2025, 3:54 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 93 0
333487418 jaygoti2006 G Aug. 11, 2025, 3:38 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 93 0
333486515 nob_lz G Aug. 11, 2025, 3:24 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 93 0
333485411 AgafonovArtem G Aug. 11, 2025, 3:09 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 93 0
333479278 H19wk G Aug. 11, 2025, 1:41 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 93 0
333477591 MoSooN G Aug. 11, 2025, 1:10 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 93 0
333474717 Acp_imt026 G Aug. 10, 2025, 11:43 p.m. OK C++23 (GCC 14-64, msys2) TESTS 18 93 0
333474230 jat.arc2004 G Aug. 10, 2025, 11:25 p.m. OK C++23 (GCC 14-64, msys2) TESTS 18 93 0
333448254 pengin_2000 G Aug. 10, 2025, 5:02 p.m. OK GNU C11 TESTS 18 218 9728000
333471691 lunarmoon G Aug. 10, 2025, 9:54 p.m. OK Go TESTS 18 202 5222400
333477358 0x3F G Aug. 11, 2025, 1:05 a.m. OK Go TESTS 18 468 4915200
333462786 mrunaltarwatkar018 G Aug. 10, 2025, 7:12 p.m. OK Java 21 TESTS 18 281 819200
333460028 joseantonio.vegaruiz G Aug. 10, 2025, 6:39 p.m. OK Java 21 TESTS 18 311 921600
333482113 0137- G Aug. 11, 2025, 2:24 a.m. OK Java 21 TESTS 18 327 614400
333498425 NpHardcore_05 G Aug. 11, 2025, 5:59 a.m. OK Java 21 TESTS 18 343 921600
333497628 oneafter G Aug. 11, 2025, 5:51 a.m. OK Java 21 TESTS 18 624 1536000
333457506 lupunish G Aug. 10, 2025, 6:13 p.m. OK Java 21 TESTS 18 624 20582400
333450562 boostorna G Aug. 10, 2025, 5:15 p.m. OK PyPy 3 TESTS 18 1093 14745600
333485847 nbhavsar G Aug. 11, 2025, 3:15 a.m. OK PyPy 3-64 TESTS 18 171 27033600
333465161 harurun4635 G Aug. 10, 2025, 7:44 p.m. OK PyPy 3-64 TESTS 18 186 21504000
333485684 nbhavsar G Aug. 11, 2025, 3:13 a.m. OK PyPy 3-64 TESTS 18 186 27136000
333453543 verstrapp_1 G Aug. 10, 2025, 5:37 p.m. OK PyPy 3-64 TESTS 18 187 27136000
333452138 Polynomu G Aug. 10, 2025, 5:27 p.m. OK PyPy 3-64 TESTS 18 249 26112000
333452736 Mischievius G Aug. 10, 2025, 5:31 p.m. OK PyPy 3-64 TESTS 18 249 27340800
333497680 IcyGirl G Aug. 11, 2025, 5:51 a.m. OK PyPy 3-64 TESTS 18 249 30822400
333497930 hexagoning G Aug. 11, 2025, 5:54 a.m. OK PyPy 3-64 TESTS 18 264 26521600
333449409 jackle G Aug. 10, 2025, 5:08 p.m. OK PyPy 3-64 TESTS 18 280 26931200
333493920 Bibek_06 G Aug. 11, 2025, 5:12 a.m. OK PyPy 3-64 TESTS 18 280 32256000
333445230 chaitanyabattu7766 G Aug. 10, 2025, 4:49 p.m. OK Python 3 TESTS 18 734 36761600
333456341 obrazcoff G Aug. 10, 2025, 6:02 p.m. OK Python 3 TESTS 18 1000 28364800
333447591 igor99972 G Aug. 10, 2025, 4:59 p.m. OK Python 3 TESTS 18 1296 26828800

remove filters

Back to search problems