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 |
|---|---|---|---|---|---|---|
| 2023 | Codeforces Round 980 (Div. 1) | FINISHED | False | 7200 | 46990523 | Oct. 20, 2024, 9:05 a.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 16527 ) | A | Concatenation of Arrays | PROGRAMMING | constructive algorithms greedy math sortings |
You are given (n) arrays (a_1), (\ldots), (a_n). The length of each array is two. Thus, (a_i = a_{i, 1}, a_{i, 2}). You need to concatenate the arrays into a single array of length (2n) such that the number of inversions(^{\dagger}) in the resulting array is minimized. Note that you do not need to count the actual number of inversions. More formally, you need to choose a permutation(^{\ddagger}) (p) of length (n), so that the array (b = a_{p_1,1}, a_{p_1,2}, a_{p_2, 1}, a_{p_2, 2}, \ldots, a_{p_n,1}, a_{p_n,2}) contains as few inversions as possible. (^{\dagger})The number of inversions in an array (c) is the number of pairs of indices (i) and (j) such that (i < j) and (c_i > c_j). (^{\ddagger})A permutation of length (n) is an array consisting of (n) distinct integers from (1) to (n) in arbitrary order. For example, (2,3,1,5,4) is a permutation, but (1,2,2) is not a permutation ((2) appears twice in the array), and (1,3,4) is also not a permutation ((n=3) but there is (4) in the array). Each test consists of multiple test cases. The first line contains a single 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 10^5)) — the number of arrays. Each of the following (n) lines contains two integers (a_{i,1}) and (a_{i,2}) ((1 \le a_{i,j} \le 10^9)) — the elements of the (i)-th array. It is guaranteed that the sum of (n) over all test cases does not exceed (10^5). For each test case, output (2n) integers — the elements of the array you obtained. If there are multiple solutions, output any of them. In the first test case, we concatenated the arrays in the order (2, 1). Let's consider the inversions in the resulting array (b = 2, 3, 1, 4): (i = 1), $$$j |
| 135341 |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 287043870 | og.kostya | A | Oct. 20, 2024, 12:15 p.m. | OK | C# 10 | TESTS | 8 | 156 | 3686400 | ||
| 286930747 | zrnstnsr | A | Oct. 20, 2024, 9:33 a.m. | OK | C# 10 | TESTS | 8 | 312 | 16179200 | ||
| 286961905 | Brinton | A | Oct. 20, 2024, 9:50 a.m. | OK | C++17 (GCC 7-32) | TESTS | 8 | 93 | 0 | ||
| 286923787 | yefllower | A | Oct. 20, 2024, 9:24 a.m. | OK | C++17 (GCC 7-32) | TESTS | 8 | 93 | 1228800 | ||
| 286912578 | PoPularPlusPlus | A | Oct. 20, 2024, 9:12 a.m. | OK | C++17 (GCC 7-32) | TESTS | 8 | 108 | 0 | ||
| 286923380 | CepryH9 | A | Oct. 20, 2024, 9:24 a.m. | OK | C++17 (GCC 7-32) | TESTS | 8 | 108 | 0 | ||
| 286909538 | MahiruShiina | A | Oct. 20, 2024, 9:10 a.m. | OK | C++17 (GCC 7-32) | TESTS | 8 | 108 | 102400 | ||
| 287135111 | MOONHOLA_ | A | Oct. 21, 2024, 1:24 a.m. | OK | C++17 (GCC 7-32) | TESTS | 8 | 108 | 102400 | ||
| 287062926 | Hagertarraf15 | A | Oct. 20, 2024, 12:52 p.m. | OK | C++17 (GCC 7-32) | TESTS | 8 | 109 | 0 | ||
| 287129826 | nadia_14 | A | Oct. 20, 2024, 10:52 p.m. | OK | C++17 (GCC 7-32) | TESTS | 8 | 109 | 102400 | ||
| 287141826 | hzk_cpp | A | Oct. 21, 2024, 3:39 a.m. | OK | C++17 (GCC 7-32) | TESTS | 8 | 109 | 102400 | ||
| 286993742 | Sorting | A | Oct. 20, 2024, 10:21 a.m. | OK | C++17 (GCC 7-32) | TESTS | 8 | 109 | 102400 | ||
| 286931055 | MtSaka | A | Oct. 20, 2024, 9:34 a.m. | OK | C++20 (GCC 13-64) | TESTS | 8 | 62 | 409600 | ||
| 286908360 | Sulfox | A | Oct. 20, 2024, 9:09 a.m. | OK | C++20 (GCC 13-64) | TESTS | 8 | 62 | 3174400 | ||
| 287148526 | arpitkus | A | Oct. 21, 2024, 5:11 a.m. | OK | C++20 (GCC 13-64) | TESTS | 8 | 77 | 102400 | ||
| 286914472 | Nelson_loh | A | Oct. 20, 2024, 9:14 a.m. | OK | C++20 (GCC 13-64) | TESTS | 8 | 77 | 102400 | ||
| 286906914 | Capps | A | Oct. 20, 2024, 9:08 a.m. | OK | C++20 (GCC 13-64) | TESTS | 8 | 77 | 716800 | ||
| 286916466 | AEM_YNxingkong | A | Oct. 20, 2024, 9:16 a.m. | OK | C++20 (GCC 13-64) | TESTS | 8 | 77 | 2662400 | ||
| 286973406 | lhy123 | A | Oct. 20, 2024, 9:57 a.m. | OK | C++20 (GCC 13-64) | TESTS | 8 | 77 | 3379200 | ||
| 286911973 | _Hok | A | Oct. 20, 2024, 9:12 a.m. | OK | C++20 (GCC 13-64) | TESTS | 8 | 77 | 17817600 | ||
| 286917641 | 2018LZY | A | Oct. 20, 2024, 9:17 a.m. | OK | C++20 (GCC 13-64) | TESTS | 8 | 78 | 102400 | ||
| 286909410 | lfxxx | A | Oct. 20, 2024, 9:10 a.m. | OK | C++20 (GCC 13-64) | TESTS | 8 | 78 | 819200 | ||
| 286916110 | xuhaotian | A | Oct. 20, 2024, 9:16 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 8 | 61 | 5017600 | ||
| 286912423 | cmk666 | A | Oct. 20, 2024, 9:12 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 8 | 77 | 1331200 | ||
| 286914150 | WithoutHope | A | Oct. 20, 2024, 9:14 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 8 | 93 | 0 | ||
| 287098653 | Ari | A | Oct. 20, 2024, 5:07 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 8 | 93 | 0 | ||
| 287042527 | chromate00 | A | Oct. 20, 2024, 12:07 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 8 | 93 | 0 | ||
| 286935551 | Nullptrs | A | Oct. 20, 2024, 9:40 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 8 | 93 | 0 | ||
| 286912764 | Error_Yuan | A | Oct. 20, 2024, 9:13 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 8 | 93 | 0 | ||
| 287142776 | shakil_21_ | A | Oct. 21, 2024, 3:53 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 8 | 93 | 102400 | ||
| 287133350 | rgrgtgrf | A | Oct. 21, 2024, 12:41 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 8 | 93 | 102400 | ||
| 287131928 | georginio | A | Oct. 21, 2024, midnight | OK | C++23 (GCC 14-64, msys2) | TESTS | 8 | 93 | 102400 | ||
| 286927345 | KumaTachiRen | A | Oct. 20, 2024, 9:29 a.m. | OK | C# 8 | TESTS | 8 | 171 | 12390400 | ||
| 286907295 | hos.lyric | A | Oct. 20, 2024, 9:09 a.m. | OK | D | TESTS | 8 | 296 | 3072000 | ||
| 287013990 | Gassa | A | Oct. 20, 2024, 11 a.m. | OK | D | TESTS | 8 | 468 | 3686400 | ||
| 286911959 | -dub-otrezkov- | A | Oct. 20, 2024, 9:12 a.m. | OK | Go | TESTS | 8 | 156 | 4812800 | ||
| 287114968 | ChrizzyB47 | A | Oct. 20, 2024, 7:19 p.m. | OK | Java 21 | TESTS | 8 | 359 | 1945600 | ||
| 287152169 | keshav_.agg | A | Oct. 21, 2024, 5:55 a.m. | OK | Java 21 | TESTS | 8 | 389 | 716800 | ||
| 287081763 | Reuben9027 | A | Oct. 20, 2024, 3 p.m. | OK | Java 21 | TESTS | 8 | 577 | 1228800 | ||
| 286986363 | alu097 | A | Oct. 20, 2024, 10:07 a.m. | OK | Java 21 | TESTS | 8 | 999 | 13721600 | ||
| 287079694 | golions | A | Oct. 20, 2024, 2:44 p.m. | OK | Java 8 | TESTS | 8 | 296 | 6656000 | ||
| 287042002 | yvbf | A | Oct. 20, 2024, 12:04 p.m. | OK | Java 8 | TESTS | 8 | 327 | 0 | ||
| 287092011 | kasiru_69 | A | Oct. 20, 2024, 4:19 p.m. | OK | Java 8 | TESTS | 8 | 406 | 0 | ||
| 286910691 | elizarov | A | Oct. 20, 2024, 9:11 a.m. | OK | Kotlin 1.9 | TESTS | 8 | 577 | 9932800 | ||
| 286910671 | senjougaharin | A | Oct. 20, 2024, 9:11 a.m. | OK | Kotlin 1.9 | TESTS | 8 | 1015 | 22937600 | ||
| 286912357 | bcollet | A | Oct. 20, 2024, 9:12 a.m. | OK | PyPy 2 | TESTS | 8 | 483 | 18841600 | ||
| 286930898 | hato_ | A | Oct. 20, 2024, 9:33 a.m. | OK | PyPy 3-64 | TESTS | 8 | 390 | 33996800 | ||
| 286911064 | ohys040411 | A | Oct. 20, 2024, 9:11 a.m. | OK | PyPy 3-64 | TESTS | 8 | 421 | 24064000 | ||
| 286919638 | chinerist | A | Oct. 20, 2024, 9:19 a.m. | OK | PyPy 3-64 | TESTS | 8 | 421 | 29593600 | ||
| 286905159 | anango | A | Oct. 20, 2024, 9:06 a.m. | OK | PyPy 3-64 | TESTS | 8 | 437 | 26009600 | ||
| 287141709 | xlk | A | Oct. 21, 2024, 3:37 a.m. | OK | PyPy 3-64 | TESTS | 8 | 499 | 25088000 | ||
| 287150947 | test892375 | A | Oct. 21, 2024, 5:41 a.m. | OK | PyPy 3-64 | TESTS | 8 | 515 | 30310400 | ||
| 286906668 | TOMATO_MAT_TO | A | Oct. 20, 2024, 9:08 a.m. | OK | PyPy 3-64 | TESTS | 8 | 531 | 31232000 | ||
| 286916046 | toam | A | Oct. 20, 2024, 9:16 a.m. | OK | PyPy 3-64 | TESTS | 8 | 546 | 28672000 | ||
| 287131204 | FelixNotter | A | Oct. 20, 2024, 11:35 p.m. | OK | PyPy 3-64 | TESTS | 8 | 546 | 48435200 | ||
| 286907950 | Synaptic_Savant | A | Oct. 20, 2024, 9:09 a.m. | OK | PyPy 3-64 | TESTS | 8 | 562 | 25600000 | ||
| 287144051 | Svlad_Cjelli | A | Oct. 21, 2024, 4:12 a.m. | OK | Rust 2021 | TESTS | 8 | 62 | 102400 | ||
| 287145647 | Allergy527 | A | Oct. 21, 2024, 4:33 a.m. | OK | Rust 2021 | TESTS | 8 | 93 | 102400 | ||
| 286907160 | sansen | A | Oct. 20, 2024, 9:09 a.m. | OK | Rust 2021 | TESTS | 8 | 124 | 6758400 | ||
| 286930145 | akashin | A | Oct. 20, 2024, 9:32 a.m. | OK | Rust 2021 | TESTS | 8 | 140 | 9830400 |
Back to search problems