Codeforces Round 1058 (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
2160 Codeforces Round 1058 (Div. 2) FINISHED False 9000 16125923 Oct. 12, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 17638 ) B Distinct Elements PROGRAMMING greedy math

Given an array (c), let (f(c)) be the number of distinct elements in (c). For example, (f(1,2,2)=2) because there are two distinct elements in (1,2,2): (1) and (2). Also, define (ci,j) as the subarray(^{\text{∗}}) of (c) bounded by positions (i) and (j) (that is, the array (c_i,c_{i+1},\ldots,c_j)). There is an array (a) of size (n). An array (b) of (n) elements is constructed such that (b_i=f(a1,i)+f(a2,i)+\ldots+f(ai,i)). You are given the array (b). Find any possible (a) with elements (1 \leq a_i \leq n). It is guaranteed that at least one possible (a) exists. (^{\text{∗}})An array (x) is a subarray of an array (y) if (x) can be obtained from (y) by the deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end. 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 an integer (n) ((1 \leq n \leq 10^5)) – the number of elements in (a) and (b). The second line of each test case contains (n) integers (b_1,b_2,\ldots,b_n) ((1 \leq b_i \leq 10^{18})). It is guaranteed that the sum of (n) over all test cases does not exceed (10^5). For each test case, print any possible (a) on a new line. The array (a) should satisfy (1\leq a_i\leq n). For every test case, it is guaranteed at least one (a) that satisfies the conditions exists. Let's verify our output for the second test case is correct: (b_1=f(2)=1) (b_2=f(2,3)+f(3)=2+1=3) (b_3=f(2,3,2)+f(3,2)+f(2)=2+2+1=5)

Tutorials

