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
B"This is the hard version of the problem. The only difference is in the constraint on q . You can make hacks only if all versions of the problem are solved. Zookeeper has been teaching his q sheep how to write and how to add. The i -th sheep has to write exactly k non-negative integers with the sum n_i . Strangely, sheep have superstitions about digits and believe that the digits 3 , 6 , and 9 are lucky. To them, the fortune of a number depends on the decimal representation of the number; the fortune of a number is equal to the sum of fortunes of its digits, and the fortune of a digit depends on its value and position and can be described by the following table. For example, the number 319 has fortune F_{2} + 3F_{0} . Each sheep wants to maximize the sum of fortune among all its k written integers. Can you help them? The first line contains a single integer k ( 1 <= q k <= q 999999 ): the number of numbers each sheep has to write. The next line contains six integers F_0 , F_1 , F_2 , F_3 , F_4 , F_5 ( 1 <= q F_i <= q 10^9 ): the fortune assigned to each digit. The next line contains a single integer q ( 1 <= q q <= q 100 ,000 ): the number of sheep. Each of the next q lines contains a single integer n_i ( 1 <= q n_i <= q 999999 ): the sum of numbers that i -th sheep has to write. Print q lines, where the i -th line contains the maximum sum of fortune of all numbers of the i -th sheep. In the first test case, 57 = 9 + 9 + 39 . The three 9 's contribute 1 cdot 3 and 3 at the tens position contributes 2 cdot 1 . Hence the sum of fortune is 11 . In the second test case, 63 = 35 + 19 + 9 . The sum of fortune is 8 . "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
95838747 |
zhoukangyang |
G2 |
Oct. 18, 2020, 4:12 a.m. |
OK |
GNU C++11 |
TESTS |
43 |
202 |
7987200 |
|
|
95837751 |
zhoukangyang |
G2 |
Oct. 18, 2020, 3:44 a.m. |
OK |
GNU C++11 |
TESTS |
43 |
233 |
7987200 |
|
|
95832312 |
EmptySoulist |
G2 |
Oct. 18, 2020, 12:21 a.m. |
OK |
GNU C++11 |
TESTS |
43 |
342 |
24064000 |
|
|
95813471 |
jhknmj |
G2 |
Oct. 17, 2020, 4:53 p.m. |
OK |
GNU C++11 |
TESTS |
43 |
374 |
7987200 |
|
|
95813826 |
s_r_f |
G2 |
Oct. 17, 2020, 4:57 p.m. |
OK |
GNU C++11 |
TESTS |
43 |
764 |
44134400 |
|
|
95802598 |
duality |
G2 |
Oct. 17, 2020, 3:21 p.m. |
OK |
GNU C++11 |
TESTS |
43 |
951 |
58777600 |
|
|
95840357 |
KillerX |
G2 |
Oct. 18, 2020, 4:56 a.m. |
OK |
GNU C++11 |
TESTS |
43 |
2324 |
40140800 |
|
|
95816575 |
BigBag |
G2 |
Oct. 17, 2020, 5:35 p.m. |
OK |
GNU C++11 |
TESTS |
43 |
2324 |
41267200 |
|
|
95801451 |
ynsm |
G2 |
Oct. 17, 2020, 3:18 p.m. |
OK |
GNU C++11 |
TESTS |
43 |
2511 |
56934400 |
|
|
95810638 |
lqs2015 |
G2 |
Oct. 17, 2020, 4:26 p.m. |
OK |
GNU C++11 |
TESTS |
43 |
2620 |
62361600 |
|
|
95825009 |
BlueDiamond |
G2 |
Oct. 17, 2020, 8 p.m. |
OK |
GNU C++14 |
TESTS |
43 |
311 |
7987200 |
|
|
95804331 |
jumpmelon |
G2 |
Oct. 17, 2020, 3:26 p.m. |
OK |
GNU C++14 |
TESTS |
43 |
389 |
32051200 |
|
|
95811863 |
TadijaSebez |
G2 |
Oct. 17, 2020, 4:35 p.m. |
OK |
GNU C++14 |
TESTS |
43 |
452 |
16076800 |
|
|
95812564 |
Sooke |
G2 |
Oct. 17, 2020, 4:42 p.m. |
OK |
GNU C++14 |
TESTS |
43 |
546 |
84172800 |
|
|
95815334 |
zeliboba |
G2 |
Oct. 17, 2020, 5:17 p.m. |
OK |
GNU C++14 |
TESTS |
43 |
732 |
19353600 |
|
|
95813024 |
LJC00118 |
G2 |
Oct. 17, 2020, 4:47 p.m. |
OK |
GNU C++14 |
TESTS |
43 |
732 |
201318400 |
|
|
95799521 |
800iq |
G2 |
Oct. 17, 2020, 3:12 p.m. |
OK |
GNU C++14 |
TESTS |
43 |
1278 |
67788800 |
|
|
95831571 |
MagicSpark |
G2 |
Oct. 17, 2020, 11:37 p.m. |
OK |
GNU C++14 |
TESTS |
43 |
1794 |
48128000 |
|
|
95814812 |
mHuman |
G2 |
Oct. 17, 2020, 5:10 p.m. |
OK |
GNU C++14 |
TESTS |
43 |
2355 |
160358400 |
|
|
95806012 |
chenkuowen |
G2 |
Oct. 17, 2020, 3:31 p.m. |
OK |
GNU C++17 |
TESTS |
43 |
171 |
64102400 |
|
|
95801533 |
gyz_gyz |
G2 |
Oct. 17, 2020, 3:18 p.m. |
OK |
GNU C++17 |
TESTS |
43 |
327 |
16076800 |
|
|
95834474 |
froggyzhang |
G2 |
Oct. 18, 2020, 2 a.m. |
OK |
GNU C++17 |
TESTS |
43 |
342 |
7987200 |
|
|
95812538 |
Kurpilyansky |
G2 |
Oct. 17, 2020, 4:42 p.m. |
OK |
GNU C++17 |
TESTS |
43 |
342 |
7987200 |
|
|
95799898 |
huhaoo |
G2 |
Oct. 17, 2020, 3:13 p.m. |
OK |
GNU C++17 |
TESTS |
43 |
343 |
50380800 |
|
|
95812180 |
sh1194 |
G2 |
Oct. 17, 2020, 4:38 p.m. |
OK |
GNU C++17 |
TESTS |
43 |
373 |
16076800 |
|
|
95822267 |
maximumSHOT |
G2 |
Oct. 17, 2020, 7:06 p.m. |
OK |
GNU C++17 |
TESTS |
43 |
374 |
7987200 |
|
|
95816703 |
ikatanic |
G2 |
Oct. 17, 2020, 5:37 p.m. |
OK |
GNU C++17 |
TESTS |
43 |
390 |
18841600 |
|
|
95810320 |
ikatanic |
G2 |
Oct. 17, 2020, 4:24 p.m. |
OK |
GNU C++17 |
TESTS |
43 |
405 |
20377600 |
|
|
95819556 |
ikatanic |
G2 |
Oct. 17, 2020, 6:20 p.m. |
OK |
GNU C++17 |
TESTS |
43 |
421 |
19353600 |
|
|
95810474 |
Maripium |
G2 |
Oct. 17, 2020, 4:25 p.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
93 |
10649600 |
|
|
95819454 |
sumitacchan |
G2 |
Oct. 17, 2020, 6:19 p.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
171 |
8806400 |
|
|
95817859 |
sumitacchan |
G2 |
Oct. 17, 2020, 5:55 p.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
187 |
8806400 |
|
|
95805192 |
KevinWan |
G2 |
Oct. 17, 2020, 3:28 p.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
187 |
79872000 |
|
|
95828363 |
VEGAnn |
G2 |
Oct. 17, 2020, 9:24 p.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
202 |
7987200 |
|
|
95832705 |
rama_pang |
G2 |
Oct. 18, 2020, 12:42 a.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
249 |
7987200 |
|
|
95803111 |
dreamoon_love_AA |
G2 |
Oct. 17, 2020, 3:23 p.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
265 |
36147200 |
|
|
95810207 |
Nebuchadnezzar |
G2 |
Oct. 17, 2020, 4:23 p.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
280 |
18739200 |
|
|
95833101 |
wlzhouzhuan |
G2 |
Oct. 18, 2020, 1:04 a.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
342 |
16076800 |
|
|
95836450 |
zhouzhendong |
G2 |
Oct. 18, 2020, 3:07 a.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
358 |
64102400 |
|
|
95807300 |
uwi |
G2 |
Oct. 17, 2020, 3:33 p.m. |
OK |
Java 11 |
TESTS |
43 |
2199 |
18022400 |
|
|
95834372 |
uwi |
G2 |
Oct. 18, 2020, 1:56 a.m. |
OK |
Java 11 |
TESTS |
43 |
2433 |
18432000 |
|
|
95812644 |
Tlatoani |
G2 |
Oct. 17, 2020, 4:43 p.m. |
OK |
Kotlin |
TESTS |
43 |
748 |
16486400 |
|
|
remove filters
Back to search problems