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 |
|---|---|---|---|---|---|---|
| 1995 | Codeforces Round 961 (Div. 2) | FINISHED | False | 7200 | 54660323 | July 23, 2024, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 396 ) | E2 | Let Me Teach You a Lesson (Hard Version) | PROGRAMMING | 2-sat bitmasks data structures dp graphs matrices two pointers |
This is the hard version of a problem. The only difference between an easy and a hard version is the constraints on t and n . You can make hacks only if both versions of the problem are solved. Arthur is giving a lesson to his famous 2 n knights. Like any other students, they're sitting at the desks in pairs, but out of habit in a circle. The knight 2 i - 1 is sitting at the desk with the knight 2 i . Each knight has intelligence, which can be measured by an integer. Let's denote the intelligence of the i -th knight as a_i . Arthur wants the maximal difference in total intelligence over all pairs of desks to be as small as possible. More formally, he wants to minimize max limits_{1 <= i <= n} (a_{2 i - 1} + a_{2 i}) - min limits_{1 <= i <= n} (a_{2 i - 1} + a_{2 i}) . However, the Code of Chivalry only allows swapping the opposite knights in the circle, i.e., Arthur can simultaneously perform a_i := a_{i + n} , a_{i + n} := a_i for any 1 <= i <= n . Arthur can make any number of such swaps. What is the best result he can achieve? Each test consists of several test cases. The first line contains a single integer t ( 1 <= t <= 10 ,000 ) -- the number of test cases. It is followed by descriptions of the test cases. The first line of each test case contains a single integer n ( 1 <= n <= 100 ,000 ) -- the number of desks. The second line consists of 2n integers a_1, a_2, ldots, a_{2 n} ( 1 <= a_i <= 10^9 ) -- the intelligence values of the knights. It is guaranteed that the sum of n over all test cases does not exceed 100 ,000 . For each test case, output a single line containing one integer -- the minimal difference Arthur can achieve. In the first test case, Arthur can swap the second and the fourth knights. Then the total intelligence at both desks will be 10 . In the third test case, Arthur can make 0 operations, which |
| Video Tutorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 272174454 | potato167 | E2 | July 23, 2024, 5:14 p.m. | OK | C++17 (GCC 7-32) | TESTS | 104 | 202 | 12492800 | ||
| 272195408 | DarkHomosapien | E2 | July 23, 2024, 5:33 p.m. | OK | C++17 (GCC 7-32) | TESTS | 104 | 296 | 8192000 | ||
| 272251017 | Superposition | E2 | July 24, 2024, 5:01 a.m. | OK | C++17 (GCC 7-32) | TESTS | 104 | 343 | 33894400 | ||
| 272212685 | ikrpprppp | E2 | July 23, 2024, 8:01 p.m. | OK | C++17 (GCC 7-32) | TESTS | 104 | 374 | 11878400 | ||
| 272205716 | Kilani | E2 | July 23, 2024, 6:47 p.m. | OK | C++17 (GCC 7-32) | TESTS | 104 | 374 | 24576000 | ||
| 272219486 | Imagine.2019 | E2 | July 23, 2024, 9:39 p.m. | OK | C++17 (GCC 7-32) | TESTS | 104 | 452 | 14028800 | ||
| 272234522 | Sparkle_Twilight | E2 | July 24, 2024, 2:12 a.m. | OK | C++17 (GCC 7-32) | TESTS | 104 | 468 | 27443200 | ||
| 272198959 | neal | E2 | July 23, 2024, 5:55 p.m. | OK | C++20 (GCC 13-64) | TESTS | 104 | 108 | 3584000 | ||
| 272197988 | neal | E2 | July 23, 2024, 5:49 p.m. | OK | C++20 (GCC 13-64) | TESTS | 104 | 156 | 4915200 | ||
| 272245727 | LNian | E2 | July 24, 2024, 4:03 a.m. | OK | C++20 (GCC 13-64) | TESTS | 104 | 186 | 13414400 | ||
| 272198107 | neal | E2 | July 23, 2024, 5:50 p.m. | OK | C++20 (GCC 13-64) | TESTS | 104 | 187 | 3584000 | ||
| 272174358 | BurnedChicken | E2 | July 23, 2024, 5:13 p.m. | OK | C++20 (GCC 13-64) | TESTS | 104 | 249 | 1126400 | ||
| 272254681 | Z-301 | E2 | July 24, 2024, 5:39 a.m. | OK | C++20 (GCC 13-64) | TESTS | 104 | 249 | 15564800 | ||
| 272254553 | Z-301 | E2 | July 24, 2024, 5:37 a.m. | OK | C++20 (GCC 13-64) | TESTS | 104 | 265 | 15462400 | ||
| 272250097 | LOOP0 | E2 | July 24, 2024, 4:52 a.m. | OK | C++20 (GCC 13-64) | TESTS | 104 | 265 | 33689600 | ||
| 272251113 | Superposition | E2 | July 24, 2024, 5:02 a.m. | OK | C++20 (GCC 13-64) | TESTS | 104 | 265 | 35225600 | ||
| 272201088 | neal | E2 | July 23, 2024, 6:10 p.m. | OK | C++20 (GCC 13-64) | TESTS | 104 | 280 | 5836800 |
Back to search problems