TopCoder

User's AC Ratio

71.4% (15/21)

Submission's AC Ratio

38.3% (23/60)

Tags

Description

Input Format

Output Format

Sample Input 1

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

Sample Output 1

2
-1
6
5

Sample Input 2

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

Sample Output 2

2
-1
5
6

Hints

Problem Source

YTP 2023 高中組初賽 p5

Subtasks

No. Testdata Range Constraints Score
1 0~1 範例測資 0
2 0, 2~10 $k_i = 2$ 3
3 0~1, 11~27 $N \leq 1000, Q \leq 5000, \sum k_i \leq 5000$ 3
4 0~39 無額外限制 9

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 2000 524288 65536 1 2 3 4
1 2000 524288 65536 1 3 4
2 2000 524288 65536 2 4
3 2000 524288 65536 2 4
4 2000 524288 65536 2 4
5 2000 524288 65536 2 4
6 2000 524288 65536 2 4
7 2000 524288 65536 2 4
8 2000 524288 65536 2 4
9 2000 524288 65536 2 4
10 2000 524288 65536 2 4
11 2000 524288 65536 3 4
12 2000 524288 65536 3 4
13 2000 524288 65536 3 4
14 2000 524288 65536 3 4
15 2000 524288 65536 3 4
16 2000 524288 65536 3 4
17 2000 524288 65536 3 4
18 2000 524288 65536 3 4
19 2000 524288 65536 3 4
20 2000 524288 65536 3 4
21 2000 524288 65536 3 4
22 2000 524288 65536 3 4
23 2000 524288 65536 3 4
24 2000 524288 65536 3 4
25 2000 524288 65536 3 4
26 2000 524288 65536 3 4
27 2000 524288 65536 3 4
28 2000 524288 65536 4
29 2000 524288 65536 4
30 2000 524288 65536 4
31 2000 524288 65536 4
32 2000 524288 65536 4
33 2000 524288 65536 4
34 2000 524288 65536 4
35 2000 524288 65536 4
36 2000 524288 65536 4
37 2000 524288 65536 4
38 2000 524288 65536 4
39 2000 524288 65536 4