Codeforces Round 884 (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
1844 Codeforces Round 884 (Div. 1 + Div. 2) FINISHED False 10800 48180263 July 11, 2023, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 796 ) F1 Min Cost Permutation (Easy Version) PROGRAMMING greedy

B'The only difference between this problem and the hard version is the constraints on t and n . You are given an array of n positive integers a_1, ... ,a_n , and a (possibly negative) integer c . Across all permutations b_1, ... ,b_n of the array a_1, ... ,a_n , consider the minimum possible value of sum_{i=1}^{n-1} |b_{i+1}-b_i-c|. Find the lexicographically smallest permutation b of the array a that achieves this minimum. A sequence x is lexicographically smaller than a sequence y if and only if one of the following holds: Each test contains multiple test cases. The first line contains the number of test cases t ( 1 <= t <= 10^3 ). The description of the test cases follows. The first line of each test case contains two integers n and c ( 1 <= n <= 5 cdot 10^3 , -10^9 <= c <= 10^9 ). The second line of each test case contains n integers a_1, ... ,a_n ( 1 <= a_i <= 10^9 ). It is guaranteed that the sum of n over all test cases does not exceed 5 cdot 10^3 . For each test case, output n integers b_1, ... ,b_n , the lexicographically smallest permutation of a that achieves the minimum sum limits_{i=1}^{n-1} |b_{i+1}-b_i-c| . In the first test case, it can be proven that the minimum possible value of sum limits_{i=1}^{n-1} |b_{i+1}-b_i-c| is 27 , and the permutation b = [9,3,1,4,5,1] is the lexicographically smallest permutation of a that achieves this minimum: |3-9-(-7)|+|1-3-(-7)|+|4-1-(-7)|+|5-4-(-7)|+|1-5-(-7)| = 1+5+10+8+3 = 27 . In the second test case, the minimum possible value of sum limits_{i=1}^{n-1} |b_{i+1}-b_i-c| is 0 , and b = [1,3,5] is the lexicographically smallest permutation of a that achieves this. In the third test case, there is only one permutation b . '...

Tutorials

