forked from codebusted/codeforces-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
4B.py
32 lines (28 loc) · 1000 Bytes
/
4B.py
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
# the problem with this solution is it won't consider the minTime
# it focuses on studying maxTime hrs each day till the sumTime becomes zero
# this means completing work as soon as possible
def beforeExam(d, sumTime, minTime, maxTime):
if sumTime < minTime[0] or sumTime > sum(maxTime):
print("NO")
else:
print("YES")
li = []
for i in range(d):
if sumTime > maxTime[i]:
li.append(maxTime[i])
sumTime = sumTime - maxTime[i]
elif sumTime < maxTime[i]:
li.append(sumTime)
sumTime = 0
else:
li.append(sumTime)
sumTime = 0
print(*li) # * operator is used to print list separated by space
d, sumTime = [int(x) for x in input().split()]
minTime = []
maxTime = []
for i in range(d):
minMax = input().split()
minTime.append(int(minMax[0]))
maxTime.append(int(minMax[1]))
beforeExam(d, sumTime, minTime, maxTime)