Codeforces Round 831 (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
1740 Codeforces Round 831 (Div. 1 + Div. 2) FINISHED False 9900 64788599 Oct. 29, 2022, 9:10 a.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 11115 ) C Bricks and Bags PROGRAMMING constructive algorithms games greedy sortings 1400

B'There are n bricks numbered from 1 to n . Brick i has a weight of a_i . Pak Chanek has 3 bags numbered from 1 to 3 that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Dengklek will take exactly one brick from each bag. Let w_j be the weight of the brick Bu Dengklek takes from bag j . The score is calculated as |w_1 - w_2| + |w_2 - w_3| , where |x| denotes the absolute value of x . It is known that Bu Dengklek will take the bricks in such a way that minimises the score. What is the maximum possible final score if Pak Chanek distributes the bricks optimally? Each test contains multiple test cases. The first line contains an integer t ( 1 <= q t <= q 2 cdot 10^4 ) -- the number of test cases. The following lines contain the description of each test case. The first line of each test case contains an integer n ( 3 <= q n <= q 2 cdot 10^5 ) -- the number of bricks. The second line of each test case contains n integers a_1, a_2, ldots, a_n ( 1 <= q a_i <= q 10^9 ) -- the weights of the bricks. 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 line containing an integer representing the maximum possible final score if Pak Chanek distributes the bricks optimally. In the first test case, one way of achieving a final score of 6 is to do the following: If Pak Chanek distributes the bricks that way, a way Bu Dengklek can take the bricks is: The score is |a_5 - a_3| + |a_3 - a_2| = |3 - 5| + |5 - 1| = 6 . It can be shown that Bu Dengklek cannot get a smaller score from this distribution. It can be shown that there is no other distribution that results in a final score bigger than 6 . '...

Tutorials

Tutorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
178401914 FatalityNT C Oct. 29, 2022, 12:50 p.m. OK C# 8 TESTS 27 233 28467200 1400
178393816 chandaka C Oct. 29, 2022, 11:51 a.m. OK GNU C11 TESTS 27 124 1638400 1400
178427801 zl17 C Oct. 29, 2022, 4:21 p.m. OK GNU C11 TESTS 27 124 1638400 1400
178436950 yurui111 C Oct. 29, 2022, 5:37 p.m. OK GNU C11 TESTS 27 124 1638400 1400
178387602 Uanu C Oct. 29, 2022, 11:33 a.m. OK GNU C11 TESTS 27 124 2457600 1400
178466564 Tom66 C Oct. 30, 2022, 3:28 a.m. OK GNU C++14 TESTS 27 31 2252800 1400
178462485 tokitsukaze C Oct. 30, 2022, 1:13 a.m. OK GNU C++14 TESTS 27 46 2048000 1400
178466702 Tom66 C Oct. 30, 2022, 3:31 a.m. OK GNU C++14 TESTS 27 46 2252800 1400
178472642 AkaiLemon C Oct. 30, 2022, 5:33 a.m. OK GNU C++14 TESTS 27 62 819200 1400
178463314 RSLJ C Oct. 30, 2022, 1:46 a.m. OK GNU C++14 TESTS 27 62 819200 1400
178434880 _Gargera_ C Oct. 29, 2022, 5:17 p.m. OK GNU C++14 TESTS 27 77 819200 1400
178468461 Gordon_Z C Oct. 30, 2022, 4:16 a.m. OK GNU C++14 TESTS 27 78 819200 1400
178466253 Nerovix C Oct. 30, 2022, 3:19 a.m. OK GNU C++14 TESTS 27 78 819200 1400
178465042 Jakon_ C Oct. 30, 2022, 2:42 a.m. OK GNU C++14 TESTS 27 78 819200 1400
178472838 Homura_jar C Oct. 30, 2022, 5:36 a.m. OK GNU C++14 TESTS 27 78 819200 1400
178405719 lqmm C Oct. 29, 2022, 1:17 p.m. OK GNU C++17 TESTS 27 62 819200 1400
178472492 A_Big_Jiong C Oct. 30, 2022, 5:31 a.m. OK GNU C++17 TESTS 27 62 819200 1400
178466470 Poseidon. C Oct. 30, 2022, 3:25 a.m. OK GNU C++17 TESTS 27 62 819200 1400
178465426 Capterlliar C Oct. 30, 2022, 2:53 a.m. OK GNU C++17 TESTS 27 62 2457600 1400
178464247 acwing_meow C Oct. 30, 2022, 2:18 a.m. OK GNU C++17 TESTS 27 77 819200 1400
178392376 Xenophloxic C Oct. 29, 2022, 11:47 a.m. OK GNU C++17 TESTS 27 77 819200 1400
178474055 vjudge2 C Oct. 30, 2022, 5:53 a.m. OK GNU C++17 TESTS 27 78 819200 1400
178462385 roadbike80 C Oct. 30, 2022, 1:09 a.m. OK GNU C++17 TESTS 27 78 819200 1400
178463404 PUNGqw C Oct. 30, 2022, 1:49 a.m. OK GNU C++17 TESTS 27 78 819200 1400
178466456 Poseidon. C Oct. 30, 2022, 3:25 a.m. OK GNU C++17 TESTS 27 78 819200 1400
178470107 wdnmdddddd C Oct. 30, 2022, 4:53 a.m. OK GNU C++17 (64) TESTS 27 46 1638400 1400
178434226 mushroom_ovo C Oct. 29, 2022, 5:11 p.m. OK GNU C++17 (64) TESTS 27 61 819200 1400
178398601 atulkumarmaurya201 C Oct. 29, 2022, 12:35 p.m. OK GNU C++17 (64) TESTS 27 61 819200 1400
178387863 prakhar11 C Oct. 29, 2022, 11:34 a.m. OK GNU C++17 (64) TESTS 27 61 819200 1400
178455196 AkramElOmrani C Oct. 29, 2022, 9:15 p.m. OK GNU C++17 (64) TESTS 27 61 1638400 1400
178458435 dufresne_1949 C Oct. 29, 2022, 10:33 p.m. OK GNU C++17 (64) TESTS 27 61 1638400 1400
178431969 MisbahUddinTareQ C Oct. 29, 2022, 4:49 p.m. OK GNU C++17 (64) TESTS 27 61 1638400 1400
178411463 Hantek C Oct. 29, 2022, 1:59 p.m. OK GNU C++17 (64) TESTS 27 61 1638400 1400
178431224 Maheen654 C Oct. 29, 2022, 4:42 p.m. OK GNU C++17 (64) TESTS 27 62 819200 1400
178464447 OTTFF C Oct. 30, 2022, 2:25 a.m. OK GNU C++17 (64) TESTS 27 62 819200 1400
178464831 rxlfd314 C Oct. 30, 2022, 2:36 a.m. OK GNU C++20 (64) TESTS 27 46 819200 1400
178463596 Tree2003 C Oct. 30, 2022, 1:55 a.m. OK GNU C++20 (64) TESTS 27 46 819200 1400
178463582 Ashoka_ C Oct. 30, 2022, 1:55 a.m. OK GNU C++20 (64) TESTS 27 46 819200 1400
178461334 _arcade C Oct. 30, 2022, 12:25 a.m. OK GNU C++20 (64) TESTS 27 46 819200 1400
178459145 stone01098 C Oct. 29, 2022, 10:58 p.m. OK GNU C++20 (64) TESTS 27 46 819200 1400
178449686 dsv6799 C Oct. 29, 2022, 8:01 p.m. OK GNU C++20 (64) TESTS 27 46 819200 1400
178466424 soda_bottle C Oct. 30, 2022, 3:24 a.m. OK GNU C++20 (64) TESTS 27 46 819200 1400
178473457 retard_qwq C Oct. 30, 2022, 5:45 a.m. OK GNU C++20 (64) TESTS 27 46 819200 1400
178466004 kaiwandao C Oct. 30, 2022, 3:11 a.m. OK GNU C++20 (64) TESTS 27 46 819200 1400
178464885 silence_suzuka C Oct. 30, 2022, 2:37 a.m. OK GNU C++20 (64) TESTS 27 46 819200 1400
178404247 Kanishka_bansode C Oct. 29, 2022, 1:05 p.m. OK Java 11 TESTS 27 249 3174400 1400
178438805 veerabhadra C Oct. 29, 2022, 5:54 p.m. OK Java 11 TESTS 27 249 5017600 1400
178444140 bajpaisharanya C Oct. 29, 2022, 6:50 p.m. OK Java 11 TESTS 27 295 0 1400
178438396 princeayush04 C Oct. 29, 2022, 5:50 p.m. OK Java 11 TESTS 27 311 6451200 1400
178394053 FirstException C Oct. 29, 2022, 11:51 a.m. OK Java 11 TESTS 27 312 67276800 1400
178435048 _milon_3.4 C Oct. 29, 2022, 5:19 p.m. OK Java 11 TESTS 27 327 3072000 1400
178414124 g_square C Oct. 29, 2022, 2:20 p.m. OK Java 11 TESTS 27 358 3174400 1400
178393830 pushkar.lonkar21 C Oct. 29, 2022, 11:51 a.m. OK Java 11 TESTS 27 405 0 1400
178442767 jagnathreddy9 C Oct. 29, 2022, 6:34 p.m. OK Java 11 TESTS 27 545 0 1400
178401109 Robot1 C Oct. 29, 2022, 12:45 p.m. OK Java 11 TESTS 27 577 0 1400
178402034 serndipty_ C Oct. 29, 2022, 12:50 p.m. OK Java 17 TESTS 27 218 1536000 1400
178409122 alibaba C Oct. 29, 2022, 1:43 p.m. OK Java 17 TESTS 27 280 4403200 1400
178405041 kkz666 C Oct. 29, 2022, 1:12 p.m. OK Java 17 TESTS 27 280 4710400 1400
178404935 kkz666 C Oct. 29, 2022, 1:11 p.m. OK Java 17 TESTS 27 312 4608000 1400
178442212 Thejas_n C Oct. 29, 2022, 6:28 p.m. OK Java 17 TESTS 27 342 7475200 1400
178445515 harman1148 C Oct. 29, 2022, 7:07 p.m. OK Java 17 TESTS 27 374 23552000 1400
178441884 merlin_ C Oct. 29, 2022, 6:25 p.m. OK Java 17 TESTS 27 421 22016000 1400
178455966 zaghaltariq007 C Oct. 29, 2022, 9:31 p.m. OK Java 17 TESTS 27 561 921600 1400
178456155 zaghaltariq007 C Oct. 29, 2022, 9:36 p.m. OK Java 17 TESTS 27 561 1126400 1400
178390366 RahulSriv C Oct. 29, 2022, 11:40 a.m. OK Java 17 TESTS 27 608 921600 1400
178398769 ikillmyself C Oct. 29, 2022, 12:36 p.m. OK Java 8 TESTS 27 171 0 1400
178409645 Virendra115 C Oct. 29, 2022, 1:46 p.m. OK Java 8 TESTS 27 171 11468800 1400
178444469 Eslam_Ahmed C Oct. 29, 2022, 6:54 p.m. OK Java 8 TESTS 27 171 11571200 1400
178429134 shivam01_0 C Oct. 29, 2022, 4:33 p.m. OK Java 8 TESTS 27 186 11468800 1400
178438377 kausanubhav2018 C Oct. 29, 2022, 5:50 p.m. OK Java 8 TESTS 27 186 66662400 1400
178467757 youtsuha C Oct. 30, 2022, 3:58 a.m. OK Java 8 TESTS 27 202 13516800 1400
178424823 abrolu C Oct. 29, 2022, 3:54 p.m. OK Java 8 TESTS 27 202 18022400 1400
178445640 Yousef_Badr C Oct. 29, 2022, 7:08 p.m. OK Java 8 TESTS 27 249 12800000 1400
178460632 -crazy_coder- C Oct. 29, 2022, 11:56 p.m. OK Java 8 TESTS 27 265 18739200 1400
178388890 kalsitushar C Oct. 29, 2022, 11:35 a.m. OK Java 8 TESTS 27 280 11468800 1400
178419382 Gompu123 C Oct. 29, 2022, 3:05 p.m. OK Kotlin 1.5 TESTS 27 467 19968000 1400
178411022 Autlomu C Oct. 29, 2022, 1:56 p.m. OK MS C++ 2017 TESTS 27 78 2457600 1400
178447966 craybeats C Oct. 29, 2022, 7:38 p.m. OK MS C++ 2017 TESTS 27 139 819200 1400
178393989 jeanfack C Oct. 29, 2022, 11:51 a.m. OK MS C++ 2017 TESTS 27 218 1945600 1400
178463192 LiuZhaocheng C Oct. 30, 2022, 1:41 a.m. OK MS C++ 2017 TESTS 27 249 819200 1400
178473938 rummansadik C Oct. 30, 2022, 5:52 a.m. OK PyPy 3 TESTS 27 171 19046400 1400
178400840 zxcuser2 C Oct. 29, 2022, 12:43 p.m. OK PyPy 3 TESTS 27 311 23244800 1400
178407858 __DeCoder__ C Oct. 29, 2022, 1:33 p.m. OK PyPy 3 TESTS 27 514 31232000 1400
178404439 YMSeah C Oct. 29, 2022, 1:07 p.m. OK PyPy 3-64 TESTS 27 140 22732800 1400
178434870 hitthheerree C Oct. 29, 2022, 5:17 p.m. OK PyPy 3-64 TESTS 27 155 28467200 1400
178408455 olisov_va C Oct. 29, 2022, 1:38 p.m. OK PyPy 3-64 TESTS 27 155 31641600 1400
178448987 Girniiiii C Oct. 29, 2022, 7:52 p.m. OK PyPy 3-64 TESTS 27 155 31846400 1400
178469555 Mr._Oogway C Oct. 30, 2022, 4:41 a.m. OK PyPy 3-64 TESTS 27 156 29491200 1400
178402172 gesuta C Oct. 29, 2022, 12:51 p.m. OK PyPy 3-64 TESTS 27 170 31436800 1400
178393722 unknown91 C Oct. 29, 2022, 11:50 a.m. OK PyPy 3-64 TESTS 27 171 27545600 1400
178406838 SangeetaSingh C Oct. 29, 2022, 1:26 p.m. OK PyPy 3-64 TESTS 27 171 28467200 1400
178441573 govindp47 C Oct. 29, 2022, 6:21 p.m. OK PyPy 3-64 TESTS 27 171 28672000 1400
178410251 skatejoe1 C Oct. 29, 2022, 1:50 p.m. OK PyPy 3-64 TESTS 27 171 28774400 1400
178413460 longthanh12 C Oct. 29, 2022, 2:14 p.m. OK Python 3 TESTS 27 390 18329600 1400
178414182 MohamedHamed123 C Oct. 29, 2022, 2:20 p.m. OK Python 3 TESTS 27 421 18432000 1400
178414209 MohamedHamed123 C Oct. 29, 2022, 2:20 p.m. OK Python 3 TESTS 27 436 18432000 1400
178465649 Shadow___Monarch C Oct. 30, 2022, 2:59 a.m. OK Python 3 TESTS 27 468 18227200 1400
178466567 gokulraaj59 C Oct. 30, 2022, 3:28 a.m. OK Python 3 TESTS 27 468 18329600 1400
178426023 gck_16 C Oct. 29, 2022, 4:05 p.m. OK Python 3 TESTS 27 468 19148800 1400
178444864 Korneli C Oct. 29, 2022, 6:59 p.m. OK Python 3 TESTS 27 483 17920000 1400
178407641 sixthcore C Oct. 29, 2022, 1:32 p.m. OK Python 3 TESTS 27 498 17510400 1400
178465484 Shadow___Monarch C Oct. 30, 2022, 2:55 a.m. OK Python 3 TESTS 27 514 17510400 1400
178429286 Savelij C Oct. 29, 2022, 4:34 p.m. OK Python 3 TESTS 27 514 17510400 1400
178414910 mmeluz C Oct. 29, 2022, 2:26 p.m. OK Rust 2021 TESTS 27 46 7884800 1400
178422228 jcowgill C Oct. 29, 2022, 3:31 p.m. OK Rust 2021 TESTS 27 170 6246400 1400

remove filters

Back to search problems