New Year Discounts
Easy
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
During the New Year's holiday season, the computer supermarket is offering a "New Year's Discounts" promotion. For each of the N
types of products available, both the regular and promotional prices are provided. Your task is to determine the maximum total discount you can achieve without exceeding a spending limit of M
, given that each product can only be purchased once.
Input
The first line contains two numbers, N
and M
. This is followed by N
lines, each containing a pair of numbers representing the regular and promotional prices of the products. All numbers are natural numbers, with M ≤ 1000
, and all other values do not exceed 100.
Output
Output the maximum total discount possible.
Examples
Input #1
Answer #1
Submissions 497
Acceptance rate 25%