cf/mirror

Acyclic Organic Compounds

CF
601D2400· grandmaster3s512 MB⌨ stdin/stdout

Examples

Sample 1of 2
Input
10
1 2 7 20 20 30 40 50 50 50
cacabbcddd
1 2
6 8
7 2
6 2
5 4
5 9
3 10
2 5
2 3
Output
51
3
Sample 2of 2
Input
6
0 2 4 1 1 1
raaaba
1 2
2 3
2 4
2 5
3 6
Output
6
2
601D.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)
loading graph engine…