forked from anubhab91/CodeForces-5
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLunchRush.py
More file actions
36 lines (26 loc) · 819 Bytes
/
LunchRush.py
File metadata and controls
36 lines (26 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
__author__ = 'Devesh Bajpai'
import sys
'''
http://codeforces.com/problemset/problem/276/A
Algorithm: Just use the condition given in question (whether for current hotel, the t_i is more than k or not.
Catch here is to set the initial value of maximum which will be minimum possible value for integer and not 0.
'''
def solve(k,vals):
maximum = -sys.maxint-1
curr = -1
for i in range(0,len(vals)):
if(vals[i][1]>k):
curr = vals[i][0] - (vals[i][1]-k)
else:
curr = vals[i][0]
maximum = max(curr,maximum)
return maximum
if __name__ == "__main__":
n,k = map(int,raw_input().split(" "))
vals = list()
_n = 0
while(_n < n):
f,t = map(int,raw_input().split(" "))
vals.append([f,t])
_n+=1
print solve(k,vals)