Codeforces Round 1058 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
343547850 tej11 B Oct. 13, 2025, 2:04 p.m. OK C# 13 TESTS 6 250 22630400
343472586 shaker-500 B Oct. 13, 2025, 6:10 a.m. OK C# 13 TESTS 6 311 17510400
343432251 VaHiX B Oct. 12, 2025, 9:01 p.m. OK C++17 (GCC 7-32) TESTS 6 46 3276800
343567579 aditya54ne B Oct. 13, 2025, 3:46 p.m. OK C++17 (GCC 7-32) TESTS 6 61 0
343479313 yashas2102 B Oct. 13, 2025, 7 a.m. OK C++17 (GCC 7-32) TESTS 6 61 0
343432018 djarnob12 B Oct. 12, 2025, 8:58 p.m. OK C++17 (GCC 7-32) TESTS 6 61 102400
343547560 koushiksonu012 B Oct. 13, 2025, 2:03 p.m. OK C++17 (GCC 7-32) TESTS 6 62 0
343625083 kunming B Oct. 14, 2025, 2:04 a.m. OK C++17 (GCC 7-32) TESTS 6 62 0
343617601 yoCandy B Oct. 13, 2025, 11:05 p.m. OK C++17 (GCC 7-32) TESTS 6 62 0
343613138 umm_okay B Oct. 13, 2025, 9:23 p.m. OK C++17 (GCC 7-32) TESTS 6 62 0
343585609 nishantawasthi175 B Oct. 13, 2025, 5:35 p.m. OK C++17 (GCC 7-32) TESTS 6 62 0
343515148 previously B Oct. 13, 2025, 11:21 a.m. OK C++17 (GCC 7-32) TESTS 6 62 0
343563703 Baumgartner B Oct. 13, 2025, 3:24 p.m. OK C++20 (GCC 13-64) TESTS 6 46 0
343568642 osmiyum B Oct. 13, 2025, 3:53 p.m. OK C++20 (GCC 13-64) TESTS 6 46 0
343466427 IanPardo B Oct. 13, 2025, 5:14 a.m. OK C++20 (GCC 13-64) TESTS 6 46 0
343619089 Anas_Ali. B Oct. 13, 2025, 11:54 p.m. OK C++20 (GCC 13-64) TESTS 6 61 0
343635020 Samarth_Udagi B Oct. 14, 2025, 3:57 a.m. OK C++20 (GCC 13-64) TESTS 6 61 0
343615328 callmeKakarot B Oct. 13, 2025, 10:04 p.m. OK C++20 (GCC 13-64) TESTS 6 61 0
343597547 PedroPacoca B Oct. 13, 2025, 6:48 p.m. OK C++20 (GCC 13-64) TESTS 6 61 0
343573252 mauryanand B Oct. 13, 2025, 4:20 p.m. OK C++20 (GCC 13-64) TESTS 6 61 0
343572881 codermaurya B Oct. 13, 2025, 4:18 p.m. OK C++20 (GCC 13-64) TESTS 6 61 0
343572351 Anandm123 B Oct. 13, 2025, 4:15 p.m. OK C++20 (GCC 13-64) TESTS 6 61 0
343442125 Mohammad_Shuvon B Oct. 13, 2025, 12:43 a.m. OK C++23 (GCC 14-64, msys2) TESTS 6 46 0
343465944 devendrasuryavanshi B Oct. 13, 2025, 5:09 a.m. OK C++23 (GCC 14-64, msys2) TESTS 6 46 0
343464633 vidhannahar B Oct. 13, 2025, 4:56 a.m. OK C++23 (GCC 14-64, msys2) TESTS 6 46 0
343439016 hungchi17 B Oct. 12, 2025, 11:14 p.m. OK C++23 (GCC 14-64, msys2) TESTS 6 46 0
343487385 bluish B Oct. 13, 2025, 7:58 a.m. OK C++23 (GCC 14-64, msys2) TESTS 6 46 307200
343441561 lianghengfei B Oct. 13, 2025, 12:28 a.m. OK C++23 (GCC 14-64, msys2) TESTS 6 46 512000
343517369 Asdezx B Oct. 13, 2025, 11:35 a.m. OK C++23 (GCC 14-64, msys2) TESTS 6 46 1638400
343574515 ttamx B Oct. 13, 2025, 4:28 p.m. OK C++23 (GCC 14-64, msys2) TESTS 6 61 0
343622426 claudlane B Oct. 14, 2025, 1:17 a.m. OK C++23 (GCC 14-64, msys2) TESTS 6 61 0
343585109 iam_Sarthak B Oct. 13, 2025, 5:31 p.m. OK C++23 (GCC 14-64, msys2) TESTS 6 61 0
343626118 asymptote314 B Oct. 14, 2025, 2:18 a.m. OK GNU C11 TESTS 6 437 1638400
343433331 Andrew_G6 B Oct. 12, 2025, 9:16 p.m. OK GNU C11 TESTS 6 452 1638400
343517092 KL2400031478 B Oct. 13, 2025, 11:33 a.m. OK GNU C11 TESTS 6 452 1740800
343433065 Andrew_G6 B Oct. 12, 2025, 9:12 p.m. OK GNU C11 TESTS 6 452 3276800
343433159 Andrew_G6 B Oct. 12, 2025, 9:13 p.m. OK GNU C11 TESTS 6 452 3276800
343559543 xXxNoobSaibotxXx B Oct. 13, 2025, 3:02 p.m. OK GNU C11 TESTS 6 468 921600
343456082 ddminh2607 B Oct. 13, 2025, 3:31 a.m. OK GNU C11 TESTS 6 468 2457600
343595143 infinte_13b B Oct. 13, 2025, 6:31 p.m. OK GNU C11 TESTS 6 483 819200
343592786 infinte_13b B Oct. 13, 2025, 6:17 p.m. OK GNU C11 TESTS 6 499 819200
343636531 Apon- B Oct. 14, 2025, 4:15 a.m. OK GNU C11 TESTS 6 843 1638400
343530386 Satyam_Arg B Oct. 13, 2025, 12:50 p.m. OK Java 21 TESTS 6 249 3276800
343581482 Tarun_chaudhary B Oct. 13, 2025, 5:08 p.m. OK Java 21 TESTS 6 265 102400
343612507 sakshams7778 B Oct. 13, 2025, 9:13 p.m. OK Java 21 TESTS 6 280 819200
343472177 keshav14 B Oct. 13, 2025, 6:06 a.m. OK Java 21 TESTS 6 281 716800
343428648 VaHiX B Oct. 12, 2025, 8:20 p.m. OK Java 21 TESTS 6 281 819200
343593249 rakshitsingh333 B Oct. 13, 2025, 6:20 p.m. OK Java 21 TESTS 6 281 1945600
343458885 tekka_ity B Oct. 13, 2025, 3:54 a.m. OK Java 21 TESTS 6 296 409600
343518864 Saucyy B Oct. 13, 2025, 11:44 a.m. OK Java 21 TESTS 6 296 716800
343544124 jacksparrow53536 B Oct. 13, 2025, 1:43 p.m. OK Java 21 TESTS 6 311 614400
343513897 Yunqq B Oct. 13, 2025, 11:13 a.m. OK Java 21 TESTS 6 311 819200
343463105 lupunish B Oct. 13, 2025, 4:38 a.m. OK Java 8 TESTS 6 171 3174400
343455159 ycnetsisnoc B Oct. 13, 2025, 3:22 a.m. OK Java 8 TESTS 6 296 0
343474175 NE0b01 B Oct. 13, 2025, 6:23 a.m. OK Java 8 TESTS 6 374 0
343458776 Shankzzz B Oct. 13, 2025, 3:53 a.m. OK Java 8 TESTS 6 421 0
343504743 manishpratap2205 B Oct. 13, 2025, 10:02 a.m. OK Java 8 TESTS 6 421 0
343562755 abhaysolanki1712 B Oct. 13, 2025, 3:19 p.m. OK Java 8 TESTS 6 437 0
343563139 abhaysolanki1712 B Oct. 13, 2025, 3:21 p.m. OK Java 8 TESTS 6 452 0
343514855 javeed_123 B Oct. 13, 2025, 11:19 a.m. OK Java 8 TESTS 6 452 0
343460525 akshita_0802 B Oct. 13, 2025, 4:10 a.m. OK Java 8 TESTS 6 452 0
343513690 Alekhya2508 B Oct. 13, 2025, 11:12 a.m. OK Java 8 TESTS 6 453 0
343482766 jagbarrameda B Oct. 13, 2025, 7:25 a.m. OK Kotlin 1.9 TESTS 6 249 7065600
343482614 jagbarrameda B Oct. 13, 2025, 7:24 a.m. OK Kotlin 1.9 TESTS 6 281 6963200
343428163 VaHiX B Oct. 12, 2025, 8:15 p.m. OK Kotlin 2.2 TESTS 6 374 8601600
343491099 ami_XR B Oct. 13, 2025, 8:24 a.m. OK PyPy 3 TESTS 6 296 13721600
343584886 opgod_07 B Oct. 13, 2025, 5:30 p.m. OK PyPy 3 TESTS 6 343 11673600
343597344 amn9130 B Oct. 13, 2025, 6:46 p.m. OK PyPy 3 TESTS 6 374 13619200
343633813 hando_Taiya B Oct. 14, 2025, 3:45 a.m. OK PyPy 3 TESTS 6 421 14336000
343560558 aa_despa B Oct. 13, 2025, 3:07 p.m. OK PyPy 3-64 TESTS 6 109 13414400
343590940 abuble_cheater B Oct. 13, 2025, 6:07 p.m. OK PyPy 3-64 TESTS 6 124 13926400
343434471 stephenwhawking343 B Oct. 12, 2025, 9:34 p.m. OK PyPy 3-64 TESTS 6 124 18636800
343567492 hugoback01 B Oct. 13, 2025, 3:46 p.m. OK PyPy 3-64 TESTS 6 139 17612800
343565882 Zephyr_Chan B Oct. 13, 2025, 3:36 p.m. OK PyPy 3-64 TESTS 6 140 15872000
343429131 jigitmax B Oct. 12, 2025, 8:24 p.m. OK PyPy 3-64 TESTS 6 140 17817600
343443502 paolaalmanzasaravia15 B Oct. 13, 2025, 1:15 a.m. OK PyPy 3-64 TESTS 6 140 22118400
343596039 nenavathshashi B Oct. 13, 2025, 6:37 p.m. OK PyPy 3-64 TESTS 6 155 17817600
343585376 henok_t_k B Oct. 13, 2025, 5:33 p.m. OK PyPy 3-64 TESTS 6 156 17408000
343426341 Arvind215271 B Oct. 12, 2025, 7:56 p.m. OK PyPy 3-64 TESTS 6 171 14131200
343478534 prithvijk.241 B Oct. 13, 2025, 6:54 a.m. OK Python 2 TESTS 6 186 8704000
343428729 VaHiX B Oct. 12, 2025, 8:21 p.m. OK Python 3 TESTS 6 124 15872000
343423600 yaxine001 B Oct. 12, 2025, 7:35 p.m. OK Python 3 TESTS 6 155 24371200
343431586 diehardx B Oct. 12, 2025, 8:53 p.m. OK Python 3 TESTS 6 155 32051200
343574456 RishantS B Oct. 13, 2025, 4:27 p.m. OK Python 3 TESTS 6 156 13004800
343575445 SteveCoder B Oct. 13, 2025, 4:33 p.m. OK Python 3 TESTS 6 171 14233600
343580582 Saugata123 B Oct. 13, 2025, 5:03 p.m. OK Python 3 TESTS 6 171 15667200
343483947 DivyMe B Oct. 13, 2025, 7:34 a.m. OK Python 3 TESTS 6 171 15667200
343619057 ANKUSH733 B Oct. 13, 2025, 11:53 p.m. OK Python 3 TESTS 6 187 14233600
343424608 mohamed_yassine_benali B Oct. 12, 2025, 7:42 p.m. OK Python 3 TESTS 6 187 24268800
343424505 yaxine001 B Oct. 12, 2025, 7:41 p.m. OK Python 3 TESTS 6 187 24268800
343643885 fr0st B Oct. 14, 2025, 5:39 a.m. OK Rust 2024 TESTS 6 77 204800

remove filters

Back to search problems