Atto Round 1 (Codeforces Round 1041, Div. 1 + Div. 2)

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
2127 Atto Round 1 (Codeforces Round 1041, Div. 1 + Div. 2) FINISHED False 10800 21828323 Aug. 7, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 12309 ) C Trip Shopping PROGRAMMING games greedy sortings

Ali and Bahamin decided to spend their summer vacation on the beautiful southern coasts of Iran. They also agreed to do some shopping during the trip — but instead of setting a fixed budget, they decided to determine how much they would spend by playing a game. The game is played on two arrays (a) and (b), each containing (n) integers. The game will last for (k) rounds. In one round: First, Ali selects two indices (i) and (j) ((1 \leq i < j \leq n)); Then, Bahamin rearranges the four integers (a_i), (a_j), (b_i), and (b_j) arbitrarily . Note that Bahamin can swap numbers between two arrays. He can also keep the two arrays unchanged. After all the (k) rounds, the value of the game is defined as (v=\sum\limits_{i=1}^{n} |a_i-b_i|). Ali and Bahamin will spend exactly (v) coins during their trip. However, their goals are quite different: Ali wants to spend as little as possible, that is, to minimize (v); Bahamin wants to spend as much as possible, that is, to maximize (v). You have to find the final amount of coins they will spend if both Ali and Bahamin play optimally. 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 test case contains two integers (n) and (k) ((2 \leq n \leq 2 \cdot 10^5), (1 \leq k \leq n)) — the length of (a) and (b), and the number of rounds. The second line contains (n) integers (a_1,a_2,\ldots,a_n) ((1 \leq a_i \leq 10^9)) — the elements of (a). The third line contains (n) integers (b_1,b_2,\ldots,b_n) ((1 \leq b_i \leq 10^9)) — the elements of (b). 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 final amount of coins they will spend if both Ali and Bahamin play optimally. In the firs

Tutorials

