Pinely Round 5 (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
2161 Pinely Round 5 (Div. 1 + Div. 2) FINISHED False 10800 14909088 Oct. 30, 2025, 4:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 12441 ) C Loyalty PROGRAMMING constructive algorithms greedy sortings two pointers

You are a customer in a store and want to buy (n) items. Each item (i) has a price (a_i) such that (1 \leq a_i \leq X), where (X) is a loyalty factor . Your loyalty level in the store is defined as (\lfloor {S \over X} \rfloor), where (S) is the total cost of items purchased so far. Initially, (S = 0). If you buy an item with price (p) and your loyalty level increases as a result of this purchase, you earn (p) bonus points. Your task is to find the maximum number of bonus points you can earn by choosing an optimal order of purchase for the items. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 2 \cdot 10^4)). The description of the test cases follows. The first line of each test case contains two integers (n) ((1 \leq n \leq 10^5)) and (X) ((1 \leq X \leq 10^9)) — the number of items and the loyalty factor. The second line of each test case contains (n) integers (a_1), (a_2), (\ldots), (a_n) ((1 \leq a_i \leq X)) — the prices of the items. It is guaranteed that the sum of (n) over all test cases does not exceed (10^5). For each test case, output two lines. The first line should contain a single integer — the maximum number of bonus points that can be earned. The second line should contain (n) integers — the prices of the items in an order of purchase that maximizes the number of bonus points. If there are several orders that maximize the number of bonus points, you can output any of them. In the first test case: After buying the first item (S = 1), loyalty level is 0; After buying the second item (S = 3), this increases loyalty level to (1) and earns (2) bonus points; After buying the third item (S = 5), this increases loyalty level to (2) and earns (2) bonus points; After buying the fourth item (S = 7), this increases loyalty level to (3) and earns (2) bonus p