Codeforces Round #884 (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
213395889 Gassa F1 July 11, 2023, 5:14 p.m. OK D TESTS 26 374 4403200
213430153 rainboy F1 July 11, 2023, 11:23 p.m. OK GNU C11 TESTS 26 46 7987200
213453304 cyh_toby F1 July 12, 2023, 5:03 a.m. OK GNU C++14 TESTS 26 31 0
213394708 0wuming0 F1 July 11, 2023, 5:10 p.m. OK GNU C++14 TESTS 26 31 2764800
213401688 zmy_ F1 July 11, 2023, 5:33 p.m. OK GNU C++14 TESTS 26 31 24166400
213456258 Reborn F1 July 12, 2023, 5:50 a.m. OK GNU C++14 TESTS 26 62 0
213447896 wa_233 F1 July 12, 2023, 3:35 a.m. OK GNU C++14 TESTS 26 78 0
213445636 djwcbac F1 July 12, 2023, 3:02 a.m. OK GNU C++14 TESTS 26 78 819200
213397302 Jimanbanashi F1 July 11, 2023, 5:19 p.m. OK GNU C++14 TESTS 26 140 204800
213406988 Suwan F1 July 11, 2023, 6:17 p.m. OK GNU C++14 TESTS 26 187 0
213450537 Galetx F1 July 12, 2023, 4:18 a.m. OK GNU C++14 TESTS 26 187 0
213440722 huzhaoyang F1 July 12, 2023, 2:04 a.m. OK GNU C++14 TESTS 26 233 1228800
213408366 KroosTheKeenGlint F1 July 11, 2023, 6:26 p.m. OK GNU C++17 TESTS 26 15 1228800
213397396 Morphymorphymorphy F1 July 11, 2023, 5:19 p.m. OK GNU C++17 TESTS 26 15 5324800
213442336 KaphI F1 July 12, 2023, 2:24 a.m. OK GNU C++17 TESTS 26 15 16384000
213426827 Unlimited_zero F1 July 11, 2023, 10:11 p.m. OK GNU C++17 TESTS 26 31 3379200
213399278 plast F1 July 11, 2023, 5:25 p.m. OK GNU C++17 TESTS 26 31 3891200
213426175 coding_octopus F1 July 11, 2023, 9:59 p.m. OK GNU C++17 TESTS 26 31 9011200
213417774 ATM12345 F1 July 11, 2023, 7:59 p.m. OK GNU C++17 TESTS 26 31 16486400
213424880 lotusblume F1 July 11, 2023, 9:35 p.m. OK GNU C++17 TESTS 26 46 204800
213437430 Hope-well F1 July 12, 2023, 1:24 a.m. OK GNU C++17 TESTS 26 93 921600
213448949 Wolam F1 July 12, 2023, 3:51 a.m. OK GNU C++17 TESTS 26 171 102400
213418390 neal F1 July 11, 2023, 8:07 p.m. OK GNU C++17 (64) TESTS 26 15 409600
213398835 kotatsugame F1 July 11, 2023, 5:24 p.m. OK GNU C++17 (64) TESTS 26 15 512000
213411400 Kude F1 July 11, 2023, 6:50 p.m. OK GNU C++17 (64) TESTS 26 15 614400
213446430 MIKEFENG F1 July 12, 2023, 3:14 a.m. OK GNU C++17 (64) TESTS 26 15 1536000
213392920 wsyear F1 July 11, 2023, 5:04 p.m. OK GNU C++17 (64) TESTS 26 31 102400
213418811 stevenkplus F1 July 11, 2023, 8:11 p.m. OK GNU C++17 (64) TESTS 26 31 614400
213454807 zihouzhong F1 July 12, 2023, 5:28 a.m. OK GNU C++17 (64) TESTS 26 31 614400
213447755 DoNotMoZheng F1 July 12, 2023, 3:33 a.m. OK GNU C++17 (64) TESTS 26 31 40038400
213447741 DoNotMoZheng F1 July 12, 2023, 3:33 a.m. OK GNU C++17 (64) TESTS 26 31 40038400
213441862 enslaved F1 July 12, 2023, 2:19 a.m. OK GNU C++17 (64) TESTS 26 46 204800
213396720 gortomi F1 July 11, 2023, 5:17 p.m. OK GNU C++20 (64) TESTS 26 15 0
213393662 Timelpn F1 July 11, 2023, 5:06 p.m. OK GNU C++20 (64) TESTS 26 15 102400
213393017 i8d F1 July 11, 2023, 5:04 p.m. OK GNU C++20 (64) TESTS 26 15 102400
213407038 memset0c F1 July 11, 2023, 6:18 p.m. OK GNU C++20 (64) TESTS 26 15 102400
213406879 Mangooste F1 July 11, 2023, 6:16 p.m. OK GNU C++20 (64) TESTS 26 15 102400
213406724 Mangooste F1 July 11, 2023, 6:15 p.m. OK GNU C++20 (64) TESTS 26 15 102400
213402159 joww F1 July 11, 2023, 5:34 p.m. OK GNU C++20 (64) TESTS 26 15 102400
213394228 Snow-Flower F1 July 11, 2023, 5:08 p.m. OK GNU C++20 (64) TESTS 26 15 102400
213438225 kkk20002 F1 July 12, 2023, 1:34 a.m. OK GNU C++20 (64) TESTS 26 15 307200
213453522 Retired_Isaunoya F1 July 12, 2023, 5:07 a.m. OK GNU C++20 (64) TESTS 26 15 307200
213437707 dzhi F1 July 12, 2023, 1:27 a.m. OK Java 11 TESTS 26 187 0
213437896 dzhi F1 July 12, 2023, 1:30 a.m. OK Java 11 TESTS 26 202 0
213437617 dzhi F1 July 12, 2023, 1:26 a.m. OK Java 11 TESTS 26 202 0
213437487 dzhi F1 July 12, 2023, 1:25 a.m. OK Java 11 TESTS 26 218 0
213402337 SecondThread F1 July 11, 2023, 5:34 p.m. OK Java 8 TESTS 26 498 38502400
213394234 top73only F1 July 11, 2023, 5:08 p.m. OK Kotlin 1.6 TESTS 26 1200 1331200
213408219 CristhianCH F1 July 11, 2023, 6:25 p.m. OK PyPy 3-64 TESTS 26 187 9625600
213395169 chinerist F1 July 11, 2023, 5:11 p.m. OK PyPy 3-64 TESTS 26 358 11366400

remove filters

Back to search problems