Atto Round 1 (Codeforces Round 1041, Div. 1 + Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
332905172 vivekrajsundar C Aug. 7, 2025, 5:31 p.m. OK C# 10 TESTS 15 203 37785600
332930746 o_elyas C Aug. 7, 2025, 10:16 p.m. OK C++17 (GCC 7-32) TESTS 15 140 0
332925805 EndMyMisery C Aug. 7, 2025, 8:32 p.m. OK C++17 (GCC 7-32) TESTS 15 140 0
332920846 a_dev C Aug. 7, 2025, 7:32 p.m. OK C++17 (GCC 7-32) TESTS 15 155 0
332920434 agrawaladitya C Aug. 7, 2025, 7:28 p.m. OK C++17 (GCC 7-32) TESTS 15 155 0
332904619 Sajos C Aug. 7, 2025, 5:30 p.m. OK C++17 (GCC 7-32) TESTS 15 155 102400
332929855 thudor C Aug. 7, 2025, 9:51 p.m. OK C++17 (GCC 7-32) TESTS 15 155 1638400
332949627 Shravan6398 C Aug. 8, 2025, 4:01 a.m. OK C++17 (GCC 7-32) TESTS 15 155 2764800
332954086 216master C Aug. 8, 2025, 4:59 a.m. OK C++17 (GCC 7-32) TESTS 15 155 3276800
332956372 Roshan.029 C Aug. 8, 2025, 5:26 a.m. OK C++17 (GCC 7-32) TESTS 15 155 24064000
332959828 Gononajontro_Biggani C Aug. 8, 2025, 6:01 a.m. OK C++17 (GCC 7-32) TESTS 15 156 0
332955464 wei666 C Aug. 8, 2025, 5:15 a.m. OK C++20 (GCC 13-64) TESTS 15 124 0
332949765 soumyadeb00 C Aug. 8, 2025, 4:03 a.m. OK C++20 (GCC 13-64) TESTS 15 124 0
332948938 ainuo C Aug. 8, 2025, 3:53 a.m. OK C++20 (GCC 13-64) TESTS 15 124 0
332945218 sakuaika C Aug. 8, 2025, 3:06 a.m. OK C++20 (GCC 13-64) TESTS 15 124 0
332952247 Photosynthesishero C Aug. 8, 2025, 4:36 a.m. OK C++20 (GCC 13-64) TESTS 15 124 102400
332934079 fugazi_zeitgeist C Aug. 8, 2025, 12:07 a.m. OK C++20 (GCC 13-64) TESTS 15 124 102400
332932379 Roll_Num_26 C Aug. 7, 2025, 11:07 p.m. OK C++20 (GCC 13-64) TESTS 15 124 102400
332933792 Manvendra27 C Aug. 7, 2025, 11:58 p.m. OK C++20 (GCC 13-64) TESTS 15 124 1126400
332927648 Tirtha_Manan_Das C Aug. 7, 2025, 9:03 p.m. OK C++20 (GCC 13-64) TESTS 15 124 1331200
332947439 doreen129 C Aug. 8, 2025, 3:35 a.m. OK C++20 (GCC 13-64) TESTS 15 124 1433600
332916992 C550 C Aug. 7, 2025, 6:56 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 93 3072000
332939846 Anachor C Aug. 8, 2025, 1:55 a.m. OK C++23 (GCC 14-64, msys2) TESTS 15 109 102400
332958349 sharp_flash_54 C Aug. 8, 2025, 5:47 a.m. OK C++23 (GCC 14-64, msys2) TESTS 15 124 102400
332958338 Ui_Umi C Aug. 8, 2025, 5:47 a.m. OK C++23 (GCC 14-64, msys2) TESTS 15 124 102400
332952532 pnhirapara C Aug. 8, 2025, 4:40 a.m. OK C++23 (GCC 14-64, msys2) TESTS 15 124 102400
332942500 Airmongsity C Aug. 8, 2025, 2:31 a.m. OK C++23 (GCC 14-64, msys2) TESTS 15 124 102400
332939428 Deemo_ML C Aug. 8, 2025, 1:48 a.m. OK C++23 (GCC 14-64, msys2) TESTS 15 124 102400
332935443 4svOn C Aug. 8, 2025, 12:34 a.m. OK C++23 (GCC 14-64, msys2) TESTS 15 124 102400
332926870 saikiran-bpr C Aug. 7, 2025, 8:50 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 124 102400
332925388 iotaaaaaaaaa C Aug. 7, 2025, 8:26 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 124 102400
332913619 bt55555 C Aug. 7, 2025, 6:32 p.m. OK GNU C11 TESTS 15 156 4915200
332905986 1435730 C Aug. 7, 2025, 5:32 p.m. OK GNU C11 TESTS 15 234 6451200
332921491 BiggestFish06 C Aug. 7, 2025, 7:39 p.m. OK Java 21 TESTS 15 327 8192000
332953343 skynet_07 C Aug. 8, 2025, 4:50 a.m. OK Java 21 TESTS 15 374 614400
332953065 KillNet7 C Aug. 8, 2025, 4:46 a.m. OK Java 21 TESTS 15 374 614400
332930282 tub0214 C Aug. 7, 2025, 10:02 p.m. OK Java 21 TESTS 15 421 9932800
332932714 hategreedy C Aug. 7, 2025, 11:20 p.m. OK Java 21 TESTS 15 483 10035200
332902053 Balu2907 C Aug. 7, 2025, 5:23 p.m. OK Java 21 TESTS 15 499 8601600
332942416 exothermic C Aug. 8, 2025, 2:30 a.m. OK Java 21 TESTS 15 499 67891200
332923576 mastacoda C Aug. 7, 2025, 8:03 p.m. OK Java 21 TESTS 15 562 8806400
332900665 kyokun C Aug. 7, 2025, 5:20 p.m. OK Java 21 TESTS 15 562 10240000
332957767 priyaroy3370 C Aug. 8, 2025, 5:41 a.m. OK Java 21 TESTS 15 937 18841600
332920215 Axel.blaze- C Aug. 7, 2025, 7:25 p.m. OK Java 8 TESTS 15 359 3891200
332905928 varsha_madireddy C Aug. 7, 2025, 5:32 p.m. OK Java 8 TESTS 15 937 6553600
332903122 jagbarrameda C Aug. 7, 2025, 5:26 p.m. OK Kotlin 1.9 TESTS 15 733 33280000
332952616 nanhi_pari110 C Aug. 8, 2025, 4:41 a.m. OK PyPy 3 TESTS 15 1124 24780800
332933093 2000_I_am_coming C Aug. 7, 2025, 11:34 p.m. OK PyPy 3-64 TESTS 15 452 47104000
332902276 olezhkavayn C Aug. 7, 2025, 5:24 p.m. OK PyPy 3-64 TESTS 15 546 38809600
332897624 DivyamAwasthy C Aug. 7, 2025, 5:12 p.m. OK PyPy 3-64 TESTS 15 562 40345600
332901635 Hacker-25 C Aug. 7, 2025, 5:22 p.m. OK PyPy 3-64 TESTS 15 577 41779200
332927416 DRDIV C Aug. 7, 2025, 8:59 p.m. OK PyPy 3-64 TESTS 15 671 30412800
332936165 jakekim C Aug. 8, 2025, 12:49 a.m. OK PyPy 3-64 TESTS 15 671 43827200
332899584 nghianteeek57 C Aug. 7, 2025, 5:17 p.m. OK PyPy 3-64 TESTS 15 686 36147200
332939730 yiren429 C Aug. 8, 2025, 1:53 a.m. OK PyPy 3-64 TESTS 15 702 32153600
332957361 Sree_charan C Aug. 8, 2025, 5:37 a.m. OK PyPy 3-64 TESTS 15 717 32153600
332899529 lattermatter C Aug. 7, 2025, 5:17 p.m. OK PyPy 3-64 TESTS 15 718 30105600
332898256 FyReX_KING635 C Aug. 7, 2025, 5:13 p.m. OK Python 3 TESTS 15 577 34816000
332928150 gupta_naman C Aug. 7, 2025, 9:13 p.m. OK Python 3 TESTS 15 593 34406400
332913995 cioppy C Aug. 7, 2025, 6:34 p.m. OK Python 3 TESTS 15 593 41062400
332941439 qos C Aug. 8, 2025, 2:17 a.m. OK Python 3 TESTS 15 624 36249600
332934241 FadedMcqueen7 C Aug. 8, 2025, 12:10 a.m. OK Python 3 TESTS 15 686 47308800
332902497 coderrg21 C Aug. 7, 2025, 5:24 p.m. OK Python 3 TESTS 15 717 49561600
332900753 akarsh_jain05 C Aug. 7, 2025, 5:20 p.m. OK Python 3 TESTS 15 718 34918400
332931603 ayushdreams147 C Aug. 7, 2025, 10:42 p.m. OK Python 3 TESTS 15 812 37888000
332954216 FDO C Aug. 8, 2025, 5 a.m. OK Python 3 TESTS 15 842 47820800
332898251 VinayRajput28 C Aug. 7, 2025, 5:13 p.m. OK Python 3 TESTS 15 1343 62464000
332920393 123gjweq2 C Aug. 7, 2025, 7:27 p.m. OK Rust 2021 TESTS 15 108 14131200
332920148 123gjweq2 C Aug. 7, 2025, 7:25 p.m. OK Rust 2021 TESTS 15 171 14028800

remove filters

Back to search problems