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
Pupils decided to go to amusement park. Some of them were with parents. In total, n people came to the park and they all want to get to the most extreme attraction and roll on it exactly once . Tickets for group of x people are sold on the attraction, there should be at least one adult in each group (it is possible that the group consists of one adult). The ticket price for such group is c 1 + c 2 ·( x - 1) 2 (in particular, if the group consists of one person, then the price is c 1 ). All pupils who came to the park and their parents decided to split into groups in such a way that each visitor join exactly one group, and the total price of visiting the most extreme attraction is as low as possible. You are to determine this minimum possible total price. There should be at least one adult in each group. The first line contains three integers n , c 1 and c 2 ( 1 ≤ n ≤ 200 000 , 1 ≤ c 1 , c 2 ≤ 10 7 ) — the number of visitors and parameters for determining the ticket prices for a group. The second line contains the string of length n , which consists of zeros and ones. If the i -th symbol of the string is zero, then the i -th visitor is a pupil, otherwise the i -th person is an adult. It is guaranteed that there is at least one adult. It is possible that there are no pupils. Print the minimum price of visiting the most extreme attraction for all pupils and their parents. Each of them should roll on the attraction exactly once. In the first test one group of three people should go to the attraction. Then they have to pay 4 + 1 * (3 - 1) 2 = 8 . In the second test it is better to go to the attraction in two groups. The first group should consist of two adults (for example, the first and the second person), the second should consist of one pupil and one adult (the third and the fourth person). Then each group will have a size of two and for each the price of ticket is 7 + 2 * (2 - 1) 2 = 9 . Thus, the total price for two groups is 18 . |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|
26215552 |
aleex |
A |
April 8, 2017, 9:51 a.m. |
OK |
D |
TESTS |
31 |
31 |
2969600 |
|
2300 |
|
26214337 |
nikih.10 |
A |
April 8, 2017, 8:53 a.m. |
OK |
FPC |
TESTS |
31 |
31 |
2969600 |
|
2300 |
|
26178601 |
receed |
A |
April 6, 2017, 7:53 p.m. |
OK |
FPC |
TESTS |
31 |
31 |
2969600 |
|
2300 |
|
26948035 |
vdae_2304 |
A |
May 7, 2017, 11:50 p.m. |
OK |
GNU C++ |
TESTS |
31 |
15 |
512000 |
|
2300 |
|
33242160 |
suchang |
A |
Dec. 14, 2017, 2:14 p.m. |
OK |
GNU C++ |
TESTS |
31 |
15 |
2252800 |
|
2300 |
|
26321391 |
rafaelgo2 |
A |
April 12, 2017, 3:48 p.m. |
OK |
GNU C++ |
TESTS |
31 |
46 |
2048000 |
|
2300 |
|
29231266 |
vjudge5 |
A |
Aug. 6, 2017, 2:14 a.m. |
OK |
GNU C++ |
TESTS |
31 |
46 |
2560000 |
|
2300 |
|
26342721 |
Idonthavenametouse |
A |
April 13, 2017, 3:27 p.m. |
OK |
GNU C++ |
TESTS |
31 |
46 |
2560000 |
|
2300 |
|
26176140 |
artem28 |
A |
April 6, 2017, 5:31 p.m. |
OK |
GNU C++ |
TESTS |
31 |
46 |
2560000 |
|
2300 |
|
37623274 |
vjudge5 |
A |
April 26, 2018, 2:52 a.m. |
OK |
GNU C++ |
TESTS |
31 |
61 |
3993600 |
|
2300 |
|
26223196 |
Secret_Eagle |
A |
April 8, 2017, 4:32 p.m. |
OK |
GNU C++ |
TESTS |
31 |
93 |
11161600 |
|
2300 |
|
26790609 |
lucasdeamorin |
A |
May 1, 2017, 6:33 p.m. |
OK |
GNU C++ |
TESTS |
31 |
108 |
2048000 |
|
2300 |
|
36222215 |
Samsara_Karma applese |
A |
March 12, 2018, 11:42 a.m. |
OK |
GNU C11 |
TESTS |
31 |
15 |
2150400 |
|
2300 |
|
31910816 |
BENYAM1N |
A |
Oct. 31, 2017, 5:09 a.m. |
OK |
GNU C++11 |
TESTS |
31 |
15 |
614400 |
|
2300 |
|
26184424 |
Toxel |
A |
April 7, 2017, 5:20 a.m. |
OK |
GNU C++11 |
TESTS |
31 |
15 |
2048000 |
|
2300 |
|
33233145 |
Durant_Lee |
A |
Dec. 14, 2017, 7:55 a.m. |
OK |
GNU C++11 |
TESTS |
31 |
15 |
2252800 |
|
2300 |
|
52514794 |
renjingyi |
A |
April 9, 2019, 4:17 a.m. |
OK |
GNU C++11 |
TESTS |
31 |
30 |
512000 |
|
2300 |
|
44235548 |
roll_no_1 |
A |
Oct. 13, 2018, 4:20 a.m. |
OK |
GNU C++11 |
TESTS |
31 |
31 |
512000 |
|
2300 |
|
44235597 |
roll_no_1 |
A |
Oct. 13, 2018, 4:22 a.m. |
OK |
GNU C++11 |
TESTS |
31 |
31 |
512000 |
|
2300 |
|
26172884 |
Error_404 |
A |
April 6, 2017, 2:44 p.m. |
OK |
GNU C++11 |
TESTS |
31 |
46 |
2560000 |
|
2300 |
|
26228162 |
schubertguitar |
A |
April 8, 2017, 11:59 p.m. |
OK |
GNU C++11 |
TESTS |
31 |
46 |
2560000 |
|
2300 |
|
26242091 |
chiheb19 |
A |
April 9, 2017, 5:27 p.m. |
OK |
GNU C++14 |
TESTS |
31 |
15 |
1945600 |
|
2300 |
|
26173315 |
haleyk100198 |
A |
April 6, 2017, 3:07 p.m. |
OK |
GNU C++14 |
TESTS |
31 |
15 |
2457600 |
|
2300 |
|
26172549 |
chichchich |
A |
April 6, 2017, 2:26 p.m. |
OK |
GNU C++14 |
TESTS |
31 |
15 |
6451200 |
|
2300 |
|
66588207 |
vjudge5 |
A |
Dec. 10, 2019, 12:01 p.m. |
OK |
GNU C++14 |
TESTS |
31 |
30 |
819200 |
|
2300 |
|
66895121 |
phuleethanh |
A |
Dec. 15, 2019, 12:46 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
31 |
512000 |
|
2300 |
|
42692466 |
crathva |
A |
Sept. 9, 2018, 3:20 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
31 |
512000 |
|
2300 |
|
27567567 |
Don_Pablo |
A |
June 4, 2017, 4:28 p.m. |
OK |
GNU C++14 |
TESTS |
31 |
46 |
0 |
|
2300 |
|
41527767 |
Red_Diamond |
A |
Aug. 12, 2018, 12:53 p.m. |
OK |
GNU C++14 |
TESTS |
31 |
46 |
512000 |
|
2300 |
|
26674145 |
black__box |
A |
April 26, 2017, 12:46 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
46 |
3993600 |
|
2300 |
|
37623459 |
racsosabe |
A |
April 26, 2018, 3:06 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
61 |
3891200 |
|
2300 |
|
46154372 |
corelof |
A |
Nov. 24, 2018, 8:20 a.m. |
OK |
GNU C++17 |
TESTS |
31 |
31 |
204800 |
|
2300 |
|
67588187 |
dontquit |
A |
Dec. 25, 2019, 9:05 a.m. |
OK |
GNU C++17 |
TESTS |
31 |
31 |
512000 |
|
2300 |
|
65748452 |
TearItuP |
A |
Nov. 26, 2019, 1:06 p.m. |
OK |
GNU C++17 |
TESTS |
31 |
109 |
4300800 |
|
2300 |
|
26193029 |
odomontois |
A |
April 7, 2017, 12:42 p.m. |
OK |
Haskell |
TESTS |
31 |
78 |
57651200 |
|
2300 |
|
27062131 |
toshif |
A |
May 12, 2017, 8:45 p.m. |
OK |
Java 8 |
TESTS |
31 |
124 |
0 |
|
2300 |
|
27166846 |
pitfall |
A |
May 16, 2017, 6:25 p.m. |
OK |
Java 8 |
TESTS |
31 |
139 |
0 |
|
2300 |
|
31125809 |
willwsxu |
A |
Oct. 7, 2017, 6:48 p.m. |
OK |
Java 8 |
TESTS |
31 |
171 |
0 |
|
2300 |
|
28122798 |
ruihanz |
A |
June 28, 2017, 3:08 p.m. |
OK |
Java 8 |
TESTS |
31 |
171 |
20992000 |
|
2300 |
|
31126352 |
willwsxu |
A |
Oct. 7, 2017, 7:12 p.m. |
OK |
Java 8 |
TESTS |
31 |
186 |
0 |
|
2300 |
|
26221268 |
wizardleen |
A |
April 8, 2017, 2:31 p.m. |
OK |
Java 8 |
TESTS |
31 |
202 |
155545600 |
|
2300 |
|
26228164 |
stczhc |
A |
April 9, 2017, midnight |
OK |
JavaScript |
TESTS |
31 |
46 |
8499200 |
|
2300 |
|
26206353 |
6eJIa9IzZzTeHb |
A |
April 8, 2017, 2:08 a.m. |
OK |
Mono C# |
TESTS |
31 |
62 |
9728000 |
|
2300 |
|
36221934 |
little_misfortune hagai |
A |
March 12, 2018, 11:33 a.m. |
OK |
Mono C# |
TESTS |
31 |
62 |
12595200 |
|
2300 |
|
26973573 |
autumn_eel |
A |
May 9, 2017, 12:27 p.m. |
OK |
Mono C# |
TESTS |
31 |
77 |
3686400 |
|
2300 |
|
26190227 |
csharpist |
A |
April 7, 2017, 10:46 a.m. |
OK |
Mono C# |
TESTS |
31 |
77 |
11980800 |
|
2300 |
|
26151406 |
Me-and-Myself zetilovn |
A |
April 5, 2017, 4:38 p.m. |
OK |
MS C# |
TESTS |
31 |
46 |
9830400 |
|
2300 |
|
28595644 |
green_damn |
A |
July 16, 2017, 12:11 p.m. |
OK |
MS C++ |
TESTS |
31 |
15 |
2662400 |
|
2300 |
|
31488975 |
greenmapc |
A |
Oct. 18, 2017, 5:24 p.m. |
OK |
MS C++ |
TESTS |
31 |
30 |
2662400 |
|
2300 |
|
26268609 |
nik1998 |
A |
April 10, 2017, 5:13 p.m. |
OK |
MS C++ |
TESTS |
31 |
46 |
2048000 |
|
2300 |
|
28356799 |
ItsNikolor |
A |
July 7, 2017, 9:02 p.m. |
OK |
MS C++ |
TESTS |
31 |
46 |
2048000 |
|
2300 |
|
26148516 |
rassvetik godjan |
A |
April 5, 2017, 4:03 p.m. |
OK |
MS C++ |
TESTS |
31 |
77 |
2048000 |
|
2300 |
|
26151273 |
AntonZ thequickfox |
A |
April 5, 2017, 4:36 p.m. |
OK |
Python 3 |
TESTS |
31 |
358 |
6041600 |
|
2300 |
|
42118978 |
Mk_Python_v1 |
A |
Aug. 26, 2018, 11:27 a.m. |
OK |
Python 3 |
TESTS |
31 |
421 |
512000 |
|
2300 |
|
40982554 |
ReaLNero1 |
A |
July 30, 2018, 6:28 p.m. |
OK |
Python 3 |
TESTS |
31 |
436 |
716800 |
|
2300 |
|
26980564 |
Baba_zibulya |
A |
May 9, 2017, 6:02 p.m. |
OK |
Python 3 |
TESTS |
31 |
467 |
6963200 |
|
2300 |
|
26154970 |
zurajacoco DAyamaCTF |
A |
April 5, 2017, 5:28 p.m. |
OK |
Ruby |
TESTS |
31 |
264 |
7168000 |
|
2300 |
|
26231342 |
_ShadowSong |
A |
April 9, 2017, 6:52 a.m. |
OK |
Ruby |
TESTS |
31 |
280 |
7168000 |
|
2300 |
remove filters
Back to search problems