cf/mirror

Prince's Problem

CF
986E2800· international gm3s512 MB⌨ stdin/stdout

Examples

Sample 1of 2
Input
4
1 2
1 3
1 4
6 4 9 5
3
2 3 6
2 3 2
3 4 7
Output
36
4
1
Sample 2of 2
Input
6
1 2
2 3
2 4
1 5
5 6
100000 200000 500000 40000 800000 250000
3
3 5 10000000
6 2 3500000
4 1 64000
Output
196000
12250
999998215
986E.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)
loading graph engine…