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"You are given a tree T consisting of n vertices. A number is written on each vertex; the number written on vertex i is ai. Let's denote the function I(x, xe2 x80 x89y) as the difference between maximum and minimum value of ai on a simple path connecting vertices x and y. Your task is to calculate . The first line contains one integer number n (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89106) -- the number of vertices in the tree. The second line contains n integer numbers a1, a2, ..., an (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89ai xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89106) -- the numbers written on the vertices. Then n xe2 x80 x89- xe2 x80 x891 lines follow. Each line contains two integers x and y denoting an edge connecting vertex x and vertex y (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89x, xe2 x80 x89y xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n, x xe2 x80 x89 xe2 x89 xa0 xe2 x80 x89y). It is guaranteed that these edges denote a tree. Print one number equal to . "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
34344149 |
xht13127 |
F |
Jan. 20, 2018, 8:11 a.m. |
OK |
GNU C++ |
TESTS |
76 |
530 |
60211200 |
|
2500 |
40978514 |
ReaLNero1 |
F |
July 30, 2018, 4:40 p.m. |
OK |
GNU C++ |
TESTS |
76 |
592 |
58163200 |
|
2500 |
34238439 |
lyx_cjz |
F |
Jan. 17, 2018, 2:38 a.m. |
OK |
GNU C++ |
TESTS |
76 |
764 |
22528000 |
|
2500 |
34466834 |
yhx-12243 |
F |
Jan. 23, 2018, 3:48 a.m. |
OK |
GNU C++ |
TESTS |
76 |
810 |
26726400 |
|
2500 |
37104258 |
luogu_bot4 |
F |
April 8, 2018, 4:12 p.m. |
OK |
GNU C++ |
TESTS |
76 |
904 |
28160000 |
|
2500 |
34302816 |
llaa |
F |
Jan. 19, 2018, 12:54 p.m. |
OK |
GNU C++ |
TESTS |
76 |
904 |
38195200 |
|
2500 |
34601196 |
Will-I-Am |
F |
Jan. 27, 2018, 9:44 a.m. |
OK |
GNU C++ |
TESTS |
76 |
935 |
31744000 |
|
2500 |
35554433 |
Polygon-yg |
F |
Feb. 21, 2018, 4:47 p.m. |
OK |
GNU C++ |
TESTS |
76 |
1013 |
59187200 |
|
2500 |
38401717 |
luogu_bot3 |
F |
May 18, 2018, 12:47 p.m. |
OK |
GNU C++ |
TESTS |
76 |
1060 |
32665600 |
|
2500 |
35775820 |
a2357 |
F |
Feb. 27, 2018, 9:55 p.m. |
OK |
GNU C++ |
TESTS |
76 |
1075 |
30924800 |
|
2500 |
68084688 |
rainboy |
F |
Jan. 2, 2020, 3:45 p.m. |
OK |
GNU C11 |
TESTS |
76 |
1045 |
20070400 |
|
2500 |
62769899 |
PresHerobrine |
F |
Oct. 17, 2019, 9:54 a.m. |
OK |
GNU C++11 |
TESTS |
76 |
514 |
24064000 |
|
2500 |
62769792 |
PresHerobrine |
F |
Oct. 17, 2019, 9:52 a.m. |
OK |
GNU C++11 |
TESTS |
76 |
530 |
24064000 |
|
2500 |
34172456 |
xolm |
F |
Jan. 14, 2018, 10:42 a.m. |
OK |
GNU C++11 |
TESTS |
76 |
576 |
45056000 |
|
2500 |
34320819 |
_nameless_ |
F |
Jan. 19, 2018, 3:47 p.m. |
OK |
GNU C++11 |
TESTS |
76 |
639 |
27238400 |
|
2500 |
34172388 |
cuizhuyefei |
F |
Jan. 14, 2018, 10:38 a.m. |
OK |
GNU C++11 |
TESTS |
76 |
701 |
52428800 |
|
2500 |
59819726 |
chuducanhchy |
F |
Aug. 31, 2019, 4:50 p.m. |
OK |
GNU C++11 |
TESTS |
76 |
763 |
28774400 |
|
2500 |
34291261 |
Kuroni |
F |
Jan. 19, 2018, 4:05 a.m. |
OK |
GNU C++11 |
TESTS |
76 |
779 |
34099200 |
|
2500 |
64690128 |
zclong |
F |
Nov. 11, 2019, 12:55 p.m. |
OK |
GNU C++11 |
TESTS |
76 |
779 |
57036800 |
|
2500 |
64908313 |
chensy |
F |
Nov. 15, 2019, 12:41 a.m. |
OK |
GNU C++11 |
TESTS |
76 |
795 |
24473600 |
|
2500 |
34303181 |
SandTea |
F |
Jan. 19, 2018, 1:06 p.m. |
OK |
GNU C++11 |
TESTS |
76 |
795 |
32972800 |
|
2500 |
34201323 |
_AjReme_ |
F |
Jan. 15, 2018, 3:58 p.m. |
OK |
GNU C++14 |
TESTS |
76 |
748 |
30822400 |
|
2500 |
39812563 |
AsahiKasugano |
F |
July 1, 2018, 5:26 a.m. |
OK |
GNU C++14 |
TESTS |
76 |
904 |
20070400 |
|
2500 |
39812636 |
AsahiKasugano |
F |
July 1, 2018, 5:33 a.m. |
OK |
GNU C++14 |
TESTS |
76 |
966 |
29900800 |
|
2500 |
34246198 |
bibibibi |
F |
Jan. 17, 2018, 9:49 a.m. |
OK |
GNU C++14 |
TESTS |
76 |
982 |
49049600 |
|
2500 |
39738620 |
AsahiKasugano |
F |
June 28, 2018, 9:42 a.m. |
OK |
GNU C++14 |
TESTS |
76 |
1028 |
28057600 |
|
2500 |
34198449 |
Marco_L_T |
F |
Jan. 15, 2018, 1:47 p.m. |
OK |
GNU C++14 |
TESTS |
76 |
1044 |
46387200 |
|
2500 |
34166489 |
Marco_L_T |
F |
Jan. 14, 2018, 4:34 a.m. |
OK |
GNU C++14 |
TESTS |
76 |
1060 |
46387200 |
|
2500 |
34421659 |
Kalam |
F |
Jan. 21, 2018, 5:53 p.m. |
OK |
GNU C++14 |
TESTS |
76 |
1076 |
41881600 |
|
2500 |
34219151 |
wzz-huchi |
F |
Jan. 16, 2018, 10:51 a.m. |
OK |
GNU C++14 |
TESTS |
76 |
1122 |
30924800 |
|
2500 |
39736429 |
AsahiKasugano |
F |
June 28, 2018, 8:08 a.m. |
OK |
GNU C++14 |
TESTS |
76 |
1123 |
28057600 |
|
2500 |
63041053 |
vjudge4 |
F |
Oct. 21, 2019, 12:47 a.m. |
OK |
GNU C++17 |
TESTS |
76 |
1060 |
36966400 |
|
2500 |
46247074 |
YJH143 |
F |
Nov. 26, 2018, 12:01 p.m. |
OK |
GNU C++17 |
TESTS |
76 |
1200 |
32972800 |
|
2500 |
43526350 |
NiceBaseballCoder |
F |
Sept. 28, 2018, 11:30 a.m. |
OK |
GNU C++17 |
TESTS |
76 |
1231 |
28569600 |
|
2500 |
40090440 |
DomiKo |
F |
July 8, 2018, 4:30 p.m. |
OK |
GNU C++17 |
TESTS |
76 |
1263 |
28876800 |
|
2500 |
49412795 |
ivan100sic |
F |
Feb. 3, 2019, 3:59 p.m. |
OK |
GNU C++17 |
TESTS |
76 |
1279 |
53043200 |
|
2500 |
53732140 |
amnesiac_dusk |
F |
May 4, 2019, 7:44 a.m. |
OK |
GNU C++17 |
TESTS |
76 |
1310 |
79564800 |
|
2500 |
57426575 |
Grapeee |
F |
July 20, 2019, 8:46 p.m. |
OK |
GNU C++17 |
TESTS |
76 |
1357 |
48742400 |
|
2500 |
46944287 |
Vahm |
F |
Dec. 12, 2018, 6:44 p.m. |
OK |
GNU C++17 |
TESTS |
76 |
1372 |
87552000 |
|
2500 |
66365140 |
alireza_kaviani |
F |
Dec. 5, 2019, 7:06 p.m. |
OK |
GNU C++17 |
TESTS |
76 |
1450 |
79155200 |
|
2500 |
51594556 |
nahid08 |
F |
March 20, 2019, 8:47 p.m. |
OK |
GNU C++17 |
TESTS |
76 |
1450 |
87552000 |
|
2500 |
68084758 |
Dukkha |
F |
Jan. 2, 2020, 3:47 p.m. |
OK |
Java 11 |
TESTS |
76 |
1794 |
37990400 |
|
2500 |
34450147 |
Moor |
F |
Jan. 22, 2018, 2:17 p.m. |
OK |
Java 8 |
TESTS |
76 |
2012 |
115507200 |
|
2500 |
34219922 |
hulk_man |
F |
Jan. 16, 2018, 11:29 a.m. |
OK |
Java 8 |
TESTS |
76 |
2027 |
80179200 |
|
2500 |
53029498 |
icpc_loser |
F |
April 19, 2019, 9:52 p.m. |
OK |
Java 8 |
TESTS |
76 |
2245 |
111206400 |
|
2500 |
34198462 |
Sagar_Savaliya |
F |
Jan. 15, 2018, 1:47 p.m. |
OK |
Java 8 |
TESTS |
76 |
2589 |
172748800 |
|
2500 |
34427742 |
svilen |
F |
Jan. 22, 2018, 12:34 a.m. |
OK |
Java 8 |
TESTS |
76 |
2682 |
160768000 |
|
2500 |
35598368 |
dalt |
F |
Feb. 23, 2018, 1:48 p.m. |
OK |
Java 8 |
TESTS |
76 |
2823 |
268390400 |
|
2500 |
34204486 |
mathmaniac |
F |
Jan. 15, 2018, 6:24 p.m. |
OK |
Java 8 |
TESTS |
76 |
3197 |
244736000 |
|
2500 |
54891359 |
caoash |
F |
May 31, 2019, 8:41 p.m. |
OK |
Java 8 |
TESTS |
76 |
3478 |
258867200 |
|
2500 |
54891322 |
BencilSharpeniro |
F |
May 31, 2019, 8:39 p.m. |
OK |
Java 8 |
TESTS |
76 |
3478 |
258867200 |
|
2500 |
34253103 |
parth_15 |
F |
Jan. 17, 2018, 1:37 p.m. |
OK |
Java 8 |
TESTS |
76 |
3603 |
268390400 |
|
2500 |
34961826 |
og.kostya |
F |
Feb. 6, 2018, 5:51 a.m. |
OK |
MS C# |
TESTS |
76 |
1637 |
98816000 |
|
2500 |
53749219 |
vjudge4 |
F |
May 4, 2019, 5:19 p.m. |
OK |
MS C++ |
TESTS |
76 |
1123 |
41164800 |
|
2500 |
34221955 |
Kakashi_Hatake |
F |
Jan. 16, 2018, 12:47 p.m. |
OK |
MS C++ |
TESTS |
76 |
3010 |
56627200 |
|
2500 |
35138598 |
RCG |
F |
Feb. 10, 2018, 10:13 p.m. |
OK |
MS C++ |
TESTS |
76 |
3057 |
104652800 |
|
2500 |
53675378 |
ialakhtin |
F |
May 2, 2019, 3:30 p.m. |
OK |
MS C++ 2017 |
TESTS |
76 |
3915 |
65536000 |
|
2500 |
remove filters
Back to search problems