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 |
|---|---|---|---|---|---|---|
| 2227 | Codeforces Round 1096 (Div. 3) | FINISHED | False | 9000 | 2820287 | April 30, 2026, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 3634 ) | F | It Just Keeps Going Sideways | PROGRAMMING | data structures dp greedy math |
Yousef has (n) columns of cubes standing side by side. The (i)-th column contains (a_i) identical unit cubes stacked vertically. Initially gravity pulls cubes downwards, so every column (i) contains exactly (a_i) cubes at heights (1, 2, \dots, a_i). Suddenly, gravity shifts to the right. Each cube slides horizontally as far to the right as possible. A cube cannot pass through or overlap other cubes, and it must remain at its original height. The final configuration is uniquely determined by the initial heights. Before the gravity shift, Yousef may perform at most one operation: choose an index (i) and decrease (a_i) by (1) (i.e. remove one cube from that column). He may also choose to do nothing. A cube's movement distance is defined as (|j - i|), where (i) is its original column index and (j) is its column index after the gravity shift. Find the maximum possible total movement distance (the sum of the movement distances of all remaining cubes) Yousef can achieve. The first line contains an integer (t) ((1 \le t \le 10^4)) — 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 \le n \le 2 \cdot 10^5)) — the length of the array. The second line of each test case contains (n) integers (a_1, a_2, \dots, a_n) ((1 \le a_i \le n)) — the elements of the 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 a single integer — the maximum possible total movement distance (the sum of the movement distances of all remaining cubes) Yousef can achieve. In the first test case, the initial total movement distance is (5). If Yousef removes the cube at index (5), the array becomes (1, 2, 3, 2, 0). Because the fifth column is now empty, all cubes from the first four columns are able to slide further to the right than they could |
| Codeforces Round 1096 (Div. 3) — Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 373161004 | Do_not_ask_why | F | April 30, 2026, 5:04 p.m. | OK | C++17 (GCC 7-32) | TESTS | 9 | 62 | 0 | ||
| 373160994 | iMa7moud | F | April 30, 2026, 5:04 p.m. | OK | C++17 (GCC 7-32) | TESTS | 9 | 62 | 0 | ||
| 373160438 | CalculusSucks | F | April 30, 2026, 5:03 p.m. | OK | C++17 (GCC 7-32) | TESTS | 9 | 62 | 0 | ||
| 373159423 | okhvgo | F | April 30, 2026, 5 p.m. | OK | C++17 (GCC 7-32) | TESTS | 9 | 62 | 0 | ||
| 373158687 | ililog | F | April 30, 2026, 4:58 p.m. | OK | C++17 (GCC 7-32) | TESTS | 9 | 62 | 0 | ||
| 373157807 | Abdelhalem_Yahya | F | April 30, 2026, 4:55 p.m. | OK | C++17 (GCC 7-32) | TESTS | 9 | 62 | 0 | ||
| 373154628 | ayushbathra18 | F | April 30, 2026, 4:44 p.m. | OK | C++17 (GCC 7-32) | TESTS | 9 | 62 | 0 | ||
| 373150022 | Dibbo1 | F | April 30, 2026, 4:30 p.m. | OK | C++17 (GCC 7-32) | TESTS | 9 | 62 | 0 | ||
| 373149844 | TarekHany | F | April 30, 2026, 4:29 p.m. | OK | C++17 (GCC 7-32) | TESTS | 9 | 62 | 0 | ||
| 373149167 | Sqoon. | F | April 30, 2026, 4:27 p.m. | OK | C++17 (GCC 7-32) | TESTS | 9 | 62 | 0 |
Back to search problems