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'Polycarp 's phone book contains n phone numbers, each of them is described by s_i -- the number itself and m_i -- the number of times Polycarp dials it in daily. Polycarp has just bought a brand new phone with an amazing speed dial feature! More precisely, k buttons on it can have a number assigned to it (not necessary from the phone book). To enter some number Polycarp can press one of these k buttons and then finish the number using usual digit buttons (entering a number with only digit buttons is also possible). Speed dial button can only be used when no digits are entered. No button can have its number reassigned. What is the minimal total number of digit number presses Polycarp can achieve after he assigns numbers to speed dial buttons and enters each of the numbers from his phone book the given number of times in an optimal way? The first line contains two integers n and k ( 1 <= n <= 500 , 1 <= k <= 10 ) -- the amount of numbers in Polycarp 's phone book and the number of speed dial buttons his new phone has. The i -th of the next n lines contain a string s_i and an integer m_i (1 <= m_i <= 500) , where s_i is a non-empty string of digits from 0 to 9 inclusive (the i -th number), and m_i is the amount of times it will be dialed, respectively. It is guaranteed that the total length of all phone numbers will not exceed 500 . Print a single integer -- the minimal total number of digit number presses Polycarp can achieve after he assigns numbers to speed dial buttons and enters each of the numbers from his phone book the given number of times in an optimal way. The only speed dial button in the first example should have "0001" on it. The total number of digit button presses will be 0 cdot 5 for the first number + 3 cdot 4 for the second + 2 cdot 1 for the third. 14 in total. The only speed dial button in the'... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
46473130 |
vjudge5 |
F |
Dec. 2, 2018, 7:49 a.m. |
OK |
Clang++17 Diagnostics |
TESTS |
70 |
1326 |
45977600 |
|
2900 |
49224621 |
rainboy |
F |
Jan. 30, 2019, 9:32 p.m. |
OK |
GNU C11 |
TESTS |
70 |
31 |
22220800 |
|
2900 |
50782608 |
Love_mona |
F |
March 4, 2019, 12:03 p.m. |
OK |
GNU C++11 |
TESTS |
70 |
31 |
102400 |
|
2900 |
46633126 |
frodakcin |
F |
Dec. 5, 2018, 4:55 a.m. |
OK |
GNU C++11 |
TESTS |
70 |
31 |
1331200 |
|
2900 |
46389042 |
Winniechen |
F |
Nov. 30, 2018, 3:39 a.m. |
OK |
GNU C++11 |
TESTS |
70 |
31 |
5222400 |
|
2900 |
50786162 |
newbiechdboom0 |
F |
March 4, 2019, 1:26 p.m. |
OK |
GNU C++11 |
TESTS |
70 |
31 |
11059200 |
|
2900 |
48655271 |
ReaLNero1 |
F |
Jan. 21, 2019, 2:09 a.m. |
OK |
GNU C++11 |
TESTS |
70 |
31 |
11366400 |
|
2900 |
47610852 |
_23333 |
F |
Dec. 28, 2018, 8:03 a.m. |
OK |
GNU C++11 |
TESTS |
70 |
31 |
11366400 |
|
2900 |
46364379 |
Elegia |
F |
Nov. 29, 2018, 12:34 p.m. |
OK |
GNU C++11 |
TESTS |
70 |
31 |
11366400 |
|
2900 |
46357071 |
kamiyoru |
F |
Nov. 29, 2018, 8:55 a.m. |
OK |
GNU C++11 |
TESTS |
70 |
31 |
11366400 |
|
2900 |
46565782 |
krijgertje |
F |
Dec. 3, 2018, 10:55 p.m. |
OK |
GNU C++11 |
TESTS |
70 |
31 |
11468800 |
|
2900 |
50774198 |
Tgotp |
F |
March 4, 2019, 7:19 a.m. |
OK |
GNU C++11 |
TESTS |
70 |
31 |
11571200 |
|
2900 |
52152184 |
the_Despair_ |
F |
April 1, 2019, 12:03 p.m. |
OK |
GNU C++14 |
TESTS |
70 |
31 |
11366400 |
|
2900 |
50776206 |
Itst |
F |
March 4, 2019, 8:38 a.m. |
OK |
GNU C++14 |
TESTS |
70 |
31 |
11468800 |
|
2900 |
46468146 |
bzh |
F |
Dec. 2, 2018, 5:28 a.m. |
OK |
GNU C++14 |
TESTS |
70 |
31 |
12492800 |
|
2900 |
46365498 |
ugly2333 |
F |
Nov. 29, 2018, 1:03 p.m. |
OK |
GNU C++14 |
TESTS |
70 |
31 |
13619200 |
|
2900 |
69222165 |
Zetr0 |
F |
Jan. 21, 2020, 5:20 a.m. |
OK |
GNU C++14 |
TESTS |
70 |
31 |
23142400 |
|
2900 |
55214270 |
Dyswan |
F |
June 6, 2019, 3:58 p.m. |
OK |
GNU C++14 |
TESTS |
70 |
31 |
50380800 |
|
2900 |
52905177 |
radoslav11 |
F |
April 17, 2019, 12:25 p.m. |
OK |
GNU C++14 |
TESTS |
70 |
46 |
307200 |
|
2900 |
46347478 |
TimonKnigge |
F |
Nov. 28, 2018, 6:59 p.m. |
OK |
GNU C++14 |
TESTS |
70 |
46 |
512000 |
|
2900 |
46754617 |
shdut |
F |
Dec. 8, 2018, 11:02 a.m. |
OK |
GNU C++14 |
TESTS |
70 |
46 |
11366400 |
|
2900 |
49389424 |
nwei |
F |
Feb. 3, 2019, 8:55 a.m. |
OK |
GNU C++14 |
TESTS |
70 |
46 |
11571200 |
|
2900 |
67203823 |
KonaeAkira |
F |
Dec. 19, 2019, 11:47 a.m. |
OK |
GNU C++17 |
TESTS |
70 |
31 |
512000 |
|
2900 |
46373408 |
arslan2003007001 |
F |
Nov. 29, 2018, 5:07 p.m. |
OK |
GNU C++17 |
TESTS |
70 |
31 |
1331200 |
|
2900 |
46365264 |
Benq |
F |
Nov. 29, 2018, 12:57 p.m. |
OK |
GNU C++17 |
TESTS |
70 |
31 |
1331200 |
|
2900 |
66508267 |
KrK |
F |
Dec. 8, 2019, 3:19 p.m. |
OK |
GNU C++17 |
TESTS |
70 |
31 |
11366400 |
|
2900 |
63632550 |
pootis |
F |
Oct. 28, 2019, 6:57 a.m. |
OK |
GNU C++17 |
TESTS |
70 |
31 |
11366400 |
|
2900 |
46743096 |
haleyk100198 |
F |
Dec. 8, 2018, 4:59 a.m. |
OK |
GNU C++17 |
TESTS |
70 |
31 |
12185600 |
|
2900 |
46515168 |
congmingyige |
F |
Dec. 2, 2018, 3:42 p.m. |
OK |
GNU C++17 |
TESTS |
70 |
31 |
12595200 |
|
2900 |
62767588 |
ljk123 |
F |
Oct. 17, 2019, 9:10 a.m. |
OK |
GNU C++17 |
TESTS |
70 |
31 |
24678400 |
|
2900 |
54165025 |
Kmcode |
F |
May 15, 2019, 8:19 a.m. |
OK |
GNU C++17 |
TESTS |
70 |
46 |
12697600 |
|
2900 |
46387662 |
fcwww |
F |
Nov. 30, 2018, 1:37 a.m. |
OK |
GNU C++17 |
TESTS |
70 |
46 |
13414400 |
|
2900 |
49224622 |
Dukkha |
F |
Jan. 30, 2019, 9:32 p.m. |
OK |
Java 8 |
TESTS |
70 |
140 |
4710400 |
|
2900 |
68452206 |
dalt |
F |
Jan. 9, 2020, 2:45 p.m. |
OK |
Java 8 |
TESTS |
70 |
171 |
46387200 |
|
2900 |
68452031 |
dalt |
F |
Jan. 9, 2020, 2:41 p.m. |
OK |
Java 8 |
TESTS |
70 |
171 |
46592000 |
|
2900 |
52275759 |
Ahmad |
F |
April 3, 2019, 2:43 p.m. |
OK |
Java 8 |
TESTS |
70 |
701 |
146329600 |
|
2900 |
48045680 |
ariel.nowik |
F |
Jan. 7, 2019, 2:29 a.m. |
OK |
Java 8 |
TESTS |
70 |
1435 |
15052800 |
|
2900 |
53306926 |
2162851 |
F |
April 26, 2019, 3:42 a.m. |
OK |
Java 8 |
TESTS |
70 |
1466 |
15052800 |
|
2900 |
46395772 |
Noureldin |
F |
Nov. 30, 2018, 9:09 a.m. |
OK |
Java 8 |
TESTS |
70 |
1778 |
268390400 |
|
2900 |
47388840 |
moss3s |
F |
Dec. 23, 2018, 6:54 a.m. |
OK |
Kotlin |
TESTS |
70 |
436 |
6144000 |
|
2900 |
remove filters
Back to search problems