Codeforces Round 1054 (Div. 3)

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
2149 Codeforces Round 1054 (Div. 3) FINISHED False 8100 17594723 Sept. 25, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 32879 ) B Unconventional Pairs PROGRAMMING greedy sortings

A popular reality show Unconventional Pairs has been launched in the city. According to the rules of the show, participants are paired in an unusual way: with an even number of people, all participants must be in pairs. Petya has an array of (n) integers (a_1,a_2,\dots ,a_n). It is known that (n) is even. Petya must divide the participants (numbers) into exactly (\large\frac{n}{2}) pairs ((a_{p_1},a_{q_1}),\,(a_{p_2},a_{q_2}),\dots\,(a_{p_\frac{n}{2}},a_{q_\frac{n}{2}})). Each index can be included in no more than one pair. For a pair ((x,y)), its difference is defined as (|x-y|). Petya wants to form unconventional pairs such that the maximum difference among all pairs is minimized. Determine the minimum possible value of this maximum difference. Each test consists of several 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 one even number (n) ((2 \le n \le 2 \cdot 10^5)) — the length of the array (a). The second line contains (n) integers (a_1,a_2,\dots ,a_n) ((-10^{9} \le a_i \le 10^{9})) — the elements of the array (a). It is guaranteed that the sum of the values of (n) across all test cases does not exceed (2 \cdot 10^5). For each test case, output a single number — the minimum possible maximum difference between the elements in pairs. In the first test case, the array is: (1,2). The only possible (and therefore optimal) pair is ((1,2)), its difference is (|1-2| = 1), the answer is (1). In the second test case, the array is: (10,1,2,9). We can choose pairs — ((1,2)) and ((9,10)): both differences are equal to (1), therefore, the maximum difference is (1). In the third test case, the array is: (3,8,9,3,3,2). We can choose pairs: ((2,3)), ((3,3)), ((8,9)). The differences are: $$$1,0,1$$

Tutorials

