Codeforces Round 1114 (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
2254 Codeforces Round 1114 (Div. 3) FINISHED False 8100 2301884 Aug. 4, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 9741 ) D Silhouette PROGRAMMING constructive algorithms math sortings

Yousef has a secret array (a) of (n) strictly positive integers. For each element (a_i), its shadow (b_i) is the sum of all elements in (a) that are strictly smaller than (a_i). Formally: ()b_i = \sum_{\substack{1 \le j \le n\\ a_j \lt a_i}} a_j() You are given the shadow array (b). Your task is to reconstruct the lexicographically smallest valid array (a) consisting of strictly positive integers that satisfies the above condition. If no such array exists, output (-1). The first line contains an integer (t) ((1 \le t \le 10^4)) — the number of test cases. The first line of each test case contains an integer (n) ((1 \le n \le 2 \cdot 10^5)) — the size of the array. The second line of each test case contains (n) integers (b_1, b_2, \dots, b_n) ((0 \le b_i \le 2 \cdot 10^{14})) — the shadow array. It is guaranteed that the sum of (n) over all test cases does not exceed (2 \cdot 10^5). For each test case, output (n) integers (a_1, a_2, \dots, a_n) ((1 \le a_i \le 10^{18})) — the lexicographically smallest valid array (a) that satisfies the condition. If no valid array exists, output (-1) instead. In the first test case, the answer is (a = 1). Since there is only one element, there are no strictly smaller elements, so its shadow is (0). Thus (a=1) is valid. It is also lexicographically smallest, because the only allowed values are positive integers, and (1) is the smallest possible. In the second test case, the answer is (a = 2,5,2,5,6): For each (2), there is no smaller element in the array, so the shadow is (0). For each (5), the strictly smaller elements are the two (2)'s, so the shadow is (2+2=4). For (6), the strictly smaller elements are two (2)'s and two (5)'s, so the shadow is (2+2+5+5=14). Therefore the shadow array is exactly (b = 0,4,0,4,14). In the third test case, the shadow array fo

Tutorials

Tutorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
385804766 Ruhangrk D Aug. 5, 2026, 7:43 p.m. OK C++17 (GCC 7-32) TESTS 27 125 921600
385671141 thequantumguy D Aug. 4, 2026, 4:44 p.m. OK C++17 (GCC 7-32) TESTS 27 125 1740800
385801975 vishwateja_2006 D Aug. 5, 2026, 7:08 p.m. OK C++17 (GCC 7-32) TESTS 27 125 13721600
385720876 AlphaOrionis69 D Aug. 5, 2026, 5:56 a.m. OK C++17 (GCC 7-32) TESTS 27 125 53043200
385834639 Inventor2417 D Aug. 6, 2026, 5:01 a.m. OK C++17 (GCC 7-32) TESTS 27 140 921600
385805249 EliudGarcia D Aug. 5, 2026, 7:50 p.m. OK C++17 (GCC 7-32) TESTS 27 140 921600
385794428 ggop123_12 D Aug. 5, 2026, 6:06 p.m. OK C++17 (GCC 7-32) TESTS 27 140 921600
385672966 saloni3112 D Aug. 4, 2026, 4:47 p.m. OK C++17 (GCC 7-32) TESTS 27 140 921600
385824414 hudiejianlo D Aug. 6, 2026, 2:37 a.m. OK C++17 (GCC 7-32) TESTS 27 140 1024000
385817358 AyushPravin D Aug. 6, 2026, 1:02 a.m. OK C++17 (GCC 7-32) TESTS 27 140 1024000
385670649 hexahydride D Aug. 4, 2026, 4:43 p.m. OK C++20 (GCC 13-64) TESTS 27 78 8704000
385812754 apollodetailed D Aug. 5, 2026, 10:31 p.m. OK C++20 (GCC 13-64) TESTS 27 93 204800
385808901 AadiCodes D Aug. 5, 2026, 8:51 p.m. OK C++20 (GCC 13-64) TESTS 27 93 921600
385799031 panduwapanda D Aug. 5, 2026, 6:38 p.m. OK C++20 (GCC 13-64) TESTS 27 93 921600
385715181 feichai123 D Aug. 5, 2026, 4:40 a.m. OK C++20 (GCC 13-64) TESTS 27 93 921600
385674557 pilu D Aug. 4, 2026, 4:49 p.m. OK C++20 (GCC 13-64) TESTS 27 93 921600
385669782 adysh D Aug. 4, 2026, 4:42 p.m. OK C++20 (GCC 13-64) TESTS 27 93 921600
385833134 CraaazyShep D Aug. 6, 2026, 4:37 a.m. OK C++20 (GCC 13-64) TESTS 27 93 1024000
385814323 newvortex D Aug. 5, 2026, 11:25 p.m. OK C++20 (GCC 13-64) TESTS 27 93 1024000
385801016 naturalLog D Aug. 5, 2026, 6:58 p.m. OK C++20 (GCC 13-64) TESTS 27 93 1024000
385837018 ekta_kisu D Aug. 6, 2026, 5:37 a.m. OK C++23 (GCC 14-64, msys2) TESTS 27 93 1024000
385826468 Dalek_of_Rivia D Aug. 6, 2026, 3 a.m. OK C++23 (GCC 14-64, msys2) TESTS 27 93 1024000
385824491 turbash D Aug. 6, 2026, 2:38 a.m. OK C++23 (GCC 14-64, msys2) TESTS 27 93 1024000
385822943 Liooow D Aug. 6, 2026, 2:21 a.m. OK C++23 (GCC 14-64, msys2) TESTS 27 93 1024000
385819784 Sidhu2oo5 D Aug. 6, 2026, 1:45 a.m. OK C++23 (GCC 14-64, msys2) TESTS 27 93 1024000
385812466 xoceankingx D Aug. 5, 2026, 10:21 p.m. OK C++23 (GCC 14-64, msys2) TESTS 27 93 1024000
385809610 omar3bdelgaid D Aug. 5, 2026, 9:06 p.m. OK C++23 (GCC 14-64, msys2) TESTS 27 93 1024000
385803393 uv6848356 D Aug. 5, 2026, 7:25 p.m. OK C++23 (GCC 14-64, msys2) TESTS 27 93 1024000
385803280 xelix D Aug. 5, 2026, 7:23 p.m. OK C++23 (GCC 14-64, msys2) TESTS 27 93 1024000
385794357 KIRAKOSYAN D Aug. 5, 2026, 6:06 p.m. OK C++23 (GCC 14-64, msys2) TESTS 27 93 1024000
385689183 NenadDapic D Aug. 4, 2026, 8:12 p.m. OK FPC TESTS 27 390 20889600
385816234 Shadow_Dragoon D Aug. 6, 2026, 12:35 a.m. OK Go TESTS 27 203 19046400
385672631 daidao D Aug. 4, 2026, 4:47 p.m. OK Go TESTS 27 250 9318400
385830629 sriram_18 D Aug. 6, 2026, 3:54 a.m. OK Java 21 TESTS 27 281 1945600
385670206 Sybaul D Aug. 4, 2026, 4:43 p.m. OK Java 21 TESTS 27 343 5427200
385833797 Mega6776 D Aug. 6, 2026, 4:48 a.m. OK Java 21 TESTS 27 343 8089600
385671048 Nainwal2005 D Aug. 4, 2026, 4:44 p.m. OK Java 21 TESTS 27 359 2662400
385673722 gadrilee D Aug. 4, 2026, 4:48 p.m. OK Java 21 TESTS 27 390 10342400
385672252 justsaurab D Aug. 4, 2026, 4:46 p.m. OK Java 21 TESTS 27 421 1843200
385699143 neilchetty D Aug. 4, 2026, 11:55 p.m. OK Java 21 TESTS 27 421 15872000
385715456 shyamPrajapat D Aug. 5, 2026, 4:45 a.m. OK Java 21 TESTS 27 468 7270400
385696280 biplav D Aug. 4, 2026, 10:46 p.m. OK Java 21 TESTS 27 500 26521600
385814767 orzMe D Aug. 5, 2026, 11:41 p.m. OK Java 21 TESTS 27 578 37683200
385673922 abhayrajnegi0416 D Aug. 4, 2026, 4:49 p.m. OK Java 8 TESTS 27 625 63488000
385802388 leonlian D Aug. 5, 2026, 7:13 p.m. OK Java 8 TESTS 27 640 21196800
385801097 Yaser2004 D Aug. 5, 2026, 6:58 p.m. OK Java 8 TESTS 27 1015 28672000
385669999 beluga9 D Aug. 4, 2026, 4:42 p.m. OK Java 8 TESTS 27 1156 22732800
385673637 MJ07 D Aug. 4, 2026, 4:48 p.m. OK Mono C# TESTS 27 562 72396800
385699293 so_crates_83 D Aug. 4, 2026, 11:59 p.m. OK Node.js TESTS 27 2406 132096000
385831701 yilei86 D Aug. 6, 2026, 4:13 a.m. OK PyPy 3-64 TESTS 27 203 35635200
385718461 Vaddu.99 D Aug. 5, 2026, 5:25 a.m. OK PyPy 3-64 TESTS 27 218 31539200
385813635 VGCos D Aug. 5, 2026, 11:02 p.m. OK PyPy 3-64 TESTS 27 234 40140800
385828132 Shadow_tree D Aug. 6, 2026, 3:18 a.m. OK PyPy 3-64 TESTS 27 296 30617600
385672651 Celeb17 D Aug. 4, 2026, 4:47 p.m. OK PyPy 3-64 TESTS 27 296 52736000
385674549 infovarius D Aug. 4, 2026, 4:49 p.m. OK PyPy 3-64 TESTS 27 312 38400000
385834698 ac_ning D Aug. 6, 2026, 5:02 a.m. OK PyPy 3-64 TESTS 27 312 40243200
385814182 explainer D Aug. 5, 2026, 11:20 p.m. OK PyPy 3-64 TESTS 27 312 50995200
385836023 moshee_moshee D Aug. 6, 2026, 5:22 a.m. OK PyPy 3-64 TESTS 27 328 40960000
385802841 Machine1569 D Aug. 5, 2026, 7:18 p.m. OK PyPy 3-64 TESTS 27 328 41676800
385796645 gareeb_baniya D Aug. 5, 2026, 6:21 p.m. OK Python 3 TESTS 27 437 54067200
385798474 Anshhhhhh D Aug. 5, 2026, 6:33 p.m. OK Python 3 TESTS 27 546 42393600
385672793 rohit_02 D Aug. 4, 2026, 4:47 p.m. OK Python 3 TESTS 27 562 55500800
385669931 Leo25Darklight D Aug. 4, 2026, 4:42 p.m. OK Python 3 TESTS 27 593 79769600
385671629 amateurcoder015 D Aug. 4, 2026, 4:45 p.m. OK Python 3 TESTS 27 687 43212800
385716251 Ekshith D Aug. 5, 2026, 4:57 a.m. OK Python 3 TESTS 27 703 29184000
385669861 srinithreddy322 D Aug. 4, 2026, 4:42 p.m. OK Python 3 TESTS 27 703 31129600
385832643 chmpro D Aug. 6, 2026, 4:29 a.m. OK Python 3 TESTS 27 703 42598400
385672280 EmeraldBeast D Aug. 4, 2026, 4:46 p.m. OK Python 3 TESTS 27 781 45875200
385669236 Vinayyyyy D Aug. 4, 2026, 4:41 p.m. OK Python 3 TESTS 27 828 41676800
385747116 MIRZAPURI D Aug. 5, 2026, 10:58 a.m. OK Rust 2024 TESTS 27 62 6144000
385823928 kroyl D Aug. 6, 2026, 2:31 a.m. OK Rust 2024 TESTS 27 62 13516800
385672549 ivantdev D Aug. 4, 2026, 4:47 p.m. OK Rust 2024 TESTS 27 78 13004800
385812210 ceadrianguevara2004 D Aug. 5, 2026, 10:13 p.m. OK Rust 2024 TESTS 27 125 34918400
385795434 honeycrux D Aug. 5, 2026, 6:13 p.m. OK Rust 2024 TESTS 27 156 16896000

remove filters

Back to search problems