Lunch Rush

题意翻译

## 题目描述 $n$ 个餐馆,每个餐馆都有两个值 $f_i$,$t_i$,分别代表在该餐馆的快乐值和所要停留的时间,给出一个正整数 $k$,如果 $t_i>k$,则在该餐馆的快乐值为 $f_i-(t_i-k)$,否则,仍为 $f_i$,选择一个餐馆,使获得的快乐值最大。 ## 输入格式 第一行两个正数 $n$,$k$。 接下来 $n$ 行每行两个数 $f_i$,$t_i$。 ## 输出格式 一个数,表示最大快乐值。 ## 数据范围 $1\leq n \leq 10^4$,$1\leq k,f_i,t_i \leq 10^9$。

题目描述

Having written another programming contest, three Rabbits decided to grab some lunch. The coach gave the team exactly $ k $ time units for the lunch break. The Rabbits have a list of $ n $ restaurants to lunch in: the $ i $ -th restaurant is characterized by two integers $ f_{i} $ and $ t_{i} $ . Value $ t_{i} $ shows the time the Rabbits need to lunch in the $ i $ -th restaurant. If time $ t_{i} $ exceeds the time $ k $ that the coach has given for the lunch break, then the Rabbits' joy from lunching in this restaurant will equal $ f_{i}-(t_{i}-k) $ . Otherwise, the Rabbits get exactly $ f_{i} $ units of joy. Your task is to find the value of the maximum joy the Rabbits can get from the lunch, depending on the restaurant. The Rabbits must choose exactly one restaurant to lunch in. Note that the joy value isn't necessarily a positive value.

输入输出格式

输入格式


The first line contains two space-separated integers — $ n $ ( $ 1<=n<=10^{4} $ ) and $ k $ ( $ 1<=k<=10^{9} $ ) — the number of restaurants in the Rabbits' list and the time the coach has given them to lunch, correspondingly. Each of the next $ n $ lines contains two space-separated integers — $ f_{i} $ ( $ 1<=f_{i}<=10^{9} $ ) and $ t_{i} $ ( $ 1<=t_{i}<=10^{9} $ ) — the characteristics of the $ i $ -th restaurant.

输出格式


In a single line print a single integer — the maximum joy value that the Rabbits will get from the lunch.

输入输出样例

输入样例 #1

2 5
3 3
4 5

输出样例 #1

4

输入样例 #2

4 6
5 8
3 6
2 3
2 2

输出样例 #2

3

输入样例 #3

1 5
1 7

输出样例 #3

-1