__rose

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
340566949 nabin-09 B Sept. 26, 2025, 5:50 a.m. OK C++17 (GCC 7-32) TESTS 4 77 0
340518944 __JT__ B Sept. 25, 2025, 6:15 p.m. OK C++17 (GCC 7-32) TESTS 4 77 0
340504202 yqq B Sept. 25, 2025, 4:46 p.m. OK C++17 (GCC 7-32) TESTS 4 77 0
340540584 TheRZ B Sept. 25, 2025, 10:58 p.m. OK C++17 (GCC 7-32) TESTS 4 78 0
340531404 __ALAMIN__ B Sept. 25, 2025, 8:28 p.m. OK C++17 (GCC 7-32) TESTS 4 78 0
340531169 levanter914 B Sept. 25, 2025, 8:24 p.m. OK C++17 (GCC 7-32) TESTS 4 78 0
340527282 AnmolSh B Sept. 25, 2025, 7:37 p.m. OK C++17 (GCC 7-32) TESTS 4 78 0
340519968 deerajkrishna49 B Sept. 25, 2025, 6:24 p.m. OK C++17 (GCC 7-32) TESTS 4 78 0
340508650 OM_202401238 B Sept. 25, 2025, 4:58 p.m. OK C++17 (GCC 7-32) TESTS 4 78 0
340552655 zhzkiller6 B Sept. 26, 2025, 2:59 a.m. OK C++17 (GCC 7-32) TESTS 4 78 819200
340568093 Jihad_923 B Sept. 26, 2025, 6:02 a.m. OK C++20 (GCC 13-64) TESTS 4 62 0
340565005 ManasaLGM B Sept. 26, 2025, 5:28 a.m. OK C++20 (GCC 13-64) TESTS 4 62 0
340541088 R_V_REVAMTH B Sept. 25, 2025, 11:11 p.m. OK C++20 (GCC 13-64) TESTS 4 62 0
340529968 rharshita_12 B Sept. 25, 2025, 8:09 p.m. OK C++20 (GCC 13-64) TESTS 4 62 0
340521441 sima124 B Sept. 25, 2025, 6:37 p.m. OK C++20 (GCC 13-64) TESTS 4 62 0
340567343 invwjy B Sept. 26, 2025, 5:54 a.m. OK C++20 (GCC 13-64) TESTS 4 77 0
340565447 EmmanuelRojas B Sept. 26, 2025, 5:33 a.m. OK C++20 (GCC 13-64) TESTS 4 77 0
340564933 pranshumg B Sept. 26, 2025, 5:27 a.m. OK C++20 (GCC 13-64) TESTS 4 77 0
340559680 Hksingh B Sept. 26, 2025, 4:38 a.m. OK C++20 (GCC 13-64) TESTS 4 77 0
340556957 Mr.Numerator_007 B Sept. 26, 2025, 4:01 a.m. OK C++20 (GCC 13-64) TESTS 4 77 0
340559718 chawlah503 B Sept. 26, 2025, 4:38 a.m. OK C++23 (GCC 14-64, msys2) TESTS 4 61 0
340525156 Hoopoe404 B Sept. 25, 2025, 7:14 p.m. OK C++23 (GCC 14-64, msys2) TESTS 4 61 0
340520504 Thesevs B Sept. 25, 2025, 6:29 p.m. OK C++23 (GCC 14-64, msys2) TESTS 4 61 0
340563113 shivankty B Sept. 26, 2025, 5:07 a.m. OK C++23 (GCC 14-64, msys2) TESTS 4 62 0
340552147 herly B Sept. 26, 2025, 2:51 a.m. OK C++23 (GCC 14-64, msys2) TESTS 4 62 0
340549498 coolkid1412 B Sept. 26, 2025, 2:10 a.m. OK C++23 (GCC 14-64, msys2) TESTS 4 62 0
340544646 alvmaury1 B Sept. 26, 2025, 12:40 a.m. OK C++23 (GCC 14-64, msys2) TESTS 4 62 0
340541834 Bassem_magdy B Sept. 25, 2025, 11:31 p.m. OK C++23 (GCC 14-64, msys2) TESTS 4 62 0
340530202 powervic08 B Sept. 25, 2025, 8:12 p.m. OK C++23 (GCC 14-64, msys2) TESTS 4 62 0
340519621 MirazHossain_847 B Sept. 25, 2025, 6:21 p.m. OK C++23 (GCC 14-64, msys2) TESTS 4 62 0
340527197 shantanu_sharma.official B Sept. 25, 2025, 7:36 p.m. OK GNU C11 TESTS 4 77 921600
340504418 Praneetha_Nallam B Sept. 25, 2025, 4:46 p.m. OK GNU C11 TESTS 4 77 1536000
340535573 u2404063 B Sept. 25, 2025, 9:30 p.m. OK GNU C11 TESTS 4 109 819200
340529039 Alpha_Zeros B Sept. 25, 2025, 7:58 p.m. OK GNU C11 TESTS 4 109 1536000
340509020 satvik.kurapaty B Sept. 25, 2025, 5 p.m. OK GNU C11 TESTS 4 124 921600
340508585 nusrat_maya B Sept. 25, 2025, 4:58 p.m. OK GNU C11 TESTS 4 124 1638400
340551816 6945934678ThanhNV B Sept. 26, 2025, 2:46 a.m. OK Go TESTS 4 155 4300800
340526101 princerxj B Sept. 25, 2025, 7:24 p.m. OK Java 21 TESTS 4 249 1228800
340561158 priyaroy3370 B Sept. 26, 2025, 4:51 a.m. OK Java 21 TESTS 4 265 512000
340561636 Selvaragavan_C B Sept. 26, 2025, 4:55 a.m. OK Java 21 TESTS 4 280 1024000
340566876 shreyashdhumal B Sept. 26, 2025, 5:49 a.m. OK Java 21 TESTS 4 296 614400
340551000 gondaliyaronak78 B Sept. 26, 2025, 2:33 a.m. OK Java 21 TESTS 4 296 1126400
340515740 dharahas B Sept. 25, 2025, 5:48 p.m. OK Java 21 TESTS 4 312 3072000
340561247 mali.avadhut7 B Sept. 26, 2025, 4:52 a.m. OK Java 21 TESTS 4 358 0
340516634 I_AM_SPEED B Sept. 25, 2025, 5:56 p.m. OK Java 21 TESTS 4 390 20172800
340518210 animesh1024 B Sept. 25, 2025, 6:09 p.m. OK Java 21 TESTS 4 577 21811200
340516273 rashad_786 B Sept. 25, 2025, 5:53 p.m. OK Java 21 TESTS 4 593 512000
340545945 ujwalcoderhunter B Sept. 26, 2025, 1:06 a.m. OK Java 8 TESTS 4 187 3788800
340532956 Shafat04 B Sept. 25, 2025, 8:49 p.m. OK Java 8 TESTS 4 406 0
340531459 jroy.karnati B Sept. 25, 2025, 8:28 p.m. OK Java 8 TESTS 4 406 0
340505700 Rafax B Sept. 25, 2025, 4:48 p.m. OK Java 8 TESTS 4 421 0
340504474 23211a7255 B Sept. 25, 2025, 4:46 p.m. OK Java 8 TESTS 4 421 0
340504048 RAshwini B Sept. 25, 2025, 4:45 p.m. OK Java 8 TESTS 4 421 0
340551835 chengzijun_de_xiatian B Sept. 26, 2025, 2:47 a.m. OK Java 8 TESTS 4 436 0
340509678 siddheshtodi B Sept. 25, 2025, 5:04 p.m. OK Java 8 TESTS 4 436 0
340563040 Dark_Horse69 B Sept. 26, 2025, 5:07 a.m. OK Java 8 TESTS 4 437 0
340513028 pranavarya2005 B Sept. 25, 2025, 5:26 p.m. OK Java 8 TESTS 4 437 0
340560410 ShauryaJain09 B Sept. 26, 2025, 4:44 a.m. OK PyPy 3 TESTS 4 312 17203200
340539130 Arun9696 B Sept. 25, 2025, 10:20 p.m. OK PyPy 3 TESTS 4 312 18022400
340560013 Chandu_Venkat B Sept. 26, 2025, 4:41 a.m. OK PyPy 3 TESTS 4 327 16179200
340563346 ss250404909 B Sept. 26, 2025, 5:10 a.m. OK PyPy 3 TESTS 4 327 18227200
340514957 andrewliu10523 B Sept. 25, 2025, 5:41 p.m. OK PyPy 3 TESTS 4 342 15564800
340522709 logankeede B Sept. 25, 2025, 6:49 p.m. OK PyPy 3 TESTS 4 343 16076800
340565184 D1mitriik B Sept. 26, 2025, 5:30 a.m. OK PyPy 3 TESTS 4 358 13926400
340504232 seifelboghdady13 B Sept. 25, 2025, 4:46 p.m. OK PyPy 3 TESTS 4 358 17715200
340515622 A2acoder B Sept. 25, 2025, 5:47 p.m. OK PyPy 3 TESTS 4 359 17920000
340523005 agad115 B Sept. 25, 2025, 6:53 p.m. OK PyPy 3 TESTS 4 359 18022400
340510902 kadirov_10_01 B Sept. 25, 2025, 5:12 p.m. OK PyPy 3-64 TESTS 4 140 23552000
340507710 Lamohehe B Sept. 25, 2025, 4:54 p.m. OK PyPy 3-64 TESTS 4 155 21504000
340523518 Lion_2056 B Sept. 25, 2025, 6:58 p.m. OK PyPy 3-64 TESTS 4 155 23552000
340511862 AG-88301 B Sept. 25, 2025, 5:18 p.m. OK PyPy 3-64 TESTS 4 155 23859200
340523342 natnael_necho B Sept. 25, 2025, 6:56 p.m. OK PyPy 3-64 TESTS 4 155 24268800
340520348 varunketa B Sept. 25, 2025, 6:28 p.m. OK PyPy 3-64 TESTS 4 155 24473600
340504282 Nafiz-Codes B Sept. 25, 2025, 4:46 p.m. OK PyPy 3-64 TESTS 4 155 27340800
340530584 re-l_no_tamago B Sept. 25, 2025, 8:17 p.m. OK PyPy 3-64 TESTS 4 156 23040000
340521179 learnerdaily5 B Sept. 25, 2025, 6:35 p.m. OK PyPy 3-64 TESTS 4 156 27033600
340537741 monocrap B Sept. 25, 2025, 9:54 p.m. OK PyPy 3-64 TESTS 4 156 27238400
340524998 Ramine001 B Sept. 25, 2025, 7:13 p.m. OK Python 3 TESTS 4 171 23859200
340539853 VeldoraTempest B Sept. 25, 2025, 10:37 p.m. OK Python 3 TESTS 4 171 25088000
340541128 PatrickCcoaPerez B Sept. 25, 2025, 11:12 p.m. OK Python 3 TESTS 4 186 23859200
340553775 gian_notty B Sept. 26, 2025, 3:15 a.m. OK Python 3 TESTS 4 186 25190400
340533836 elistark B Sept. 25, 2025, 9:02 p.m. OK Python 3 TESTS 4 186 25190400
340532080 sharlotik B Sept. 25, 2025, 8:36 p.m. OK Python 3 TESTS 4 186 29491200
340547261 XemM B Sept. 26, 2025, 1:31 a.m. OK Python 3 TESTS 4 187 23859200
340505876 singh.adityaa74 B Sept. 25, 2025, 4:48 p.m. OK Python 3 TESTS 4 202 18329600
340565595 javoh1964 B Sept. 26, 2025, 5:35 a.m. OK Python 3 TESTS 4 202 23859200
340523305 Amit_Rane B Sept. 25, 2025, 6:56 p.m. OK Python 3 TESTS 4 202 23859200
340553753 0x81 B Sept. 26, 2025, 3:14 a.m. OK Rust 2024 TESTS 4 61 2867200

remove filters

Back to search problems