Ticket 911
Problem 1629 -a
View hacks & all small testcases

Unable to dry run this testcase?
Try making a new request with small values of n_high, t_high, *_high, etc.


Retry
Input
2
2 9
5 9 
3 1 
3 8
7 5 2 
8 4 1 
Expected Output
13
21
Generator Parameters
--k_cap 1000 --k_high 9 --k_low 1 --n_cap 100 --n_high 9 --n_low 1 --t_cap 100 --t_high 2 --t_low 1 --val_cap 1000 --val_high 9 --val_low 1