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"// We decided to drop the legend about the power sockets but feel free to come up with your own :^) Define a chain: You are given n chains of lengths l_1, l_2, ... , l_n . You plan to build a tree using some of them. The distance between two vertices of the tree is the number of edges on the shortest path between them. If there is at least k white vertices in the resulting tree, then the value of the tree is the distance between the root and the k -th closest white vertex. What's the minimum value of the tree you can obtain? If there is no way to build a tree with at least k white vertices, then print -1. The first line contains two integers n and k ( 1 <= n <= 2 cdot 10^5 , 2 <= k <= 10^9 ) -- the number of chains and the minimum number of white vertices a tree should have to have a value. The second line contains n integers l_1, l_2, ... , l_n ( 3 <= l_i <= 2 cdot 10^5 ) -- the lengths of the chains. Print a single integer. If there is no way to build a tree with at least k white vertices, then print -1. Otherwise, print the minimum value the tree can have. You are allowed to not use all the chains, so it's optimal to only use chain of length 4 in the second example. "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
102653950 |
zgyw |
F |
Dec. 29, 2020, 3:41 a.m. |
OK |
GNU C++11 |
TESTS |
28 |
46 |
7987200 |
|
|
102658063 |
fishcathu. |
F |
Dec. 29, 2020, 5:19 a.m. |
OK |
GNU C++11 |
TESTS |
28 |
62 |
9523200 |
|
|
102657914 |
fishcathu. |
F |
Dec. 29, 2020, 5:16 a.m. |
OK |
GNU C++11 |
TESTS |
28 |
62 |
9523200 |
|
|
102629725 |
fishcathu. |
F |
Dec. 28, 2020, 5:19 p.m. |
OK |
GNU C++11 |
TESTS |
28 |
62 |
9523200 |
|
|
102628384 |
fishcathu. |
F |
Dec. 28, 2020, 5:06 p.m. |
OK |
GNU C++11 |
TESTS |
28 |
62 |
9523200 |
|
|
102629565 |
Prabowo |
F |
Dec. 28, 2020, 5:18 p.m. |
OK |
GNU C++11 |
TESTS |
28 |
78 |
7987200 |
|
|
102657940 |
fishcathu. |
F |
Dec. 29, 2020, 5:17 a.m. |
OK |
GNU C++11 |
TESTS |
28 |
78 |
9523200 |
|
|
102658205 |
fishcathu. |
F |
Dec. 29, 2020, 5:21 a.m. |
OK |
GNU C++11 |
TESTS |
28 |
93 |
9523200 |
|
|
102646441 |
CoDeHuNtEr |
F |
Dec. 28, 2020, 10:32 p.m. |
OK |
GNU C++11 |
TESTS |
28 |
124 |
11161600 |
|
|
102655913 |
Vixbob |
F |
Dec. 29, 2020, 4:36 a.m. |
OK |
GNU C++11 |
TESTS |
28 |
140 |
53145600 |
|
|
102643013 |
algodoer |
F |
Dec. 28, 2020, 8:47 p.m. |
OK |
GNU C++14 |
TESTS |
28 |
78 |
1638400 |
|
|
102636462 |
hectoreg |
F |
Dec. 28, 2020, 6:45 p.m. |
OK |
GNU C++14 |
TESTS |
28 |
93 |
2764800 |
|
|
102627410 |
wifiiii |
F |
Dec. 28, 2020, 4:59 p.m. |
OK |
GNU C++14 |
TESTS |
28 |
93 |
3993600 |
|
|
102632962 |
SuperJ6 |
F |
Dec. 28, 2020, 5:57 p.m. |
OK |
GNU C++14 |
TESTS |
28 |
93 |
16076800 |
|
|
102644275 |
_no0B |
F |
Dec. 28, 2020, 9:22 p.m. |
OK |
GNU C++14 |
TESTS |
28 |
124 |
10035200 |
|
|
102644318 |
_no0B |
F |
Dec. 28, 2020, 9:23 p.m. |
OK |
GNU C++14 |
TESTS |
28 |
140 |
10035200 |
|
|
102637901 |
purinliang |
F |
Dec. 28, 2020, 7:07 p.m. |
OK |
GNU C++14 |
TESTS |
28 |
264 |
26419200 |
|
|
102654297 |
oyqy1203 |
F |
Dec. 29, 2020, 3:52 a.m. |
OK |
GNU C++14 |
TESTS |
28 |
280 |
2457600 |
|
|
102640836 |
menna.hamdy431 |
F |
Dec. 28, 2020, 8 p.m. |
OK |
GNU C++14 |
TESTS |
28 |
280 |
5222400 |
|
|
102639572 |
hectoreg |
F |
Dec. 28, 2020, 7:36 p.m. |
OK |
GNU C++14 |
TESTS |
28 |
280 |
5222400 |
|
|
102631376 |
RUSH_D_CAT |
F |
Dec. 28, 2020, 5:39 p.m. |
OK |
GNU C++17 |
TESTS |
28 |
78 |
3174400 |
|
|
102640452 |
mardagio11 |
F |
Dec. 28, 2020, 7:52 p.m. |
OK |
GNU C++17 |
TESTS |
28 |
78 |
3174400 |
|
|
102642462 |
harsh639 |
F |
Dec. 28, 2020, 8:33 p.m. |
OK |
GNU C++17 |
TESTS |
28 |
93 |
2764800 |
|
|
102644092 |
couplefire |
F |
Dec. 28, 2020, 9:16 p.m. |
OK |
GNU C++17 |
TESTS |
28 |
109 |
2457600 |
|
|
102633455 |
Vitaha |
F |
Dec. 28, 2020, 6:03 p.m. |
OK |
GNU C++17 |
TESTS |
28 |
109 |
3993600 |
|
|
102653656 |
WA_King |
F |
Dec. 29, 2020, 3:32 a.m. |
OK |
GNU C++17 |
TESTS |
28 |
124 |
3993600 |
|
|
102632268 |
Vitaha |
F |
Dec. 28, 2020, 5:49 p.m. |
OK |
GNU C++17 |
TESTS |
28 |
124 |
3993600 |
|
|
102632210 |
Vitaha |
F |
Dec. 28, 2020, 5:49 p.m. |
OK |
GNU C++17 |
TESTS |
28 |
156 |
3993600 |
|
|
102634400 |
N.N_2004 |
F |
Dec. 28, 2020, 6:16 p.m. |
OK |
GNU C++17 |
TESTS |
28 |
187 |
6451200 |
|
|
102634343 |
MiSco_1 |
F |
Dec. 28, 2020, 6:15 p.m. |
OK |
GNU C++17 |
TESTS |
28 |
187 |
6451200 |
|
|
102644474 |
neal |
F |
Dec. 28, 2020, 9:27 p.m. |
OK |
GNU C++17 (64) |
TESTS |
28 |
61 |
1228800 |
|
|
102640557 |
june_waves |
F |
Dec. 28, 2020, 7:54 p.m. |
OK |
GNU C++17 (64) |
TESTS |
28 |
61 |
2867200 |
|
|
102627331 |
.__. |
F |
Dec. 28, 2020, 4:59 p.m. |
OK |
GNU C++17 (64) |
TESTS |
28 |
62 |
6144000 |
|
|
102653276 |
lucky_2020 |
F |
Dec. 29, 2020, 3:21 a.m. |
OK |
GNU C++17 (64) |
TESTS |
28 |
62 |
9625600 |
|
|
102627126 |
m_99 |
F |
Dec. 28, 2020, 4:57 p.m. |
OK |
GNU C++17 (64) |
TESTS |
28 |
77 |
3788800 |
|
|
102641440 |
june_waves |
F |
Dec. 28, 2020, 8:11 p.m. |
OK |
GNU C++17 (64) |
TESTS |
28 |
78 |
2764800 |
|
|
102632555 |
Marckess |
F |
Dec. 28, 2020, 5:53 p.m. |
OK |
GNU C++17 (64) |
TESTS |
28 |
92 |
6656000 |
|
|
102650632 |
LJC00118 |
F |
Dec. 29, 2020, 1:40 a.m. |
OK |
GNU C++17 (64) |
TESTS |
28 |
93 |
3174400 |
|
|
102650605 |
LJC00118 |
F |
Dec. 29, 2020, 1:38 a.m. |
OK |
GNU C++17 (64) |
TESTS |
28 |
108 |
3174400 |
|
|
102635163 |
CoderAnshu |
F |
Dec. 28, 2020, 6:27 p.m. |
OK |
GNU C++17 (64) |
TESTS |
28 |
108 |
7270400 |
|
|
102646047 |
Taran_1407 |
F |
Dec. 28, 2020, 10:17 p.m. |
OK |
Java 8 |
TESTS |
28 |
670 |
101580800 |
|
|
102634438 |
mban259 |
F |
Dec. 28, 2020, 6:17 p.m. |
OK |
.NET Core C# |
TESTS |
28 |
3073 |
36044800 |
|
|
102633781 |
sh1194 |
F |
Dec. 28, 2020, 6:08 p.m. |
OK |
PyPy 3 |
TESTS |
28 |
2136 |
24064000 |
|
|
102633473 |
sh1194 |
F |
Dec. 28, 2020, 6:04 p.m. |
OK |
PyPy 3 |
TESTS |
28 |
2136 |
24371200 |
|
|
102633533 |
sh1194 |
F |
Dec. 28, 2020, 6:04 p.m. |
OK |
PyPy 3 |
TESTS |
28 |
2137 |
24883200 |
|
|
102633888 |
sh1194 |
F |
Dec. 28, 2020, 6:09 p.m. |
OK |
PyPy 3 |
TESTS |
28 |
2152 |
23859200 |
|
|
102633699 |
sh1194 |
F |
Dec. 28, 2020, 6:07 p.m. |
OK |
PyPy 3 |
TESTS |
28 |
2152 |
23859200 |
|
|
102634040 |
sh1194 |
F |
Dec. 28, 2020, 6:12 p.m. |
OK |
PyPy 3 |
TESTS |
28 |
2199 |
23859200 |
|
|
102623318 |
SPD_9X2 |
F |
Dec. 28, 2020, 4:37 p.m. |
OK |
PyPy 3 |
TESTS |
28 |
2230 |
24268800 |
|
|
remove filters
Back to search problems