Problems
10155 - HELP TITU!
SUBMIT PROBLEM

HELP TITU!

Time Limit: 1 sec

 

The Problem

TITU has recently got a broadband internet connection.He had  no internet earlier because he is kind of mizer . He managed this broadband connection from RAJU.The history of Titu's  internet usage has been given bellow.

 

During the first T1 minutes, data using speed  was D1 MBs per minute, and during next T2 minutes, internet data usage was D2 MBs per minute, and so on till during last TN minutes it was DN MBs per minute.

 

The internet provider charges the Titu 1 taka for every 1 MB of internet  data TITU used, except for the first K minutes, when the data is full free as the internet plan TITU Bought from ISP

 

Please find out the total amount that TITU has to pay to the ISP Company.

 

The Input

First line of the input contains a single integer TC the number of test cases. Description of TC test cases follow.

First line of each test case contains two space separated integers N and K.

Next N lines of each test case contains information about the internet data usage. Specifically, in the i-th line, there will be two space separated integers: Ti and Di. All number are fit within 32 bit integer.

 

The Output

For each test case output a single integer in separate line, the amount that TITU has to pay in Taka.

 

Sample Input

3
2 2
2 1
2 3
2 2
1 2
2 3
3 0
1 2
2 4
10 10

 

Sample Output

6

3

110

 

 

Explanation:

Example case 1. For the first two minutes, internet data of usage of TITU is free. He has to pay for last 2 minutes only, for which he will be charged at 3 dollars per minute, i.e. total 6 Taka.

 

 

Inter University Programming Contest(II) - 2018 [BGC Trust University Bangladesh]

Problem Setter: Parag Paul