TopCoder

Caido
主唱太拼命了

User's AC Ratio

77.8% (7/9)

Submission's AC Ratio

52.0% (13/25)

Tags

Description

Input Format

Output Format

Sample Input 1

5 10
1 1 1 1 1
1 2
2 3
3 4
4 5

Sample Output 1

3

Sample Input 2

7 20
8 2 1 7 1 10 2
3 7
7 6
6 1
3 5
1 2
1 4

Sample Output 2

21

Sample Input 3

2 100
1 1
1 2

Sample Output 3

-1

Hints

Problem Source

YTP 2024 高中組初賽 p6

Subtasks

No. Testdata Range Constraints Score
1 0~2 範例測資 0
2 0~12 $1 \leq N, K \leq 200$ 4
3 13~18 給定的樹是一條鍊 4
4 0~27 無額外限制 12

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 6000 1048576 65536 1 2 4
1 6000 1048576 65536 1 2 4
2 6000 1048576 65536 1 2 4
3 6000 1048576 65536 2 4
4 6000 1048576 65536 2 4
5 6000 1048576 65536 2 4
6 6000 1048576 65536 2 4
7 6000 1048576 65536 2 4
8 6000 1048576 65536 2 4
9 6000 1048576 65536 2 4
10 6000 1048576 65536 2 4
11 6000 1048576 65536 2 4
12 6000 1048576 65536 2 4
13 6000 1048576 65536 3 4
14 6000 1048576 65536 3 4
15 6000 1048576 65536 3 4
16 6000 1048576 65536 3 4
17 6000 1048576 65536 3 4
18 6000 1048576 65536 3 4
19 6000 1048576 65536 4
20 6000 1048576 65536 4
21 6000 1048576 65536 4
22 6000 1048576 65536 4
23 6000 1048576 65536 4
24 6000 1048576 65536 4
25 6000 1048576 65536 4
26 6000 1048576 65536 4
27 6000 1048576 65536 4