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"There are n cities in the country of Berland. Some of them are connected by bidirectional roads in such a way that there exists exactly one path, which visits each road no more than once, between every pair of cities. Each road has its own length. Cities are numbered from 1 to n . The travelling time between some cities v and u is the total length of the roads on the shortest path from v to u . The two most important cities in Berland are cities 1 and n . The Berland Ministry of Transport decided to build a single new road to decrease the traffic between the most important cities. However, lots of people are used to the current travelling time between the most important cities, so the new road shouldn't change it too much. The new road can only be built between such cities v and u that v neq u and v and u aren't already connected by some road. They came up with m possible projects. Each project is just the length x of the new road. Polycarp works as a head analyst at the Berland Ministry of Transport and it's his job to deal with all those m projects. For the i -th project he is required to choose some cities v and u to build the new road of length x_i between such that the travelling time between the most important cities is maximal possible. Unfortunately, Polycarp is not a programmer and no analyst in the world is capable to process all projects using only pen and paper. Thus, he asks you to help him to calculate the maximal possible travelling time between the most important cities for each project. Note that the choice of v and u can differ for different projects. The first line contains two integers n and m ( 3 <= n <= 3 cdot 10^5 , 1 <= m <= 3 cdot 10^5 ) -- the number of cities and the number of projects, respectively. Each of the next n - 1 lines contains three integers v_i$"... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
41910997 |
__ShaW |
F |
Aug. 20, 2018, 5:48 p.m. |
OK |
FPC |
TESTS |
49 |
1388 |
68403200 |
|
2600 |
41200079 |
zhtzht |
F |
Aug. 4, 2018, 4:33 a.m. |
OK |
GNU C++ |
TESTS |
48 |
280 |
29081600 |
|
2600 |
41241893 |
zhouzhendong |
F |
Aug. 5, 2018, 10:52 a.m. |
OK |
GNU C++ |
TESTS |
48 |
296 |
27648000 |
|
2600 |
41186549 |
zhouzhendongYa |
F |
Aug. 3, 2018, 5:01 p.m. |
OK |
GNU C++ |
TESTS |
48 |
296 |
27648000 |
|
2600 |
41204325 |
luogu_bot2 |
F |
Aug. 4, 2018, 7:04 a.m. |
OK |
GNU C++ |
TESTS |
48 |
296 |
30003200 |
|
2600 |
41238636 |
luogu_bot2 |
F |
Aug. 5, 2018, 8:47 a.m. |
OK |
GNU C++ |
TESTS |
48 |
311 |
36352000 |
|
2600 |
41333035 |
luogu_bot3 |
F |
Aug. 8, 2018, 9:59 a.m. |
OK |
GNU C++ |
TESTS |
49 |
312 |
36659200 |
|
2600 |
41238532 |
yybyyb |
F |
Aug. 5, 2018, 8:43 a.m. |
OK |
GNU C++ |
TESTS |
48 |
327 |
36352000 |
|
2600 |
41449028 |
Stump |
F |
Aug. 11, 2018, 2:33 a.m. |
OK |
GNU C++ |
TESTS |
49 |
327 |
47616000 |
|
2600 |
41293173 |
zhangqingqi |
F |
Aug. 7, 2018, 5:16 a.m. |
OK |
GNU C++ |
TESTS |
49 |
389 |
34816000 |
|
2600 |
41558027 |
guoruihan |
F |
Aug. 13, 2018, 12:33 p.m. |
OK |
GNU C++ |
TESTS |
49 |
421 |
71475200 |
|
2600 |
52522599 |
Scut82 |
F |
April 9, 2019, 9:39 a.m. |
OK |
GNU C++11 |
TESTS |
49 |
218 |
26419200 |
|
2600 |
41295872 |
qeatzy |
F |
Aug. 7, 2018, 7:09 a.m. |
OK |
GNU C++11 |
TESTS |
49 |
234 |
41164800 |
|
2600 |
41295477 |
qeatzy |
F |
Aug. 7, 2018, 6:55 a.m. |
OK |
GNU C++11 |
TESTS |
49 |
234 |
41164800 |
|
2600 |
42721562 |
ReaLNero1 |
F |
Sept. 10, 2018, 2:10 a.m. |
OK |
GNU C++11 |
TESTS |
49 |
249 |
41164800 |
|
2600 |
41295600 |
qeatzy |
F |
Aug. 7, 2018, 7:01 a.m. |
OK |
GNU C++11 |
TESTS |
49 |
249 |
41164800 |
|
2600 |
69391394 |
Sneakoscope |
F |
Jan. 23, 2020, 3:55 a.m. |
OK |
GNU C++11 |
TESTS |
49 |
264 |
27955200 |
|
2600 |
41179103 |
aspi |
F |
Aug. 3, 2018, 4:08 p.m. |
OK |
GNU C++11 |
TESTS |
48 |
265 |
22937600 |
|
2600 |
41295680 |
qeatzy |
F |
Aug. 7, 2018, 7:05 a.m. |
OK |
GNU C++11 |
TESTS |
49 |
265 |
41164800 |
|
2600 |
64353913 |
lx_zjk |
F |
Nov. 6, 2019, 9:27 a.m. |
OK |
GNU C++11 |
TESTS |
49 |
280 |
32051200 |
|
2600 |
41277408 |
qeatzy |
F |
Aug. 6, 2018, 1:58 p.m. |
OK |
GNU C++11 |
TESTS |
49 |
280 |
32460800 |
|
2600 |
41191173 |
wleung_bvg |
F |
Aug. 3, 2018, 7:20 p.m. |
OK |
GNU C++14 |
TESTS |
48 |
342 |
41472000 |
|
2600 |
41209336 |
waynetuinfor |
F |
Aug. 4, 2018, 9:38 a.m. |
OK |
GNU C++14 |
TESTS |
48 |
405 |
33792000 |
|
2600 |
67958303 |
problem-solved |
F |
Dec. 30, 2019, 10:33 a.m. |
OK |
GNU C++14 |
TESTS |
49 |
514 |
43827200 |
|
2600 |
41331641 |
wcy1122 |
F |
Aug. 8, 2018, 9:06 a.m. |
OK |
GNU C++14 |
TESTS |
49 |
530 |
21913600 |
|
2600 |
42796130 |
zhoujundong |
F |
Sept. 12, 2018, 11:48 a.m. |
OK |
GNU C++14 |
TESTS |
49 |
545 |
38707200 |
|
2600 |
53810827 |
NotNight |
F |
May 6, 2019, 6:34 a.m. |
OK |
GNU C++14 |
TESTS |
49 |
545 |
50995200 |
|
2600 |
48441772 |
DeletedAccount90083864 |
F |
Jan. 16, 2019, 4:17 a.m. |
OK |
GNU C++14 |
TESTS |
49 |
546 |
45465600 |
|
2600 |
46487899 |
endereye |
F |
Dec. 2, 2018, 9:44 a.m. |
OK |
GNU C++14 |
TESTS |
49 |
561 |
42291200 |
|
2600 |
67760671 |
stefdasca |
F |
Dec. 27, 2019, 10:01 p.m. |
OK |
GNU C++14 |
TESTS |
49 |
576 |
23347200 |
|
2600 |
41211285 |
Shayan.P |
F |
Aug. 4, 2018, 10:48 a.m. |
OK |
GNU C++14 |
TESTS |
48 |
576 |
45772800 |
|
2600 |
61838497 |
hjk1030 |
F |
Oct. 4, 2019, 8:49 a.m. |
OK |
GNU C++17 |
TESTS |
49 |
560 |
43724800 |
|
2600 |
42111100 |
Sdywolf |
F |
Aug. 26, 2018, 6:06 a.m. |
OK |
GNU C++17 |
TESTS |
49 |
561 |
32665600 |
|
2600 |
49550951 |
happy_ |
F |
Feb. 7, 2019, 5:54 a.m. |
OK |
GNU C++17 |
TESTS |
49 |
561 |
44953600 |
|
2600 |
41245791 |
tkj |
F |
Aug. 5, 2018, 1:02 p.m. |
OK |
GNU C++17 |
TESTS |
49 |
561 |
125030400 |
|
2600 |
42786854 |
shenyunhan |
F |
Sept. 12, 2018, 5:09 a.m. |
OK |
GNU C++17 |
TESTS |
49 |
577 |
32665600 |
|
2600 |
42291447 |
ivan100sic |
F |
Aug. 30, 2018, 9:10 p.m. |
OK |
GNU C++17 |
TESTS |
49 |
577 |
38604800 |
|
2600 |
41266345 |
TianyiChen |
F |
Aug. 6, 2018, 7:24 a.m. |
OK |
GNU C++17 |
TESTS |
49 |
577 |
41472000 |
|
2600 |
64435089 |
pootis |
F |
Nov. 7, 2019, 12:40 a.m. |
OK |
GNU C++17 |
TESTS |
49 |
592 |
33382400 |
|
2600 |
41189364 |
Benq |
F |
Aug. 3, 2018, 6:12 p.m. |
OK |
GNU C++17 |
TESTS |
48 |
592 |
43827200 |
|
2600 |
41213783 |
EtCetera |
F |
Aug. 4, 2018, noon |
OK |
GNU C++17 |
TESTS |
48 |
607 |
28979200 |
|
2600 |
41194792 |
mathmaniac |
F |
Aug. 3, 2018, 11:06 p.m. |
OK |
Java 8 |
TESTS |
48 |
1122 |
147046400 |
|
2600 |
41210497 |
vadimmm |
F |
Aug. 4, 2018, 10:18 a.m. |
OK |
Java 8 |
TESTS |
48 |
1216 |
180940800 |
|
2600 |
41191240 |
uwi |
F |
Aug. 3, 2018, 7:23 p.m. |
OK |
Java 8 |
TESTS |
48 |
1263 |
58368000 |
|
2600 |
41188747 |
SecondThread |
F |
Aug. 3, 2018, 5:52 p.m. |
OK |
Java 8 |
TESTS |
48 |
1621 |
70246400 |
|
2600 |
41393974 |
dalt |
F |
Aug. 9, 2018, 9:54 a.m. |
OK |
Java 8 |
TESTS |
49 |
1824 |
133017600 |
|
2600 |
41386480 |
dalt |
F |
Aug. 9, 2018, 6:13 a.m. |
OK |
Java 8 |
TESTS |
49 |
1856 |
133017600 |
|
2600 |
41210115 |
vadimmm |
F |
Aug. 4, 2018, 10:04 a.m. |
OK |
Java 8 |
TESTS |
48 |
1918 |
233984000 |
|
2600 |
41229117 |
wuli_zhaojing_ya |
F |
Aug. 5, 2018, 12:34 a.m. |
OK |
MS C++ |
TESTS |
48 |
545 |
50483200 |
|
2600 |
41210317 |
wuli_zhaojing_ya |
F |
Aug. 4, 2018, 10:11 a.m. |
OK |
MS C++ |
TESTS |
48 |
639 |
50483200 |
|
2600 |
41200601 |
wuli_zhaojing_ya |
F |
Aug. 4, 2018, 4:54 a.m. |
OK |
MS C++ |
TESTS |
48 |
1840 |
65638400 |
|
2600 |
41210021 |
wuli_zhaojing_ya |
F |
Aug. 4, 2018, 10:01 a.m. |
OK |
MS C++ |
TESTS |
48 |
1856 |
61337600 |
|
2600 |
41210052 |
wuli_zhaojing_ya |
F |
Aug. 4, 2018, 10:02 a.m. |
OK |
MS C++ |
TESTS |
48 |
1965 |
61337600 |
|
2600 |
41206437 |
kobae964 |
F |
Aug. 4, 2018, 8:05 a.m. |
OK |
Rust |
TESTS |
48 |
1075 |
149299200 |
|
2600 |
remove filters
Back to search problems