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'Bandits appeared in the city! One of them is trying to catch as many citizens as he can. The city consists of n squares connected by n-1 roads in such a way that it is possible to reach any square from any other square. The square number 1 is the main square. After Sunday walk all the roads were changed to one-way roads in such a way that it is possible to reach any square from the main square. At the moment when the bandit appeared on the main square there were a_i citizens on the i -th square. Now the following process will begin. First, each citizen that is currently on a square with some outgoing one-way roads chooses one of such roads and moves along it to another square. Then the bandit chooses one of the one-way roads outgoing from the square he is located and moves along it. The process is repeated until the bandit is located on a square with no outgoing roads. The bandit catches all the citizens on that square. The bandit wants to catch as many citizens as possible; the citizens want to minimize the number of caught people. The bandit and the citizens know positions of all citizens at any time, the citizens can cooperate. If both sides act optimally, how many citizens will be caught? The first line contains a single integer n -- the number of squares in the city ( 2 <= n <= 2 cdot10^5 ). The second line contains n-1 integers p_2, p_3 ... p_n meaning that there is a one-way road from the square p_i to the square i ( 1 <= p_i < i ). The third line contains n integers a_1, a_2, ... , a_n -- the number of citizens on each square initially ( 0 <= a_i <= 10^9 ). Print a single integer -- the number of citizens the bandit will catch if both sides act optimally. In the first example the citizens on the square 1 can split into two groups 2 + 1 , so that the second and on the third squares will have 3 citizens each. In the second example no mat'... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
96627349 |
cheese-cracker |
D |
Oct. 25, 2020, 5:28 a.m. |
OK |
D |
TESTS |
95 |
187 |
51609600 |
|
|
96747147 |
TYGZ |
D |
Oct. 26, 2020, 5:20 a.m. |
OK |
GNU C++11 |
TESTS |
95 |
46 |
3993600 |
|
|
96638680 |
Lu_Anlai |
D |
Oct. 25, 2020, 8:48 a.m. |
OK |
GNU C++11 |
TESTS |
95 |
46 |
8396800 |
|
|
96637672 |
Intro. |
D |
Oct. 25, 2020, 8:34 a.m. |
OK |
GNU C++11 |
TESTS |
95 |
46 |
14438400 |
|
|
96621027 |
CZJ_2005 |
D |
Oct. 25, 2020, 1:33 a.m. |
OK |
GNU C++11 |
TESTS |
95 |
46 |
20787200 |
|
|
96737967 |
tourifeng |
D |
Oct. 26, 2020, 1:02 a.m. |
OK |
GNU C++11 |
TESTS |
95 |
46 |
25600000 |
|
|
96746521 |
Rainbow_sjy |
D |
Oct. 26, 2020, 5:07 a.m. |
OK |
GNU C++11 |
TESTS |
95 |
46 |
30412800 |
|
|
96623114 |
Werner_Yin |
D |
Oct. 25, 2020, 2:53 a.m. |
OK |
GNU C++11 |
TESTS |
95 |
61 |
21606400 |
|
|
96619098 |
Young.EQ |
D |
Oct. 25, 2020, 12:07 a.m. |
OK |
GNU C++11 |
TESTS |
95 |
62 |
15769600 |
|
|
96740279 |
Miopha |
D |
Oct. 26, 2020, 2:18 a.m. |
OK |
GNU C++11 |
TESTS |
95 |
62 |
17510400 |
|
|
96645324 |
fishcathu. |
D |
Oct. 25, 2020, 10:22 a.m. |
OK |
GNU C++11 |
TESTS |
95 |
62 |
18227200 |
|
|
96637996 |
sayam.sethi2 |
D |
Oct. 25, 2020, 8:38 a.m. |
OK |
GNU C++14 |
TESTS |
95 |
93 |
30720000 |
|
|
96702005 |
loulingli |
D |
Oct. 25, 2020, 1:40 p.m. |
OK |
GNU C++14 |
TESTS |
95 |
124 |
7987200 |
|
|
96619862 |
youarethestupiddog |
D |
Oct. 25, 2020, 12:46 a.m. |
OK |
GNU C++14 |
TESTS |
95 |
124 |
20992000 |
|
|
96637804 |
codelord47 |
D |
Oct. 25, 2020, 8:36 a.m. |
OK |
GNU C++14 |
TESTS |
95 |
124 |
23347200 |
|
|
96647533 |
yjojdkgk5bp |
D |
Oct. 25, 2020, 10:52 a.m. |
OK |
GNU C++14 |
TESTS |
95 |
124 |
23347200 |
|
|
96639824 |
stark42 |
D |
Oct. 25, 2020, 9:03 a.m. |
OK |
GNU C++14 |
TESTS |
95 |
124 |
23347200 |
|
|
96619978 |
VTruongAn |
D |
Oct. 25, 2020, 12:51 a.m. |
OK |
GNU C++14 |
TESTS |
95 |
124 |
24166400 |
|
|
96643058 |
SRIKANTH |
D |
Oct. 25, 2020, 9:49 a.m. |
OK |
GNU C++14 |
TESTS |
95 |
124 |
28160000 |
|
|
96615264 |
Gorgo |
D |
Oct. 24, 2020, 9:40 p.m. |
OK |
GNU C++14 |
TESTS |
95 |
139 |
3174400 |
|
|
96635914 |
Lazy_lad |
D |
Oct. 25, 2020, 8:12 a.m. |
OK |
GNU C++14 |
TESTS |
95 |
139 |
21811200 |
|
|
96728686 |
DR.KOKS |
D |
Oct. 25, 2020, 8:04 p.m. |
OK |
GNU C++17 |
TESTS |
95 |
109 |
6758400 |
|
|
96609536 |
mihmih |
D |
Oct. 24, 2020, 7:38 p.m. |
OK |
GNU C++17 |
TESTS |
95 |
124 |
3174400 |
|
|
96619142 |
Thallium_is_Vegetable |
D |
Oct. 25, 2020, 12:09 a.m. |
OK |
GNU C++17 |
TESTS |
95 |
124 |
3174400 |
|
|
96618677 |
Kanoon |
D |
Oct. 24, 2020, 11:44 p.m. |
OK |
GNU C++17 |
TESTS |
95 |
124 |
3174400 |
|
|
96629565 |
rgnerdplayer |
D |
Oct. 25, 2020, 5:55 a.m. |
OK |
GNU C++17 |
TESTS |
95 |
124 |
3174400 |
|
|
96626016 |
palsoumyadeep |
D |
Oct. 25, 2020, 5:06 a.m. |
OK |
GNU C++17 |
TESTS |
95 |
124 |
3993600 |
|
|
96632493 |
TLEonTestCase04 |
D |
Oct. 25, 2020, 7:18 a.m. |
OK |
GNU C++17 |
TESTS |
95 |
124 |
3993600 |
|
|
96638527 |
hua_shuo |
D |
Oct. 25, 2020, 8:45 a.m. |
OK |
GNU C++17 |
TESTS |
95 |
124 |
4812800 |
|
|
96631837 |
chefpr7 |
D |
Oct. 25, 2020, 7:02 a.m. |
OK |
GNU C++17 |
TESTS |
95 |
124 |
4812800 |
|
|
96637501 |
codesniper99 |
D |
Oct. 25, 2020, 8:32 a.m. |
OK |
GNU C++17 |
TESTS |
95 |
124 |
4812800 |
|
|
96609754 |
harsh_arora |
D |
Oct. 24, 2020, 7:42 p.m. |
OK |
GNU C++17 (64) |
TESTS |
95 |
77 |
3174400 |
|
|
96643110 |
dum4ss |
D |
Oct. 25, 2020, 9:49 a.m. |
OK |
GNU C++17 (64) |
TESTS |
95 |
77 |
4812800 |
|
|
96599252 |
Harshlyn94 |
D |
Oct. 24, 2020, 5:57 p.m. |
OK |
GNU C++17 (64) |
TESTS |
94 |
78 |
3174400 |
|
|
96619429 |
Kanoon |
D |
Oct. 25, 2020, 12:24 a.m. |
OK |
GNU C++17 (64) |
TESTS |
95 |
108 |
32870400 |
|
|
96606287 |
neal |
D |
Oct. 24, 2020, 6:49 p.m. |
OK |
GNU C++17 (64) |
TESTS |
95 |
109 |
12902400 |
|
|
96598577 |
Eureka17 |
D |
Oct. 24, 2020, 5:52 p.m. |
OK |
GNU C++17 (64) |
TESTS |
94 |
109 |
13004800 |
|
|
96616597 |
inbornhandsome |
D |
Oct. 24, 2020, 10:26 p.m. |
OK |
GNU C++17 (64) |
TESTS |
95 |
109 |
14540800 |
|
|
96715013 |
Svanh |
D |
Oct. 25, 2020, 4:12 p.m. |
OK |
GNU C++17 (64) |
TESTS |
95 |
109 |
32051200 |
|
|
96621460 |
MateoCV |
D |
Oct. 25, 2020, 1:47 a.m. |
OK |
GNU C++17 (64) |
TESTS |
95 |
124 |
28876800 |
|
|
96636950 |
Lola0213 |
D |
Oct. 25, 2020, 8:26 a.m. |
OK |
GNU C++17 (64) |
TESTS |
95 |
124 |
30515200 |
|
|
96611245 |
RuthlessAggression |
D |
Oct. 24, 2020, 8:09 p.m. |
OK |
Java 11 |
TESTS |
95 |
389 |
67481600 |
|
|
96632757 |
soumit915 |
D |
Oct. 25, 2020, 7:23 a.m. |
OK |
Java 11 |
TESTS |
95 |
421 |
40140800 |
|
|
96596798 |
yuruiyin |
D |
Oct. 24, 2020, 5:44 p.m. |
OK |
Java 11 |
TESTS |
94 |
436 |
69939200 |
|
|
96646425 |
KoustavBeginner |
D |
Oct. 25, 2020, 10:38 a.m. |
OK |
Java 11 |
TESTS |
95 |
451 |
57446400 |
|
|
96599010 |
bobib |
D |
Oct. 24, 2020, 5:55 p.m. |
OK |
Java 11 |
TESTS |
94 |
451 |
64204800 |
|
|
96712119 |
anshum_it_is |
D |
Oct. 25, 2020, 3:33 p.m. |
OK |
Java 11 |
TESTS |
95 |
514 |
69222400 |
|
|
96598640 |
Agnimandur |
D |
Oct. 24, 2020, 5:53 p.m. |
OK |
Java 11 |
TESTS |
94 |
529 |
48435200 |
|
|
96608474 |
b0bl0blaw |
D |
Oct. 24, 2020, 7:21 p.m. |
OK |
Java 11 |
TESTS |
95 |
545 |
64000000 |
|
|
96604890 |
b0bl0blaw |
D |
Oct. 24, 2020, 6:33 p.m. |
OK |
Java 11 |
TESTS |
95 |
764 |
232448000 |
|
|
96629665 |
abcde12345 |
D |
Oct. 25, 2020, 5:59 a.m. |
OK |
Java 11 |
TESTS |
95 |
826 |
255078400 |
|
|
96609791 |
Whiplash99 |
D |
Oct. 24, 2020, 7:43 p.m. |
OK |
Java 8 |
TESTS |
95 |
233 |
27136000 |
|
|
96684308 |
Slamur |
D |
Oct. 25, 2020, 12:24 p.m. |
OK |
Java 8 |
TESTS |
95 |
311 |
37580800 |
|
|
96617645 |
ShesMyNerd |
D |
Oct. 24, 2020, 11:03 p.m. |
OK |
Java 8 |
TESTS |
95 |
311 |
61849600 |
|
|
96622790 |
MohamedK |
D |
Oct. 25, 2020, 2:40 a.m. |
OK |
Java 8 |
TESTS |
95 |
373 |
61337600 |
|
|
96606811 |
subhamdtu |
D |
Oct. 24, 2020, 6:56 p.m. |
OK |
Java 8 |
TESTS |
95 |
389 |
63488000 |
|
|
96622478 |
lzhang |
D |
Oct. 25, 2020, 2:26 a.m. |
OK |
Java 8 |
TESTS |
95 |
389 |
112844800 |
|
|
96735072 |
polyakoff |
D |
Oct. 25, 2020, 10:51 p.m. |
OK |
Java 8 |
TESTS |
95 |
405 |
78233600 |
|
|
96606718 |
subhamdtu |
D |
Oct. 24, 2020, 6:55 p.m. |
OK |
Java 8 |
TESTS |
95 |
420 |
65843200 |
|
|
96597266 |
the_final_problem |
D |
Oct. 24, 2020, 5:47 p.m. |
OK |
Java 8 |
TESTS |
94 |
421 |
80179200 |
|
|
96606604 |
subhamdtu |
D |
Oct. 24, 2020, 6:53 p.m. |
OK |
Java 8 |
TESTS |
95 |
436 |
65843200 |
|
|
96745387 |
Ivan11 |
D |
Oct. 26, 2020, 4:42 a.m. |
OK |
MS C++ 2017 |
TESTS |
95 |
374 |
18432000 |
|
|
96629299 |
SherKGoder |
D |
Oct. 25, 2020, 5:46 a.m. |
OK |
MS C++ 2017 |
TESTS |
95 |
389 |
24780800 |
|
|
96622626 |
17658592801 |
D |
Oct. 25, 2020, 2:33 a.m. |
OK |
MS C++ 2017 |
TESTS |
95 |
421 |
20787200 |
|
|
96624998 |
Yupiteru |
D |
Oct. 25, 2020, 4:22 a.m. |
OK |
.NET Core C# |
TESTS |
95 |
248 |
44748800 |
|
|
96607186 |
azukun |
D |
Oct. 24, 2020, 7:01 p.m. |
OK |
.NET Core C# |
TESTS |
95 |
280 |
74137600 |
|
|
96620302 |
sanjeevkumar113f |
D |
Oct. 25, 2020, 1:06 a.m. |
OK |
PyPy 3 |
TESTS |
95 |
280 |
26521600 |
|
|
96596758 |
htkb |
D |
Oct. 24, 2020, 5:44 p.m. |
OK |
PyPy 3 |
TESTS |
94 |
358 |
23859200 |
|
|
96740958 |
Soren_15 |
D |
Oct. 26, 2020, 2:38 a.m. |
OK |
PyPy 3 |
TESTS |
95 |
483 |
22425600 |
|
|
96619494 |
uttharapally.chandra |
D |
Oct. 25, 2020, 12:27 a.m. |
OK |
PyPy 3 |
TESTS |
95 |
483 |
27852800 |
|
|
96621975 |
wwwCielllwww |
D |
Oct. 25, 2020, 2:04 a.m. |
OK |
PyPy 3 |
TESTS |
95 |
499 |
22425600 |
|
|
96596894 |
main_single_hu |
D |
Oct. 24, 2020, 5:45 p.m. |
OK |
PyPy 3 |
TESTS |
94 |
514 |
28057600 |
|
|
96607309 |
marcus.test |
D |
Oct. 24, 2020, 7:03 p.m. |
OK |
PyPy 3 |
TESTS |
95 |
545 |
24268800 |
|
|
96608486 |
marcus.test |
D |
Oct. 24, 2020, 7:21 p.m. |
OK |
PyPy 3 |
TESTS |
95 |
545 |
24985600 |
|
|
96634284 |
donuthole |
D |
Oct. 25, 2020, 7:45 a.m. |
OK |
PyPy 3 |
TESTS |
95 |
545 |
30105600 |
|
|
96647697 |
anshujha123 |
D |
Oct. 25, 2020, 10:54 a.m. |
OK |
PyPy 3 |
TESTS |
95 |
561 |
206540800 |
|
|
96596768 |
nwi |
D |
Oct. 24, 2020, 5:44 p.m. |
OK |
Python 2 |
TESTS |
94 |
436 |
14950400 |
|
|
96625776 |
srijan.sarkar |
D |
Oct. 25, 2020, 4:56 a.m. |
OK |
Python 3 |
TESTS |
95 |
592 |
20992000 |
|
|
96608781 |
sh1194 |
D |
Oct. 24, 2020, 7:26 p.m. |
OK |
Python 3 |
TESTS |
95 |
919 |
233062400 |
|
|
96619189 |
maximpetrov |
D |
Oct. 25, 2020, 12:12 a.m. |
OK |
Python 3 |
TESTS |
95 |
951 |
56012800 |
|
|
96619469 |
bqn |
D |
Oct. 25, 2020, 12:26 a.m. |
OK |
Rust |
TESTS |
95 |
93 |
31641600 |
|
|
96606265 |
tuna_salad |
D |
Oct. 24, 2020, 6:49 p.m. |
OK |
Rust |
TESTS |
95 |
155 |
25600000 |
|
|
96707895 |
crazyboycjr0.1 |
D |
Oct. 25, 2020, 2:40 p.m. |
OK |
Rust |
TESTS |
95 |
171 |
39219200 |
|
|
remove filters
Back to search problems