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 |
|---|---|---|---|---|---|---|
| 2239 | Codeforces Round 1105 (Div. 1) | FINISHED | False | 9000 | 4029884 | June 27, 2026, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 6954 ) | B | Decidophobia | PROGRAMMING | greedy sortings two pointers |
There are (n) people attending a round-table party, numbered (1, 2, 3, \ldots, n) in clockwise order. You have prepared some gifts to distribute among them. Each person (i) has a weight (a_i) and a common field of view (d). The field of view for person (i) consists of the (d) people sitting clockwise and the (d) people sitting counter-clockwise from them (a total of (2d) people excluding person (i)). The happiness gained by person (i) is determined by the following rules: If person (i) receives a gift, and there are (x) people within their field of view who did not receive a gift, they gain (x \cdot a_i) happiness. If person (i) does not receive a gift, and there are (x) people within their field of view who received a gift, they incur (-x \cdot a_i) happiness. You want to maximize the total happiness of all (n) people combined. Find this maximum value. 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 (d) ((3 \le n \le 2 \cdot 10^5), (1 \le d \lt \frac{n}{2})). The second line contains (n) integers (a_1, a_2, \ldots, a_n) ((1 \le a_i \le 10^8)), where (a_i) is the weight of the (i)-th person. It is guaranteed that the sum of (n) over all test cases does not exceed (10^6). For each test case, output a single integer representing the maximum total happiness. In the first test case, there are 3 people sitting in a circle. For each person (i), the field of view is (d=1), which includes the 1 person sitting clockwise and the 1 person sitting counter-clockwise from them. If person 2 receives the gift, they gain happiness from 2 neighbors who did not receive it, resulting in (2 \cdot a_2 = 2 \cdot 2 = 4). However, person 1 and person 3 incur loss because they d |
| Codeforces Round 1105 (Div. 1, Div. 2) Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 380336280 | -firefly- | B | June 27, 2026, 3:04 p.m. | OK | C# 13 | TESTS | 7 | 343 | 29798400 | ||
| 380333252 | oceeff | B | June 27, 2026, 2:57 p.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 171 | 11776000 | ||
| 380357638 | knightL | B | June 27, 2026, 4:04 p.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 203 | 3993600 | ||
| 380337703 | WisedomCasual | B | June 27, 2026, 3:07 p.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 218 | 0 | ||
| 380334052 | chen_weilian | B | June 27, 2026, 2:59 p.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 218 | 1740800 | ||
| 380355281 | TSU-001 | B | June 27, 2026, 3:55 p.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 218 | 4812800 | ||
| 380380838 | GregCodez | B | June 27, 2026, 7 p.m. | OK | C++17 (GCC 7-32) | TESTS | 9 | 234 | 0 | ||
| 380350366 | TheRaptor0225 | B | June 27, 2026, 3:39 p.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 234 | 0 | ||
| 380329881 | vid | B | June 27, 2026, 2:51 p.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 234 | 921600 | ||
| 380337849 | Min_27 | B | June 27, 2026, 3:07 p.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 234 | 1638400 | ||
| 380340579 | TiLTovozzik | B | June 27, 2026, 3:13 p.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 234 | 5836800 | ||
| 380327827 | shiomusubi496 | B | June 27, 2026, 2:47 p.m. | OK | C++20 (GCC 13-64) | TESTS | 7 | 78 | 3072000 | ||
| 380409190 | Milkcat2009 | B | June 28, 2026, 3:13 a.m. | OK | C++20 (GCC 13-64) | TESTS | 9 | 78 | 14131200 | ||
| 380346472 | kaichou243 | B | June 27, 2026, 3:28 p.m. | OK | C++20 (GCC 13-64) | TESTS | 7 | 93 | 5017600 | ||
| 380329223 | BoaHancock | B | June 27, 2026, 2:50 p.m. | OK | C++20 (GCC 13-64) | TESTS | 7 | 93 | 7475200 | ||
| 380337082 | lbmzxhb | B | June 27, 2026, 3:05 p.m. | OK | C++20 (GCC 13-64) | TESTS | 7 | 93 | 9625600 | ||
| 380327106 | permutation | B | June 27, 2026, 2:46 p.m. | OK | C++20 (GCC 13-64) | TESTS | 7 | 93 | 16179200 | ||
| 380342509 | DylanSmith | B | June 27, 2026, 3:18 p.m. | OK | C++20 (GCC 13-64) | TESTS | 7 | 171 | 0 | ||
| 380329551 | NotOnlySuccess | B | June 27, 2026, 2:50 p.m. | OK | C++20 (GCC 13-64) | TESTS | 7 | 171 | 204800 | ||
| 380329893 | Unlimited_zero | B | June 27, 2026, 2:51 p.m. | OK | C++20 (GCC 13-64) | TESTS | 7 | 171 | 4096000 | ||
| 380340498 | zrl123456 | B | June 27, 2026, 3:13 p.m. | OK | C++20 (GCC 13-64) | TESTS | 7 | 171 | 6451200 | ||
| 380335586 | www_bilibili_com | B | June 27, 2026, 3:02 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 7 | 46 | 4198400 | ||
| 380327121 | 2sqrt3 | B | June 27, 2026, 2:46 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 7 | 62 | 3788800 | ||
| 380330598 | Sulfox | B | June 27, 2026, 2:52 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 7 | 78 | 4915200 | ||
| 380327681 | maspy | B | June 27, 2026, 2:47 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 7 | 78 | 7680000 | ||
| 380330820 | woyebuzhidaowoshishui | B | June 27, 2026, 2:53 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 7 | 78 | 8601600 | ||
| 380343140 | LastKismet | B | June 27, 2026, 3:19 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 7 | 78 | 10137600 | ||
| 380333656 | iforandom | B | June 27, 2026, 2:58 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 7 | 78 | 10137600 | ||
| 380332896 | gunuozhang | B | June 27, 2026, 2:57 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 7 | 93 | 4300800 | ||
| 380343904 | Pt.ll | B | June 27, 2026, 3:21 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 7 | 125 | 1638400 | ||
| 380337447 | KIRIJIJI | B | June 27, 2026, 3:06 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 7 | 156 | 5632000 | ||
| 380327470 | hos.lyric | B | June 27, 2026, 2:47 p.m. | OK | D | TESTS | 7 | 328 | 51200000 | ||
| 380331374 | Gassa | B | June 27, 2026, 2:54 p.m. | OK | D | TESTS | 7 | 390 | 90828800 | ||
| 380388244 | nokib | B | June 27, 2026, 8:16 p.m. | OK | GNU C11 | TESTS | 9 | 250 | 1740800 | ||
| 380349999 | 101Noir | B | June 27, 2026, 3:38 p.m. | OK | Go | TESTS | 7 | 437 | 12697600 | ||
| 380372322 | Sumit_y_04nov | B | June 27, 2026, 5:21 p.m. | OK | Java 21 | TESTS | 7 | 234 | 6553600 | ||
| 380375280 | Kraken24 | B | June 27, 2026, 5:53 p.m. | OK | Java 21 | TESTS | 8 | 234 | 8908800 | ||
| 380331849 | gofrozen21 | B | June 27, 2026, 2:54 p.m. | OK | Java 21 | TESTS | 7 | 265 | 0 | ||
| 380331710 | nathanballman | B | June 27, 2026, 2:54 p.m. | OK | Java 21 | TESTS | 7 | 453 | 819200 | ||
| 380330324 | LT1 | B | June 27, 2026, 2:52 p.m. | OK | Java 21 | TESTS | 7 | 515 | 8396800 | ||
| 380344668 | malachi_toney_goat | B | June 27, 2026, 3:23 p.m. | OK | Java 8 | TESTS | 7 | 296 | 10137600 | ||
| 380341935 | hardgonnapass | B | June 27, 2026, 3:16 p.m. | OK | Java 8 | TESTS | 7 | 312 | 0 | ||
| 380325944 | arvindf232 | B | June 27, 2026, 2:44 p.m. | OK | Kotlin 2.2 | TESTS | 7 | 296 | 9728000 | ||
| 380341608 | bitplease_ | B | June 27, 2026, 3:16 p.m. | OK | Node.js | TESTS | 7 | 234 | 34099200 | ||
| 380332728 | sos89756 | B | June 27, 2026, 2:56 p.m. | OK | PyPy 3 | TESTS | 7 | 1593 | 143667200 | ||
| 380328195 | AdTerram | B | June 27, 2026, 2:48 p.m. | OK | PyPy 3-64 | TESTS | 7 | 218 | 43417600 | ||
| 380391659 | TheAppleTree | B | June 27, 2026, 8:46 p.m. | OK | PyPy 3-64 | TESTS | 9 | 218 | 44851200 | ||
| 380337457 | Friedrich | B | June 27, 2026, 3:06 p.m. | OK | PyPy 3-64 | TESTS | 7 | 218 | 59801600 | ||
| 380379508 | actuallykarthik | B | June 27, 2026, 6:42 p.m. | OK | PyPy 3-64 | TESTS | 9 | 234 | 66560000 | ||
| 380334465 | harurun4635 | B | June 27, 2026, 3 p.m. | OK | PyPy 3-64 | TESTS | 7 | 265 | 32051200 | ||
| 380342019 | jimini23kjm | B | June 27, 2026, 3:16 p.m. | OK | PyPy 3-64 | TESTS | 7 | 265 | 93798400 | ||
| 380374954 | BhaveshGupta1308 | B | June 27, 2026, 5:50 p.m. | OK | PyPy 3-64 | TESTS | 8 | 281 | 36761600 | ||
| 380349831 | stan23456 | B | June 27, 2026, 3:37 p.m. | OK | PyPy 3-64 | TESTS | 7 | 281 | 43827200 | ||
| 380328530 | toam | B | June 27, 2026, 2:48 p.m. | OK | PyPy 3-64 | TESTS | 7 | 296 | 35737600 | ||
| 380353084 | twosquares | B | June 27, 2026, 3:47 p.m. | OK | PyPy 3-64 | TESTS | 7 | 296 | 61030400 | ||
| 380332697 | maworkin | B | June 27, 2026, 2:56 p.m. | OK | Python 3 | TESTS | 7 | 578 | 78438400 | ||
| 380334421 | Midhilesh | B | June 27, 2026, 2:59 p.m. | OK | Python 3 | TESTS | 7 | 750 | 70758400 | ||
| 380333578 | sansen | B | June 27, 2026, 2:58 p.m. | OK | Rust 2021 | TESTS | 7 | 78 | 30003200 | ||
| 380352633 | darkkcyan | B | June 27, 2026, 3:46 p.m. | OK | Rust 2024 | TESTS | 7 | 62 | 3891200 | ||
| 380355923 | cvs-650 | B | June 27, 2026, 3:57 p.m. | OK | Rust 2024 | TESTS | 7 | 62 | 5632000 | ||
| 380337598 | DanielAnker | B | June 27, 2026, 3:06 p.m. | OK | Rust 2024 | TESTS | 7 | 78 | 7372800 | ||
| 380335367 | Solalyth | B | June 27, 2026, 3:02 p.m. | OK | Rust 2024 | TESTS | 7 | 78 | 27443200 | ||
| 380329036 | Egor | B | June 27, 2026, 2:49 p.m. | OK | Rust 2024 | TESTS | 7 | 93 | 9318400 | ||
| 380345449 | qwerty787788 | B | June 27, 2026, 3:25 p.m. | OK | Rust 2024 | TESTS | 7 | 468 | 12595200 |
Back to search problems