answer:
Feeling really retarded. . I didn't even think of such a simple question.
Been thinking about doing this for a dynamic backpack. . find not
First obviously we will ask to sort by a[i] according to the m sequence
Then how to satisfy b?
It's actually quite simple. . It is only necessary to record f[i] to indicate the minimum and maximum value of the previous items when they reach the volume of i