Tutorials

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
346722488 ksandr1v C Oct. 30, 2025, 6:47 p.m. OK C# 13 TESTS 18 218 10752000
346753741 little_happy C Oct. 31, 2025, 1:36 a.m. OK C++17 (GCC 7-32) TESTS 18 78 819200
346763723 Maf_Koira_Den_Vai C Oct. 31, 2025, 4:08 a.m. OK C++17 (GCC 7-32) TESTS 18 92 102400
346748288 Evadra_jiangly C Oct. 30, 2025, 11:16 p.m. OK C++17 (GCC 7-32) TESTS 18 93 0
346760578 warbubbles C Oct. 31, 2025, 3:31 a.m. OK C++17 (GCC 7-32) TESTS 18 93 0
346755191 Presim C Oct. 31, 2025, 2:02 a.m. OK C++17 (GCC 7-32) TESTS 18 93 0
346772893 pushkardev123 C Oct. 31, 2025, 5:53 a.m. OK C++17 (GCC 7-32) TESTS 18 93 0
346769914 yuguchenyuzhengjun C Oct. 31, 2025, 5:21 a.m. OK C++17 (GCC 7-32) TESTS 18 93 0
346769251 devecent C Oct. 31, 2025, 5:14 a.m. OK C++17 (GCC 7-32) TESTS 18 93 0
346766296 LycanAlan C Oct. 31, 2025, 4:37 a.m. OK C++17 (GCC 7-32) TESTS 18 93 0
346764666 asadullo_1111 C Oct. 31, 2025, 4:19 a.m. OK C++17 (GCC 7-32) TESTS 18 93 0
346756887 qiqi_0507sinan C Oct. 31, 2025, 2:35 a.m. OK C++20 (GCC 13-64) TESTS 18 62 0
346773279 MonkeySpinning C Oct. 31, 2025, 5:57 a.m. OK C++20 (GCC 13-64) TESTS 18 62 1638400
346758563 Hugo_Zhou C Oct. 31, 2025, 3:03 a.m. OK C++20 (GCC 13-64) TESTS 18 77 0
346769623 siyam35 C Oct. 31, 2025, 5:18 a.m. OK C++20 (GCC 13-64) TESTS 18 77 0
346769085 MD.REON C Oct. 31, 2025, 5:12 a.m. OK C++20 (GCC 13-64) TESTS 18 77 0
346767584 Dark__Seith C Oct. 31, 2025, 4:54 a.m. OK C++20 (GCC 13-64) TESTS 18 77 0
346765814 HCCoder C Oct. 31, 2025, 4:32 a.m. OK C++20 (GCC 13-64) TESTS 18 77 0
346762515 ashu6919 C Oct. 31, 2025, 3:55 a.m. OK C++20 (GCC 13-64) TESTS 18 77 0
346761226 expectationOfX C Oct. 31, 2025, 3:38 a.m. OK C++20 (GCC 13-64) TESTS 18 77 0
346756867 LenmoChicken C Oct. 31, 2025, 2:35 a.m. OK C++20 (GCC 13-64) TESTS 18 77 0
346764083 U_aena C Oct. 31, 2025, 4:12 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 62 0
346730697 Koo__ C Oct. 30, 2025, 7:21 p.m. OK C++23 (GCC 14-64, msys2) TESTS 18 62 307200
346754131 FisherGo C Oct. 31, 2025, 1:43 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 62 1638400
346756524 hungchi17 C Oct. 31, 2025, 2:28 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 62 7987200
346752714 persuade C Oct. 31, 2025, 1:13 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 62 7987200
346763817 devcodefrc C Oct. 31, 2025, 4:09 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 77 0
346766907 vewake C Oct. 31, 2025, 4:45 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 77 0
346766793 YFffffffff C Oct. 31, 2025, 4:44 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 77 0
346773489 red_army98 C Oct. 31, 2025, 5:59 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 77 0
346769529 Algomancer29 C Oct. 31, 2025, 5:17 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 77 0
346724679 hollow_knight_25 C Oct. 30, 2025, 6:56 p.m. OK C# 8 TESTS 18 171 8601600
346730701 Setar C Oct. 30, 2025, 7:21 p.m. OK C# 8 TESTS 18 218 20582400
346712910 NenadDapic C Oct. 30, 2025, 6:15 p.m. OK FPC TESTS 18 218 921600
346740888 ruban C Oct. 30, 2025, 8:54 p.m. OK FPC TESTS 18 250 153702400
346741589 SARVESH65 C Oct. 30, 2025, 9:04 p.m. OK GNU C11 TESTS 18 609 921600
346731150 matrix081621 C Oct. 30, 2025, 7:23 p.m. OK GNU C11 TESTS 18 686 921600
346736631 chethan_coding C Oct. 30, 2025, 8:06 p.m. OK Go TESTS 18 124 4198400
346715258 me_shivendra01 C Oct. 30, 2025, 6:22 p.m. OK Java 21 TESTS 18 312 1740800
346716262 SumitXorY C Oct. 30, 2025, 6:25 p.m. OK Java 21 TESTS 18 312 1740800
346769597 sulabhambule C Oct. 31, 2025, 5:18 a.m. OK Java 21 TESTS 18 327 1024000
346719444 pratham15541 C Oct. 30, 2025, 6:36 p.m. OK Java 21 TESTS 18 328 1024000
346725766 s_mahata C Oct. 30, 2025, 7 p.m. OK Java 21 TESTS 18 328 1126400
346719127 Ani17et C Oct. 30, 2025, 6:35 p.m. OK Java 21 TESTS 18 343 1331200
346718672 Abhishek_Yadav123 C Oct. 30, 2025, 6:33 p.m. OK Java 21 TESTS 18 343 1433600
346713935 LakhimpurKheri C Oct. 30, 2025, 6:18 p.m. OK Java 21 TESTS 18 358 1024000
346714477 cherry1009 C Oct. 30, 2025, 6:20 p.m. OK Java 21 TESTS 18 358 1536000
346717654 Satyam_Arg C Oct. 30, 2025, 6:30 p.m. OK Java 21 TESTS 18 359 1024000
346746178 SoMeQuit C Oct. 30, 2025, 10:24 p.m. OK Java 8 TESTS 18 249 3788800
346715727 SoMeQuit C Oct. 30, 2025, 6:24 p.m. OK Java 8 TESTS 18 249 3788800
346725234 samamn_varshney C Oct. 30, 2025, 6:58 p.m. OK Java 8 TESTS 18 249 3891200
346721611 abhayrajnegi0416 C Oct. 30, 2025, 6:44 p.m. OK Java 8 TESTS 18 296 4403200
346720580 KartikKumar-01 C Oct. 30, 2025, 6:40 p.m. OK Java 8 TESTS 18 577 0
346718588 KLU2300033802 C Oct. 30, 2025, 6:33 p.m. OK Java 8 TESTS 18 578 0
346712830 kadhaipaneer21 C Oct. 30, 2025, 6:15 p.m. OK Java 8 TESTS 18 609 0
346728286 devsac12 C Oct. 30, 2025, 7:11 p.m. OK Java 8 TESTS 18 624 0
346739991 kevin_0911 C Oct. 30, 2025, 8:43 p.m. OK Java 8 TESTS 18 624 0
346718666 Nikhil_Kalavagunta C Oct. 30, 2025, 6:33 p.m. OK Java 8 TESTS 18 639 0
346727028 dglima C Oct. 30, 2025, 7:06 p.m. OK Node.js TESTS 18 483 29900800
346723935 DSKroc C Oct. 30, 2025, 6:53 p.m. OK PyPy 3 TESTS 18 499 145612800
346724942 LittleBeetroot C Oct. 30, 2025, 6:57 p.m. OK PyPy 3 TESTS 18 561 13926400
346719852 Hxncus C Oct. 30, 2025, 6:37 p.m. OK PyPy 3 TESTS 18 718 12492800
346723267 rabeysin C Oct. 30, 2025, 6:50 p.m. OK PyPy 3 TESTS 18 781 11878400
346732148 jared.mccarthy05 C Oct. 30, 2025, 7:27 p.m. OK PyPy 3 TESTS 18 811 14336000
346730106 ayan.ryukendo C Oct. 30, 2025, 7:19 p.m. OK PyPy 3 TESTS 18 812 14950400
346744500 gardengnome C Oct. 30, 2025, 9:52 p.m. OK PyPy 3-64 TESTS 18 125 18636800
346764617 HumbleRobo C Oct. 31, 2025, 4:19 a.m. OK PyPy 3-64 TESTS 18 140 18329600
346747996 minuki646 C Oct. 30, 2025, 11:08 p.m. OK PyPy 3-64 TESTS 18 155 18227200
346752488 azerbenmed1730 C Oct. 31, 2025, 1:07 a.m. OK PyPy 3-64 TESTS 18 155 19558400
346714392 zzz_._nitin C Oct. 30, 2025, 6:19 p.m. OK PyPy 3-64 TESTS 18 156 18636800
346746494 DT4V C Oct. 30, 2025, 10:32 p.m. OK PyPy 3-64 TESTS 18 171 18534400
346713549 Code_Maker_only12 C Oct. 30, 2025, 6:17 p.m. OK PyPy 3-64 TESTS 18 171 18534400
346713258 kshitij_29 C Oct. 30, 2025, 6:16 p.m. OK PyPy 3-64 TESTS 18 187 18534400
346715537 saint_kirill C Oct. 30, 2025, 6:23 p.m. OK PyPy 3-64 TESTS 18 187 18636800
346735875 know_pain C Oct. 30, 2025, 7:59 p.m. OK PyPy 3-64 TESTS 18 187 18739200
346723295 koushcodes C Oct. 30, 2025, 6:50 p.m. OK Python 3 TESTS 18 171 23449600
346719941 rashadkerimov2022 C Oct. 30, 2025, 6:38 p.m. OK Python 3 TESTS 18 187 21913600
346712735 FR_7 C Oct. 30, 2025, 6:14 p.m. OK Python 3 TESTS 18 203 14950400
346714142 phantom_edge_004 C Oct. 30, 2025, 6:19 p.m. OK Python 3 TESTS 18 203 15052800
346768349 Aayush_Kumar_Singh C Oct. 31, 2025, 5:03 a.m. OK Python 3 TESTS 18 233 12595200
346720829 siddharthsharma C Oct. 30, 2025, 6:41 p.m. OK Python 3 TESTS 18 233 13721600
346732834 yrjzs C Oct. 30, 2025, 7:30 p.m. OK Python 3 TESTS 18 264 12697600
346719570 ayush24ms C Oct. 30, 2025, 6:36 p.m. OK Python 3 TESTS 18 281 22425600
346721677 ariam_ C Oct. 30, 2025, 6:44 p.m. OK Python 3 TESTS 18 296 12697600
346712941 isanz C Oct. 30, 2025, 6:15 p.m. OK Python 3 TESTS 18 296 15769600
346723585 Dilha_1526 C Oct. 30, 2025, 6:52 p.m. OK Ruby 3 TESTS 18 1109 12288000
346715979 NagisaF C Oct. 30, 2025, 6:24 p.m. OK Rust 2021 TESTS 18 93 512000
346749630 _JG_ C Oct. 30, 2025, 11:53 p.m. OK Rust 2024 TESTS 18 171 102400

remove filters

Back to search problems