cf/mirror

Maximize The Value

CF
1906F2100· master1s1024 MB⌨ stdin/stdout

Examples

Sample 1of 2
Input
2 6
1 1 -50
1 2 -20
2 2 -30
1 1 60
1 2 40
2 2 10
5
1 1 6
2 1 6
1 1 3
2 1 3
1 1 2
Output
100
50
0
0
-20
Sample 2of 2
Input
5 3
1 3 3
2 4 -2
3 5 3
6
1 1 3
2 1 3
3 1 3
3 2 3
2 2 3
2 2 2
Output
3
3
4
3
0
-2
1906F.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)