A. BaldTree
time limit per test
2 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
9 6
1 1 1 3 2 4 4 7
1 1 1 4 2 3 5 8
Output
18