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 |
---|---|---|---|---|---|---|
1905 | Codeforces Round 915 (Div. 2) | FINISHED | False | 7200 | 29085899 | Dec. 16, 2023, 2:35 p.m. |
Solved$ |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
---|---|---|---|---|---|---|
( 3911 ) | D | Cyclic MEX | PROGRAMMING | binary search constructive algorithms data structures implementation math two pointers |
B'For an array a , define its cost as sum_{i=1}^{n} operatorname{mex} ^ dagger ([a_1,a_2, ldots,a_i]) . You are given a permutation ^ ddagger p of the set {0,1,2, ldots,n-1 } . Find the maximum cost across all cyclic shifts of p . ^ dagger operatorname{mex}([b_1,b_2, ldots,b_m]) is the smallest non-negative integer x such that x does not occur among b_1,b_2, ldots,b_m . ^ ddagger A permutation of the set {0,1,2,...,n-1 } is an array consisting of n distinct integers from 0 to n-1 in arbitrary order. For example, [1,2,0,4,3] is a permutation, but [0,1,1] is not a permutation ( 1 appears twice in the array), and [0,2,3] is also not a permutation ( n=3 but there is 3 in the array). Each test consists of multiple test cases. The first line contains a single integer t ( 1 <= t <= 10^5 ) -- the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer n ( 1 <= n <= 10^6 ) -- the length of the permutation p . The second line of each test case contain n distinct integers p_1, p_2, ldots, p_n ( 0 <= p_i < n ) -- the elements of the permutation p . It is guaranteed that sum of n over all test cases does not exceed 10^6 . For each test case, output a single integer -- the maximum cost across all cyclic shifts of p . In the first test case, the cyclic shift that yields the maximum cost is [2,1,0,5,4,3] with cost 0+0+3+3+3+6=15 . In the second test case, the cyclic shift that yields the maximum cost is [0,2,1] with cost 1+1+3=5 . '... |
Codeforces Round 915 (Div. 2) Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
---|---|---|---|---|---|---|---|---|---|---|---|
237534077 | rhdqor213 | D | Dec. 16, 2023, 5:34 p.m. | OK | GNU C11 | TESTS | 20 | 202 | 11980800 | ||
237565469 | 2022hanscome | D | Dec. 17, 2023, 3:51 a.m. | OK | GNU C++14 | TESTS | 20 | 249 | 13824000 | ||
237534806 | Yzm007 | D | Dec. 16, 2023, 5:40 p.m. | OK | GNU C++14 | TESTS | 20 | 249 | 20070400 | ||
237529378 | jokervn078 | D | Dec. 16, 2023, 4:59 p.m. | OK | GNU C++14 | TESTS | 20 | 249 | 80281600 | ||
237518914 | Geoyster | D | Dec. 16, 2023, 4:12 p.m. | OK | GNU C++14 | TESTS | 20 | 264 | 11980800 | ||
237528596 | ABO_isinused | D | Dec. 16, 2023, 4:56 p.m. | OK | GNU C++14 | TESTS | 20 | 280 | 12083200 | ||
237560950 | Coder2020HCY | D | Dec. 17, 2023, 2:06 a.m. | OK | GNU C++14 | TESTS | 20 | 280 | 12800000 | ||
237537560 | TrendBattles | D | Dec. 16, 2023, 6:06 p.m. | OK | GNU C++14 | TESTS | 20 | 280 | 16793600 | ||
237546021 | Naman_Agarwal_03 | D | Dec. 16, 2023, 7:42 p.m. | OK | GNU C++14 | TESTS | 20 | 280 | 30617600 | ||
237521464 | BobZheng | D | Dec. 16, 2023, 4:20 p.m. | OK | GNU C++14 | TESTS | 20 | 295 | 30617600 | ||
237546624 | r_75 | D | Dec. 16, 2023, 7:51 p.m. | OK | GNU C++14 | TESTS | 20 | 296 | 25497600 | ||
237561509 | Hydroxythio | D | Dec. 17, 2023, 2:21 a.m. | OK | GNU C++17 | TESTS | 20 | 61 | 69529600 | ||
237521514 | Sochu | D | Dec. 16, 2023, 4:20 p.m. | OK | GNU C++17 | TESTS | 20 | 93 | 40140800 | ||
237563808 | peteza | D | Dec. 17, 2023, 3:16 a.m. | OK | GNU C++17 | TESTS | 20 | 249 | 11366400 | ||
237559667 | Xiaozzz | D | Dec. 17, 2023, 1:31 a.m. | OK | GNU C++17 | TESTS | 20 | 249 | 15872000 | ||
237524700 | Mikey_Gojo | D | Dec. 16, 2023, 4:29 p.m. | OK | GNU C++17 | TESTS | 20 | 264 | 11571200 | ||
237551145 | cs142857 | D | Dec. 16, 2023, 9:05 p.m. | OK | GNU C++17 | TESTS | 20 | 264 | 11571200 | ||
237515258 | naiij | D | Dec. 16, 2023, 4:02 p.m. | OK | GNU C++17 | TESTS | 20 | 264 | 12083200 | ||
237563125 | MinhHoangLe | D | Dec. 17, 2023, 3:01 a.m. | OK | GNU C++17 | TESTS | 20 | 264 | 16691200 | ||
237530191 | the_mhh | D | Dec. 16, 2023, 5:03 p.m. | OK | GNU C++17 | TESTS | 20 | 264 | 29388800 | ||
237566182 | Radiaa | D | Dec. 17, 2023, 4:08 a.m. | OK | GNU C++17 | TESTS | 20 | 264 | 36659200 | ||
237532570 | areason | D | Dec. 16, 2023, 5:20 p.m. | OK | GNU C++17 (64) | TESTS | 20 | 77 | 22016000 | ||
237560953 | Once_I_Liked_AGirl | D | Dec. 17, 2023, 2:06 a.m. | OK | GNU C++17 (64) | TESTS | 20 | 156 | 11571200 | ||
237538799 | jahid_hridoy | D | Dec. 16, 2023, 6:18 p.m. | OK | GNU C++17 (64) | TESTS | 20 | 156 | 23552000 | ||
237550042 | y_combinator | D | Dec. 16, 2023, 8:45 p.m. | OK | GNU C++17 (64) | TESTS | 20 | 171 | 19046400 | ||
237531220 | AverageAmogusEnjoyer | D | Dec. 16, 2023, 5:10 p.m. | OK | GNU C++17 (64) | TESTS | 20 | 171 | 20172800 | ||
237560049 | Angriliset | D | Dec. 17, 2023, 1:42 a.m. | OK | GNU C++17 (64) | TESTS | 20 | 171 | 21708800 | ||
237536114 | wxgmjfhy | D | Dec. 16, 2023, 5:53 p.m. | OK | GNU C++17 (64) | TESTS | 20 | 171 | 24064000 | ||
237530463 | wuyoudexian | D | Dec. 16, 2023, 5:05 p.m. | OK | GNU C++17 (64) | TESTS | 20 | 171 | 24064000 | ||
237522380 | Nghiaaa | D | Dec. 16, 2023, 4:22 p.m. | OK | GNU C++17 (64) | TESTS | 20 | 171 | 29696000 | ||
237564691 | drdilyor | D | Dec. 17, 2023, 3:36 a.m. | OK | GNU C++17 (64) | TESTS | 20 | 171 | 30310400 | ||
237564431 | FlowRays | D | Dec. 17, 2023, 3:30 a.m. | OK | GNU C++20 (64) | TESTS | 20 | 62 | 41676800 | ||
237529539 | marc2825 | D | Dec. 16, 2023, 4:59 p.m. | OK | GNU C++20 (64) | TESTS | 20 | 78 | 19251200 | ||
237543379 | ...Esha... | D | Dec. 16, 2023, 7:08 p.m. | OK | GNU C++20 (64) | TESTS | 20 | 139 | 18739200 | ||
237529556 | mbae059 | D | Dec. 16, 2023, 4:59 p.m. | OK | GNU C++20 (64) | TESTS | 20 | 139 | 22937600 | ||
237548803 | AshrafYousry | D | Dec. 16, 2023, 8:24 p.m. | OK | GNU C++20 (64) | TESTS | 20 | 139 | 23347200 | ||
237532011 | ov_vo | D | Dec. 16, 2023, 5:15 p.m. | OK | GNU C++20 (64) | TESTS | 20 | 139 | 48128000 | ||
237518799 | atodo | D | Dec. 16, 2023, 4:12 p.m. | OK | GNU C++20 (64) | TESTS | 20 | 140 | 11878400 | ||
237547878 | VectorViking | D | Dec. 16, 2023, 8:10 p.m. | OK | GNU C++20 (64) | TESTS | 20 | 140 | 11980800 | ||
237533390 | fyh20 | D | Dec. 16, 2023, 5:27 p.m. | OK | GNU C++20 (64) | TESTS | 20 | 140 | 12083200 | ||
237567449 | fyh20 | D | Dec. 17, 2023, 4:35 a.m. | OK | GNU C++20 (64) | TESTS | 20 | 140 | 12083200 | ||
237518949 | lorenzotinfena | D | Dec. 16, 2023, 4:12 p.m. | OK | Go | TESTS | 20 | 686 | 129433600 | ||
237517566 | etian6795 | D | Dec. 16, 2023, 4:08 p.m. | OK | Java 11 | TESTS | 20 | 529 | 51609600 | ||
237526548 | KlayThompson11 | D | Dec. 16, 2023, 4:34 p.m. | OK | Java 11 | TESTS | 20 | 1918 | 143462400 | ||
237551109 | BlizGale | D | Dec. 16, 2023, 9:04 p.m. | OK | Java 17 | TESTS | 20 | 1123 | 148889600 | ||
237551196 | BlizGale | D | Dec. 16, 2023, 9:06 p.m. | OK | Java 17 | TESTS | 20 | 1404 | 148377600 | ||
237558489 | CutSandstone | D | Dec. 17, 2023, 12:50 a.m. | OK | Java 17 | TESTS | 20 | 1996 | 79974400 | ||
237520436 | vijaypanwar_12 | D | Dec. 16, 2023, 4:17 p.m. | OK | Java 21 | TESTS | 20 | 733 | 68915200 | ||
237516033 | warks | D | Dec. 16, 2023, 4:04 p.m. | OK | Java 21 | TESTS | 20 | 1513 | 86528000 | ||
237518492 | amaturecoder | D | Dec. 16, 2023, 4:11 p.m. | OK | Java 8 | TESTS | 20 | 421 | 73318400 | ||
237528659 | vijay_panwar12 | D | Dec. 16, 2023, 4:56 p.m. | OK | Java 8 | TESTS | 20 | 623 | 65740800 | ||
237529314 | American_Eagle | D | Dec. 16, 2023, 4:58 p.m. | OK | Java 8 | TESTS | 20 | 1356 | 102297600 | ||
237528841 | diamond5687 | D | Dec. 16, 2023, 4:57 p.m. | OK | Java 8 | TESTS | 20 | 1388 | 102297600 | ||
237561295 | cc4414 | D | Dec. 17, 2023, 2:16 a.m. | OK | Java 8 | TESTS | 20 | 1871 | 203571200 | ||
237517319 | chekurisrinivasavarma | D | Dec. 16, 2023, 4:08 p.m. | OK | PyPy 3 | TESTS | 20 | 483 | 87142400 | ||
237562792 | conqueror_of_womais | D | Dec. 17, 2023, 2:52 a.m. | OK | PyPy 3 | TESTS | 20 | 1388 | 108851200 | ||
237562577 | Mukundan314 | D | Dec. 17, 2023, 2:47 a.m. | OK | PyPy 3-64 | TESTS | 20 | 327 | 94822400 | ||
237551418 | ossau_guildo | D | Dec. 16, 2023, 9:10 p.m. | OK | PyPy 3-64 | TESTS | 20 | 420 | 142745600 | ||
237569543 | nehan_der_thal | D | Dec. 17, 2023, 5:14 a.m. | OK | PyPy 3-64 | TESTS | 20 | 436 | 106905600 | ||
237522768 | blue_ice_yj | D | Dec. 16, 2023, 4:24 p.m. | OK | PyPy 3-64 | TESTS | 20 | 436 | 110080000 | ||
237548198 | Jayg000e | D | Dec. 16, 2023, 8:14 p.m. | OK | PyPy 3-64 | TESTS | 20 | 436 | 124108800 | ||
237565811 | AyuAnchor | D | Dec. 17, 2023, 3:59 a.m. | OK | PyPy 3-64 | TESTS | 20 | 452 | 131379200 | ||
237524312 | alxwen711 | D | Dec. 16, 2023, 4:28 p.m. | OK | PyPy 3-64 | TESTS | 20 | 467 | 106905600 | ||
237523900 | Remineva | D | Dec. 16, 2023, 4:27 p.m. | OK | PyPy 3-64 | TESTS | 20 | 499 | 105984000 | ||
237522836 | toam | D | Dec. 16, 2023, 4:24 p.m. | OK | PyPy 3-64 | TESTS | 20 | 545 | 120320000 | ||
237518076 | PyIsTheBestLang | D | Dec. 16, 2023, 4:10 p.m. | OK | PyPy 3-64 | TESTS | 20 | 623 | 126668800 | ||
237515746 | toor | D | Dec. 16, 2023, 4:03 p.m. | OK | Rust 2021 | TESTS | 20 | 1122 | 40140800 |
Back to search problems