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.
Problems
Alexey recently held a programming contest for students from Berland. n students participated in a contest, i -th of them solved a i problems. Now he wants to award some contestants. Alexey can award the students with diplomas of three different degrees. Each student either will receive one diploma of some degree, or won't receive any diplomas at all. Let cnt x be the number of students that are awarded with diplomas of degree x ( 1 ≤ x ≤ 3 ). The following conditions must hold: For each x ( 1 ≤ x ≤ 3 ) cnt x > 0 ; For any two degrees x and y cnt x ≤ 2· cnt y . Of course, there are a lot of ways to distribute the diplomas. Let b i be the degree of diploma i -th student will receive (or - 1 if i -th student won't receive any diplomas). Also for any x such that 1 ≤ x ≤ 3 let c x be the maximum number of problems solved by a student that receives a diploma of degree x , and d x be the minimum number of problems solved by a student that receives a diploma of degree x . Alexey wants to distribute the diplomas in such a way that: If student i solved more problems than student j , then he has to be awarded not worse than student j (it's impossible that student j receives a diploma and i doesn't receive any, and also it's impossible that both of them receive a diploma, but b j < b i ); d 1 - c 2 is maximum possible; Among all ways that maximize the previous expression, d 2 - c 3 is maximum possible; Among all ways that correspond to the two previous conditions, d 3 - c - 1 is maximum possible, where c - 1 is the maximum number of problems solved by a student that doesn't receive any diploma (or 0 if each student is awarded with some diploma). Help Alexey to find a way to award the contestants! The first line contains one integer number n ( 3 ≤ n ≤ 3000 ). The second line contains n integer numbers a 1 , a 2 , ..., a n ( 1 ≤ a i ≤ 5000 ). Output n numbers. i -th number must be equal to the degree of diploma i -th contestant will receive (or - 1 if he doesn't receiv |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|
38989433 |
xsc |
E |
June 6, 2018, 9:16 a.m. |
OK |
Clang++17 Diagnostics |
TESTS |
52 |
249 |
0 |
|
2500 |
|
32285058 |
cyand1317 |
E |
Nov. 13, 2017, 1:14 p.m. |
OK |
GNU C |
TESTS |
52 |
62 |
144588800 |
|
2500 |
|
31287214 |
Worldwide_D |
E |
Oct. 14, 2017, 1:47 a.m. |
OK |
GNU C++ |
TESTS |
52 |
15 |
0 |
|
2500 |
|
38991724 |
xsc |
E |
June 6, 2018, 10:37 a.m. |
OK |
GNU C++ |
TESTS |
52 |
30 |
0 |
|
2500 |
|
41637368 |
luogu_bot3 |
E |
Aug. 16, 2018, 1:53 a.m. |
OK |
GNU C++ |
TESTS |
52 |
31 |
0 |
|
2500 |
|
38991703 |
xsc |
E |
June 6, 2018, 10:37 a.m. |
OK |
GNU C++ |
TESTS |
52 |
31 |
0 |
|
2500 |
|
38991186 |
xsc |
E |
June 6, 2018, 10:19 a.m. |
OK |
GNU C++ |
TESTS |
52 |
31 |
0 |
|
2500 |
|
38990998 |
xsc |
E |
June 6, 2018, 10:13 a.m. |
OK |
GNU C++ |
TESTS |
52 |
31 |
0 |
|
2500 |
|
38990971 |
xsc |
E |
June 6, 2018, 10:12 a.m. |
OK |
GNU C++ |
TESTS |
52 |
31 |
0 |
|
2500 |
|
38989618 |
xsc |
E |
June 6, 2018, 9:23 a.m. |
OK |
GNU C++ |
TESTS |
52 |
31 |
0 |
|
2500 |
|
38989562 |
xsc |
E |
June 6, 2018, 9:21 a.m. |
OK |
GNU C++ |
TESTS |
52 |
31 |
0 |
|
2500 |
|
38989320 |
xsc |
E |
June 6, 2018, 9:11 a.m. |
OK |
GNU C++ |
TESTS |
52 |
31 |
0 |
|
2500 |
|
31264581 |
I_always_love_cc |
E |
Oct. 13, 2017, 3:44 a.m. |
OK |
GNU C++11 |
TESTS |
52 |
15 |
204800 |
|
2500 |
|
31300713 |
gisp_zjz |
E |
Oct. 14, 2017, 10:05 a.m. |
OK |
GNU C++11 |
TESTS |
52 |
15 |
16588800 |
|
2500 |
|
31448243 |
niu |
E |
Oct. 17, 2017, 12:31 p.m. |
OK |
GNU C++11 |
TESTS |
52 |
30 |
2560000 |
|
2500 |
|
38974947 |
xsc |
E |
June 5, 2018, 5:11 p.m. |
OK |
GNU C++11 |
TESTS |
52 |
30 |
3993600 |
|
2500 |
|
31294055 |
HellKitsune |
E |
Oct. 14, 2017, 7:55 a.m. |
OK |
GNU C++11 |
TESTS |
52 |
31 |
102400 |
|
2500 |
|
31254652 |
TrumPence |
E |
Oct. 12, 2017, 4:19 p.m. |
OK |
GNU C++11 |
TESTS |
52 |
31 |
102400 |
|
2500 |
|
31254314 |
Sorsweet |
E |
Oct. 12, 2017, 4:10 p.m. |
OK |
GNU C++11 |
TESTS |
52 |
31 |
204800 |
|
2500 |
|
63989684 |
He_Ren |
E |
Nov. 1, 2019, 12:46 p.m. |
OK |
GNU C++11 |
TESTS |
52 |
31 |
307200 |
|
2500 |
|
31267065 |
xiaohhao |
E |
Oct. 13, 2017, 7:01 a.m. |
OK |
GNU C++11 |
TESTS |
52 |
31 |
409600 |
|
2500 |
|
52066997 |
xielinhan |
E |
March 31, 2019, 5:59 a.m. |
OK |
GNU C++11 |
TESTS |
52 |
31 |
512000 |
|
2500 |
|
31249919 |
SPFA_THE_BEST_ALGORITHM |
E |
Oct. 12, 2017, 3:09 p.m. |
OK |
GNU C++14 |
TESTS |
52 |
15 |
307200 |
|
2500 |
|
33612661 |
kobae964 |
E |
Dec. 25, 2017, 9:16 a.m. |
OK |
GNU C++14 |
TESTS |
52 |
15 |
2355200 |
|
2500 |
|
31331721 |
Minnakhmetov |
E |
Oct. 15, 2017, 7:15 a.m. |
OK |
GNU C++14 |
TESTS |
52 |
15 |
2560000 |
|
2500 |
|
31249136 |
dreamoon_love_AA |
E |
Oct. 12, 2017, 3 p.m. |
OK |
GNU C++14 |
TESTS |
52 |
15 |
41779200 |
|
2500 |
|
38989332 |
xsc |
E |
June 6, 2018, 9:11 a.m. |
OK |
GNU C++14 |
TESTS |
52 |
30 |
204800 |
|
2500 |
|
38974899 |
xsc |
E |
June 5, 2018, 5:09 p.m. |
OK |
GNU C++14 |
TESTS |
52 |
30 |
3788800 |
|
2500 |
|
31939138 |
orz010orz |
E |
Nov. 1, 2017, 5:57 a.m. |
OK |
GNU C++14 |
TESTS |
52 |
31 |
307200 |
|
2500 |
|
31261844 |
-Morass- |
E |
Oct. 12, 2017, 10:48 p.m. |
OK |
GNU C++14 |
TESTS |
52 |
31 |
307200 |
|
2500 |
|
64167697 |
gelumntrez |
E |
Nov. 3, 2019, 5 p.m. |
OK |
GNU C++14 |
TESTS |
52 |
31 |
409600 |
|
2500 |
|
31251022 |
chemthan |
E |
Oct. 12, 2017, 3:22 p.m. |
OK |
GNU C++14 |
TESTS |
52 |
31 |
409600 |
|
2500 |
|
36307598 |
WooDeND |
E |
March 15, 2018, 4:39 p.m. |
OK |
GNU C++17 |
TESTS |
52 |
15 |
2150400 |
|
2500 |
|
38974324 |
xsc |
E |
June 5, 2018, 4:40 p.m. |
OK |
GNU C++17 |
TESTS |
52 |
31 |
3891200 |
|
2500 |
|
59604176 |
Hacheylight |
E |
Aug. 28, 2019, 7:56 a.m. |
OK |
GNU C++17 |
TESTS |
52 |
46 |
307200 |
|
2500 |
|
65404347 |
lrvideckis |
E |
Nov. 20, 2019, 2:04 a.m. |
OK |
GNU C++17 |
TESTS |
52 |
46 |
409600 |
|
2500 |
|
67154390 |
AM. |
E |
Dec. 18, 2019, 11:59 a.m. |
OK |
GNU C++17 |
TESTS |
52 |
62 |
102400 |
|
2500 |
|
41127041 |
LHiC |
E |
Aug. 2, 2018, 2:45 p.m. |
OK |
GNU C++17 |
TESTS |
52 |
62 |
102400 |
|
2500 |
|
36886995 |
karasek |
E |
April 2, 2018, 6:49 p.m. |
OK |
GNU C++17 |
TESTS |
52 |
109 |
3481600 |
|
2500 |
|
47226175 |
chinmay0906 |
E |
Dec. 18, 2018, 4:35 p.m. |
OK |
GNU C++17 |
TESTS |
52 |
109 |
72396800 |
|
2500 |
|
67629923 |
Ricky_pon |
E |
Dec. 26, 2019, 2:57 a.m. |
OK |
GNU C++17 |
TESTS |
52 |
124 |
102400 |
|
2500 |
|
42750131 |
FastestFinger smartnj |
E |
Sept. 11, 2018, 12:38 a.m. |
OK |
GNU C++17 |
TESTS |
52 |
186 |
72704000 |
|
2500 |
|
48109173 |
qb2008 |
E |
Jan. 9, 2019, 8:03 a.m. |
OK |
Go |
TESTS |
52 |
31 |
204800 |
|
2500 |
|
31257882 |
uwi |
E |
Oct. 12, 2017, 6:24 p.m. |
OK |
Java 8 |
TESTS |
52 |
139 |
0 |
|
2500 |
|
34163907 |
svilen |
E |
Jan. 14, 2018, 12:32 a.m. |
OK |
Java 8 |
TESTS |
52 |
217 |
21401600 |
|
2500 |
|
31270135 |
Ahmad_Elsagheer |
E |
Oct. 13, 2017, 9:32 a.m. |
OK |
Java 8 |
TESTS |
52 |
389 |
0 |
|
2500 |
|
33016131 |
Renphil |
E |
Dec. 8, 2017, 7:01 a.m. |
OK |
Java 8 |
TESTS |
52 |
436 |
20787200 |
|
2500 |
|
33755508 |
vovacomua |
E |
Dec. 29, 2017, 9:11 a.m. |
OK |
Java 8 |
TESTS |
52 |
608 |
21504000 |
|
2500 |
|
38989387 |
xsc |
E |
June 6, 2018, 9:14 a.m. |
OK |
MS C++ |
TESTS |
52 |
31 |
204800 |
|
2500 |
|
68957413 |
hakobdilif |
E |
Jan. 16, 2020, 9:03 p.m. |
OK |
MS C++ 2017 |
TESTS |
52 |
46 |
409600 |
|
2500 |
remove filters
Back to search problems