hello ! I was solving this problem from Codechef
I think that the solution on the editorial is wrong and it should fail this exemple :
6 6
1 3 1
1 2 1
2 4 1
3 5 2
4 5 2
4 6 3
the answer is 33 while the tester's algorithm output 34
Am I wrong ?
EDIT : you can find the tester's solution at the end of the Editorial