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 |
|---|---|---|---|---|---|---|
| 2229 | Spectral::Cup 2026 Round 2 (Codeforces Round 1100, Div. 1 + Div. 2) | FINISHED | False | 10800 | 833086 | May 23, 2026, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 7126 ) | C2 | We Be Flipping (Hard Version) | PROGRAMMING | constructive algorithms |
This is the hard version of the problem. The difference between the versions is that in this version, you must maximise the sum. You can hack only if you solved all versions of this problem. You have an array (a) of length (n) which consists of non-zero (but possibly negative) integers. You will perform the following operation at most (n) times (possibly none): select an index (i) ((1 \le i \le n)) such that (a_i \gt 0) then for each (j) where (1 \le j \le i) do (a_j := -a_j). Output a valid sequence of operations of length at most (n) which (\color{red}{\text{maximises}}) the sum of (a) at 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 testcase contains an integer (n) ((2 \le n \le 2 \cdot 10^5)) — the length of the array (a). The second line of each testcase contains (n) integers (a_1,a_2,\ldots,a_n) ((-10^9 \le a_i \le 10^9, a_i \ne 0)). It is guaranteed that the sum of (n) over all test cases does not exceed (2 \cdot 10^5). For each testcase, output a single integer (k) ((0 \le k \le n)) — the number of operations you will perform. Now output (k) integers (b_1,\ldots,b_k) where (b_i) is the index you perform the (i)th operation on. After performing the operations the sum of (a) should be maximal. In the first testcase, no operations are possible. In the second testcase, the sum is already maximal. In the third testcase, operations are made as follows: (1, -3, 2, -1, 10 \xrightarrow{i = 1} \color{red}{-1}, -3, 2, -1, 10) (-1, -3, 2, -1, 10 \xrightarrow{i = 3} \color{red}{1, 3, -2}, -1, 10) This has sum (11), which can be proven to be maximal. |
| Spectral::Cup 2026 Round 2 (Codeforces Round 1100, 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 375838227 | samirpsalim | C2 | May 23, 2026, 4:46 p.m. | OK | C# 13 | TESTS | 9 | 109 | 41574400 | ||
| 375845104 | Tfman | C2 | May 23, 2026, 5:18 p.m. | OK | C# 13 | TESTS | 9 | 140 | 35635200 | ||
| 375890359 | hrushikeshm56 | C2 | May 24, 2026, 5:27 a.m. | OK | C++17 (GCC 7-32) | TESTS | 9 | 46 | 1228800 | ||
| 375883395 | jingjing_Andy | C2 | May 24, 2026, 3:27 a.m. | OK | C++17 (GCC 7-32) | TESTS | 9 | 46 | 1228800 | ||
| 375893041 | H.M_11 | C2 | May 24, 2026, 6:03 a.m. | OK | C++17 (GCC 7-32) | TESTS | 9 | 62 | 0 | ||
| 375837062 | kdedovich | C2 | May 23, 2026, 4:41 p.m. | OK | C++17 (GCC 7-32) | TESTS | 9 | 62 | 0 | ||
| 375876883 | travisbickle1976 | C2 | May 24, 2026, 12:11 a.m. | OK | C++17 (GCC 7-32) | TESTS | 9 | 62 | 102400 | ||
| 375881666 | qinglin_zcr | C2 | May 24, 2026, 2:46 a.m. | OK | C++17 (GCC 7-32) | TESTS | 9 | 62 | 409600 | ||
| 375883542 | wuziqiao | C2 | May 24, 2026, 3:30 a.m. | OK | C++17 (GCC 7-32) | TESTS | 9 | 62 | 1126400 | ||
| 375839259 | deefpried | C2 | May 23, 2026, 4:51 p.m. | OK | C++17 (GCC 7-32) | TESTS | 9 | 62 | 1638400 | ||
| 375875071 | sofyanalam | C2 | May 23, 2026, 10:55 p.m. | OK | C++17 (GCC 7-32) | TESTS | 9 | 62 | 2048000 | ||
| 375829023 | zerich | C2 | May 23, 2026, 4:10 p.m. | OK | C++17 (GCC 7-32) | TESTS | 9 | 62 | 2048000 |
Back to search problems