message stringlengths 2 20.2k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 757 108k | cluster float64 4 4 | __index_level_0__ int64 1.51k 217k |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It seems that Borya is seriously sick. He is going visit n doctors to find out the exact diagnosis. Each of the doctors needs the information about all previous visits, so Borya has to visit them in the prescribed order (i.e. Borya should first visit doctor 1, then doctor 2, then doctor 3 and so on). Borya will get the information about his health from the last doctor.
Doctors have a strange working schedule. The doctor i goes to work on the si-th day and works every di day. So, he works on days si, si + di, si + 2di, ....
The doctor's appointment takes quite a long time, so Borya can not see more than one doctor per day. What is the minimum time he needs to visit all doctors?
Input
First line contains an integer n — number of doctors (1 ≤ n ≤ 1000).
Next n lines contain two numbers si and di (1 ≤ si, di ≤ 1000).
Output
Output a single integer — the minimum day at which Borya can visit the last doctor.
Examples
Input
3
2 2
1 2
2 2
Output
4
Input
2
10 1
6 5
Output
11
Note
In the first sample case, Borya can visit all doctors on days 2, 3 and 4.
In the second sample case, Borya can visit all doctors on days 10 and 11.
Submitted Solution:
```
n = int(input())
cur = 0
for i in range(n):
start, x = [int(k) for k in input().split()]
for j in range(start,1000,x):
if j > cur:
cur = j
#print(cur)
break
print(cur)
``` | instruction | 0 | 14,720 | 4 | 29,440 |
No | output | 1 | 14,720 | 4 | 29,441 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It seems that Borya is seriously sick. He is going visit n doctors to find out the exact diagnosis. Each of the doctors needs the information about all previous visits, so Borya has to visit them in the prescribed order (i.e. Borya should first visit doctor 1, then doctor 2, then doctor 3 and so on). Borya will get the information about his health from the last doctor.
Doctors have a strange working schedule. The doctor i goes to work on the si-th day and works every di day. So, he works on days si, si + di, si + 2di, ....
The doctor's appointment takes quite a long time, so Borya can not see more than one doctor per day. What is the minimum time he needs to visit all doctors?
Input
First line contains an integer n — number of doctors (1 ≤ n ≤ 1000).
Next n lines contain two numbers si and di (1 ≤ si, di ≤ 1000).
Output
Output a single integer — the minimum day at which Borya can visit the last doctor.
Examples
Input
3
2 2
1 2
2 2
Output
4
Input
2
10 1
6 5
Output
11
Note
In the first sample case, Borya can visit all doctors on days 2, 3 and 4.
In the second sample case, Borya can visit all doctors on days 10 and 11.
Submitted Solution:
```
n = int(input())
cur = 0
for i in range(n):
s, d = map(int, input().split())
if cur <= s:
cur = s
else:
t = 0
while cur >= s + t * d:
t += 1
cur = s + t * d
print(cur)
``` | instruction | 0 | 14,721 | 4 | 29,442 |
No | output | 1 | 14,721 | 4 | 29,443 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It seems that Borya is seriously sick. He is going visit n doctors to find out the exact diagnosis. Each of the doctors needs the information about all previous visits, so Borya has to visit them in the prescribed order (i.e. Borya should first visit doctor 1, then doctor 2, then doctor 3 and so on). Borya will get the information about his health from the last doctor.
Doctors have a strange working schedule. The doctor i goes to work on the si-th day and works every di day. So, he works on days si, si + di, si + 2di, ....
The doctor's appointment takes quite a long time, so Borya can not see more than one doctor per day. What is the minimum time he needs to visit all doctors?
Input
First line contains an integer n — number of doctors (1 ≤ n ≤ 1000).
Next n lines contain two numbers si and di (1 ≤ si, di ≤ 1000).
Output
Output a single integer — the minimum day at which Borya can visit the last doctor.
Examples
Input
3
2 2
1 2
2 2
Output
4
Input
2
10 1
6 5
Output
11
Note
In the first sample case, Borya can visit all doctors on days 2, 3 and 4.
In the second sample case, Borya can visit all doctors on days 10 and 11.
Submitted Solution:
```
x = int(input())
day_num = 1
doctors = [[*map(int, input().split())] for _ in range(x)]
while 1:
if day_num<doctors[0][0]:
day_num = doctors[0][0]
elif day_num<doctors[0][0]+doctors[0][1]:
day_num += doctors[0][0]+doctors[0][1]-day_num
if (abs(day_num-doctors[0][0])%doctors[0][1] == 0):
doctors = doctors[1:]
day_num+=1
if not doctors:
break
print(day_num-1)
``` | instruction | 0 | 14,722 | 4 | 29,444 |
No | output | 1 | 14,722 | 4 | 29,445 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It seems that Borya is seriously sick. He is going visit n doctors to find out the exact diagnosis. Each of the doctors needs the information about all previous visits, so Borya has to visit them in the prescribed order (i.e. Borya should first visit doctor 1, then doctor 2, then doctor 3 and so on). Borya will get the information about his health from the last doctor.
Doctors have a strange working schedule. The doctor i goes to work on the si-th day and works every di day. So, he works on days si, si + di, si + 2di, ....
The doctor's appointment takes quite a long time, so Borya can not see more than one doctor per day. What is the minimum time he needs to visit all doctors?
Input
First line contains an integer n — number of doctors (1 ≤ n ≤ 1000).
Next n lines contain two numbers si and di (1 ≤ si, di ≤ 1000).
Output
Output a single integer — the minimum day at which Borya can visit the last doctor.
Examples
Input
3
2 2
1 2
2 2
Output
4
Input
2
10 1
6 5
Output
11
Note
In the first sample case, Borya can visit all doctors on days 2, 3 and 4.
In the second sample case, Borya can visit all doctors on days 10 and 11.
Submitted Solution:
```
A = []
n = int(input())
for i in range(n):
s, d = map(int, input().split())
if not A:
A.append(s)
elif s <= A[-1]:
for j in range(s+d, 10000001, d):
if j not in A:
A.append(j)
break
else:
A.append(s)
print(A[-1])
``` | instruction | 0 | 14,723 | 4 | 29,446 |
No | output | 1 | 14,723 | 4 | 29,447 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently Luba bought a very interesting book. She knows that it will take t seconds to read the book. Luba wants to finish reading as fast as she can.
But she has some work to do in each of n next days. The number of seconds that Luba has to spend working during i-th day is ai. If some free time remains, she can spend it on reading.
Help Luba to determine the minimum number of day when she finishes reading.
It is guaranteed that the answer doesn't exceed n.
Remember that there are 86400 seconds in a day.
Input
The first line contains two integers n and t (1 ≤ n ≤ 100, 1 ≤ t ≤ 106) — the number of days and the time required to read the book.
The second line contains n integers ai (0 ≤ ai ≤ 86400) — the time Luba has to spend on her work during i-th day.
Output
Print the minimum day Luba can finish reading the book.
It is guaranteed that answer doesn't exceed n.
Examples
Input
2 2
86400 86398
Output
2
Input
2 86400
0 86400
Output
1 | instruction | 0 | 15,634 | 4 | 31,268 |
Tags: implementation
Correct Solution:
```
n, t = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]
ans = 0
while(t>0):
t -= 86400-a[ans]
ans += 1
print(ans)
``` | output | 1 | 15,634 | 4 | 31,269 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently Luba bought a very interesting book. She knows that it will take t seconds to read the book. Luba wants to finish reading as fast as she can.
But she has some work to do in each of n next days. The number of seconds that Luba has to spend working during i-th day is ai. If some free time remains, she can spend it on reading.
Help Luba to determine the minimum number of day when she finishes reading.
It is guaranteed that the answer doesn't exceed n.
Remember that there are 86400 seconds in a day.
Input
The first line contains two integers n and t (1 ≤ n ≤ 100, 1 ≤ t ≤ 106) — the number of days and the time required to read the book.
The second line contains n integers ai (0 ≤ ai ≤ 86400) — the time Luba has to spend on her work during i-th day.
Output
Print the minimum day Luba can finish reading the book.
It is guaranteed that answer doesn't exceed n.
Examples
Input
2 2
86400 86398
Output
2
Input
2 86400
0 86400
Output
1 | instruction | 0 | 15,635 | 4 | 31,270 |
Tags: implementation
Correct Solution:
```
n,t=map(int,input().split())
a=list(map(int,input().split()))
c=0
for i in range (n):
c+=(86400-a[i])
if c>=t:
print(i+1)
break
``` | output | 1 | 15,635 | 4 | 31,271 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently Luba bought a very interesting book. She knows that it will take t seconds to read the book. Luba wants to finish reading as fast as she can.
But she has some work to do in each of n next days. The number of seconds that Luba has to spend working during i-th day is ai. If some free time remains, she can spend it on reading.
Help Luba to determine the minimum number of day when she finishes reading.
It is guaranteed that the answer doesn't exceed n.
Remember that there are 86400 seconds in a day.
Input
The first line contains two integers n and t (1 ≤ n ≤ 100, 1 ≤ t ≤ 106) — the number of days and the time required to read the book.
The second line contains n integers ai (0 ≤ ai ≤ 86400) — the time Luba has to spend on her work during i-th day.
Output
Print the minimum day Luba can finish reading the book.
It is guaranteed that answer doesn't exceed n.
Examples
Input
2 2
86400 86398
Output
2
Input
2 86400
0 86400
Output
1 | instruction | 0 | 15,636 | 4 | 31,272 |
Tags: implementation
Correct Solution:
```
def main():
day = 86400
n,x = map(int,input().split())
a = list(map(int,input().split()))
if n < 1 or n > 100 or x < 1 or x > 1000000 or len(a) != n:
print("NO")
return
else:
ctr = 1
for d in a:
x -= max(day-d,0)
if x <= 0:
print(ctr)
return
ctr += 1
if __name__ == "__main__":
main()
``` | output | 1 | 15,636 | 4 | 31,273 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently Luba bought a very interesting book. She knows that it will take t seconds to read the book. Luba wants to finish reading as fast as she can.
But she has some work to do in each of n next days. The number of seconds that Luba has to spend working during i-th day is ai. If some free time remains, she can spend it on reading.
Help Luba to determine the minimum number of day when she finishes reading.
It is guaranteed that the answer doesn't exceed n.
Remember that there are 86400 seconds in a day.
Input
The first line contains two integers n and t (1 ≤ n ≤ 100, 1 ≤ t ≤ 106) — the number of days and the time required to read the book.
The second line contains n integers ai (0 ≤ ai ≤ 86400) — the time Luba has to spend on her work during i-th day.
Output
Print the minimum day Luba can finish reading the book.
It is guaranteed that answer doesn't exceed n.
Examples
Input
2 2
86400 86398
Output
2
Input
2 86400
0 86400
Output
1 | instruction | 0 | 15,637 | 4 | 31,274 |
Tags: implementation
Correct Solution:
```
n,t=[int(i) for i in input().split()]
s=[int(i) for i in input().split()]
i=0
while t>0:
a=86400-s[i]
t=t-a
i=i+1
print(i)
``` | output | 1 | 15,637 | 4 | 31,275 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently Luba bought a very interesting book. She knows that it will take t seconds to read the book. Luba wants to finish reading as fast as she can.
But she has some work to do in each of n next days. The number of seconds that Luba has to spend working during i-th day is ai. If some free time remains, she can spend it on reading.
Help Luba to determine the minimum number of day when she finishes reading.
It is guaranteed that the answer doesn't exceed n.
Remember that there are 86400 seconds in a day.
Input
The first line contains two integers n and t (1 ≤ n ≤ 100, 1 ≤ t ≤ 106) — the number of days and the time required to read the book.
The second line contains n integers ai (0 ≤ ai ≤ 86400) — the time Luba has to spend on her work during i-th day.
Output
Print the minimum day Luba can finish reading the book.
It is guaranteed that answer doesn't exceed n.
Examples
Input
2 2
86400 86398
Output
2
Input
2 86400
0 86400
Output
1 | instruction | 0 | 15,638 | 4 | 31,276 |
Tags: implementation
Correct Solution:
```
n, t = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
ans = 1
sums = []
for i in a:
sums.append(86400 - i)
while sum(sums[0:ans]) < t:
ans += 1
print(ans)
``` | output | 1 | 15,638 | 4 | 31,277 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently Luba bought a very interesting book. She knows that it will take t seconds to read the book. Luba wants to finish reading as fast as she can.
But she has some work to do in each of n next days. The number of seconds that Luba has to spend working during i-th day is ai. If some free time remains, she can spend it on reading.
Help Luba to determine the minimum number of day when she finishes reading.
It is guaranteed that the answer doesn't exceed n.
Remember that there are 86400 seconds in a day.
Input
The first line contains two integers n and t (1 ≤ n ≤ 100, 1 ≤ t ≤ 106) — the number of days and the time required to read the book.
The second line contains n integers ai (0 ≤ ai ≤ 86400) — the time Luba has to spend on her work during i-th day.
Output
Print the minimum day Luba can finish reading the book.
It is guaranteed that answer doesn't exceed n.
Examples
Input
2 2
86400 86398
Output
2
Input
2 86400
0 86400
Output
1 | instruction | 0 | 15,639 | 4 | 31,278 |
Tags: implementation
Correct Solution:
```
R=lambda:list(map(int,input().split()))
n, t = R()
list = R()
for i in range(n):
t -= 86400 - list[i]
if (t <= 0):
print(i+1)
break
``` | output | 1 | 15,639 | 4 | 31,279 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently Luba bought a very interesting book. She knows that it will take t seconds to read the book. Luba wants to finish reading as fast as she can.
But she has some work to do in each of n next days. The number of seconds that Luba has to spend working during i-th day is ai. If some free time remains, she can spend it on reading.
Help Luba to determine the minimum number of day when she finishes reading.
It is guaranteed that the answer doesn't exceed n.
Remember that there are 86400 seconds in a day.
Input
The first line contains two integers n and t (1 ≤ n ≤ 100, 1 ≤ t ≤ 106) — the number of days and the time required to read the book.
The second line contains n integers ai (0 ≤ ai ≤ 86400) — the time Luba has to spend on her work during i-th day.
Output
Print the minimum day Luba can finish reading the book.
It is guaranteed that answer doesn't exceed n.
Examples
Input
2 2
86400 86398
Output
2
Input
2 86400
0 86400
Output
1 | instruction | 0 | 15,640 | 4 | 31,280 |
Tags: implementation
Correct Solution:
```
(n, t) = list(map(int, input().split()))
a = list(map(int, input().split()))
secondInDay = 24 * 60 * 60
result = 0
while t > 0:
t -= secondInDay - a[result]
result += 1
print(result)
``` | output | 1 | 15,640 | 4 | 31,281 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently Luba bought a very interesting book. She knows that it will take t seconds to read the book. Luba wants to finish reading as fast as she can.
But she has some work to do in each of n next days. The number of seconds that Luba has to spend working during i-th day is ai. If some free time remains, she can spend it on reading.
Help Luba to determine the minimum number of day when she finishes reading.
It is guaranteed that the answer doesn't exceed n.
Remember that there are 86400 seconds in a day.
Input
The first line contains two integers n and t (1 ≤ n ≤ 100, 1 ≤ t ≤ 106) — the number of days and the time required to read the book.
The second line contains n integers ai (0 ≤ ai ≤ 86400) — the time Luba has to spend on her work during i-th day.
Output
Print the minimum day Luba can finish reading the book.
It is guaranteed that answer doesn't exceed n.
Examples
Input
2 2
86400 86398
Output
2
Input
2 86400
0 86400
Output
1 | instruction | 0 | 15,641 | 4 | 31,282 |
Tags: implementation
Correct Solution:
```
(n, t) = map(lambda x: int(x) , str(input()).split(' '))
a = list(map(lambda x: int(x) , str(input()).split(' ')))
day = 0
while t > 0:
t -= 86400 - a[day]
day += 1
print(day)
``` | output | 1 | 15,641 | 4 | 31,283 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently Luba bought a very interesting book. She knows that it will take t seconds to read the book. Luba wants to finish reading as fast as she can.
But she has some work to do in each of n next days. The number of seconds that Luba has to spend working during i-th day is ai. If some free time remains, she can spend it on reading.
Help Luba to determine the minimum number of day when she finishes reading.
It is guaranteed that the answer doesn't exceed n.
Remember that there are 86400 seconds in a day.
Input
The first line contains two integers n and t (1 ≤ n ≤ 100, 1 ≤ t ≤ 106) — the number of days and the time required to read the book.
The second line contains n integers ai (0 ≤ ai ≤ 86400) — the time Luba has to spend on her work during i-th day.
Output
Print the minimum day Luba can finish reading the book.
It is guaranteed that answer doesn't exceed n.
Examples
Input
2 2
86400 86398
Output
2
Input
2 86400
0 86400
Output
1
Submitted Solution:
```
n, t = map(int, input().split())
a = list(map(int, input().split()))
#c = 0
for i in range(n):
t -= 86400 - a[i]
if t <= 0:
print(i + 1)
break
``` | instruction | 0 | 15,642 | 4 | 31,284 |
Yes | output | 1 | 15,642 | 4 | 31,285 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently Luba bought a very interesting book. She knows that it will take t seconds to read the book. Luba wants to finish reading as fast as she can.
But she has some work to do in each of n next days. The number of seconds that Luba has to spend working during i-th day is ai. If some free time remains, she can spend it on reading.
Help Luba to determine the minimum number of day when she finishes reading.
It is guaranteed that the answer doesn't exceed n.
Remember that there are 86400 seconds in a day.
Input
The first line contains two integers n and t (1 ≤ n ≤ 100, 1 ≤ t ≤ 106) — the number of days and the time required to read the book.
The second line contains n integers ai (0 ≤ ai ≤ 86400) — the time Luba has to spend on her work during i-th day.
Output
Print the minimum day Luba can finish reading the book.
It is guaranteed that answer doesn't exceed n.
Examples
Input
2 2
86400 86398
Output
2
Input
2 86400
0 86400
Output
1
Submitted Solution:
```
n, t = map(int, input().split())
a = list(map(int, input().split()))
s = 0
for i in range(n):
s += 86400 - a[i]
if s >= t:
print(i + 1)
break
# UBCF
# CodeForcesian
# ♥
# گرسنمه :|
``` | instruction | 0 | 15,643 | 4 | 31,286 |
Yes | output | 1 | 15,643 | 4 | 31,287 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently Luba bought a very interesting book. She knows that it will take t seconds to read the book. Luba wants to finish reading as fast as she can.
But she has some work to do in each of n next days. The number of seconds that Luba has to spend working during i-th day is ai. If some free time remains, she can spend it on reading.
Help Luba to determine the minimum number of day when she finishes reading.
It is guaranteed that the answer doesn't exceed n.
Remember that there are 86400 seconds in a day.
Input
The first line contains two integers n and t (1 ≤ n ≤ 100, 1 ≤ t ≤ 106) — the number of days and the time required to read the book.
The second line contains n integers ai (0 ≤ ai ≤ 86400) — the time Luba has to spend on her work during i-th day.
Output
Print the minimum day Luba can finish reading the book.
It is guaranteed that answer doesn't exceed n.
Examples
Input
2 2
86400 86398
Output
2
Input
2 86400
0 86400
Output
1
Submitted Solution:
```
n,t = list(map(int,input().split()))
l = list(map(int,input().split()))
for i in range(len(l)):
t = t - (86400 - l[i])
if t <= 0:
print(i+1)
break
``` | instruction | 0 | 15,644 | 4 | 31,288 |
Yes | output | 1 | 15,644 | 4 | 31,289 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently Luba bought a very interesting book. She knows that it will take t seconds to read the book. Luba wants to finish reading as fast as she can.
But she has some work to do in each of n next days. The number of seconds that Luba has to spend working during i-th day is ai. If some free time remains, she can spend it on reading.
Help Luba to determine the minimum number of day when she finishes reading.
It is guaranteed that the answer doesn't exceed n.
Remember that there are 86400 seconds in a day.
Input
The first line contains two integers n and t (1 ≤ n ≤ 100, 1 ≤ t ≤ 106) — the number of days and the time required to read the book.
The second line contains n integers ai (0 ≤ ai ≤ 86400) — the time Luba has to spend on her work during i-th day.
Output
Print the minimum day Luba can finish reading the book.
It is guaranteed that answer doesn't exceed n.
Examples
Input
2 2
86400 86398
Output
2
Input
2 86400
0 86400
Output
1
Submitted Solution:
```
n,t = map(int,input().split())
A = list(map(int,input().split()))
B = []
for i in range (n):
B.append(86400-A[i])
su = 0
for i in range (n):
su += B[i]
if su >= t:
print (i+1)
break
``` | instruction | 0 | 15,645 | 4 | 31,290 |
Yes | output | 1 | 15,645 | 4 | 31,291 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently Luba bought a very interesting book. She knows that it will take t seconds to read the book. Luba wants to finish reading as fast as she can.
But she has some work to do in each of n next days. The number of seconds that Luba has to spend working during i-th day is ai. If some free time remains, she can spend it on reading.
Help Luba to determine the minimum number of day when she finishes reading.
It is guaranteed that the answer doesn't exceed n.
Remember that there are 86400 seconds in a day.
Input
The first line contains two integers n and t (1 ≤ n ≤ 100, 1 ≤ t ≤ 106) — the number of days and the time required to read the book.
The second line contains n integers ai (0 ≤ ai ≤ 86400) — the time Luba has to spend on her work during i-th day.
Output
Print the minimum day Luba can finish reading the book.
It is guaranteed that answer doesn't exceed n.
Examples
Input
2 2
86400 86398
Output
2
Input
2 86400
0 86400
Output
1
Submitted Solution:
```
n , t = map(int,input().split())
l = list(map(int,input().split()))
s = 0
i = 0
while i < n - 1 :
s = 86400 - l[i]
if s >= t :
break
i += 1
print(i+1)
``` | instruction | 0 | 15,646 | 4 | 31,292 |
No | output | 1 | 15,646 | 4 | 31,293 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently Luba bought a very interesting book. She knows that it will take t seconds to read the book. Luba wants to finish reading as fast as she can.
But she has some work to do in each of n next days. The number of seconds that Luba has to spend working during i-th day is ai. If some free time remains, she can spend it on reading.
Help Luba to determine the minimum number of day when she finishes reading.
It is guaranteed that the answer doesn't exceed n.
Remember that there are 86400 seconds in a day.
Input
The first line contains two integers n and t (1 ≤ n ≤ 100, 1 ≤ t ≤ 106) — the number of days and the time required to read the book.
The second line contains n integers ai (0 ≤ ai ≤ 86400) — the time Luba has to spend on her work during i-th day.
Output
Print the minimum day Luba can finish reading the book.
It is guaranteed that answer doesn't exceed n.
Examples
Input
2 2
86400 86398
Output
2
Input
2 86400
0 86400
Output
1
Submitted Solution:
```
n,m=map(int,input().split())
l=list(map(int,input().split()))
ans=0
for i in range(n):
m-abs(l[i]-86400)
ans+=1
print(ans)
``` | instruction | 0 | 15,647 | 4 | 31,294 |
No | output | 1 | 15,647 | 4 | 31,295 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently Luba bought a very interesting book. She knows that it will take t seconds to read the book. Luba wants to finish reading as fast as she can.
But she has some work to do in each of n next days. The number of seconds that Luba has to spend working during i-th day is ai. If some free time remains, she can spend it on reading.
Help Luba to determine the minimum number of day when she finishes reading.
It is guaranteed that the answer doesn't exceed n.
Remember that there are 86400 seconds in a day.
Input
The first line contains two integers n and t (1 ≤ n ≤ 100, 1 ≤ t ≤ 106) — the number of days and the time required to read the book.
The second line contains n integers ai (0 ≤ ai ≤ 86400) — the time Luba has to spend on her work during i-th day.
Output
Print the minimum day Luba can finish reading the book.
It is guaranteed that answer doesn't exceed n.
Examples
Input
2 2
86400 86398
Output
2
Input
2 86400
0 86400
Output
1
Submitted Solution:
```
# http://codeforces.com/problemset/problem/884/A
n, t = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]
for i in range(n):
if 86400-q[i] >= t:
print(i+1)
break
``` | instruction | 0 | 15,648 | 4 | 31,296 |
No | output | 1 | 15,648 | 4 | 31,297 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently Luba bought a very interesting book. She knows that it will take t seconds to read the book. Luba wants to finish reading as fast as she can.
But she has some work to do in each of n next days. The number of seconds that Luba has to spend working during i-th day is ai. If some free time remains, she can spend it on reading.
Help Luba to determine the minimum number of day when she finishes reading.
It is guaranteed that the answer doesn't exceed n.
Remember that there are 86400 seconds in a day.
Input
The first line contains two integers n and t (1 ≤ n ≤ 100, 1 ≤ t ≤ 106) — the number of days and the time required to read the book.
The second line contains n integers ai (0 ≤ ai ≤ 86400) — the time Luba has to spend on her work during i-th day.
Output
Print the minimum day Luba can finish reading the book.
It is guaranteed that answer doesn't exceed n.
Examples
Input
2 2
86400 86398
Output
2
Input
2 86400
0 86400
Output
1
Submitted Solution:
```
a = [int(i) for i in (input().split())]
b = [int(i) for i in (input().split())]
c = a[1]
d = a[0]
e = 0
for i in range(0, d):
if c != 0:
c = c - (86400 - b[i])
e += 1
else:
d = i
print(e)
``` | instruction | 0 | 15,649 | 4 | 31,298 |
No | output | 1 | 15,649 | 4 | 31,299 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Yet another education system reform has been carried out in Berland recently. The innovations are as follows:
An academic year now consists of n days. Each day pupils study exactly one of m subjects, besides, each subject is studied for no more than one day. After the lessons of the i-th subject pupils get the home task that contains no less than ai and no more than bi exercises. Besides, each subject has a special attribute, the complexity (ci). A school can make its own timetable, considering the following conditions are satisfied:
* the timetable should contain the subjects in the order of the complexity's strict increasing;
* each day, except for the first one, the task should contain either k times more exercises, or more by k compared to the previous day (more formally: let's call the number of home task exercises in the i-th day as xi, then for each i (1 < i ≤ n): either xi = k + xi - 1 or xi = k·xi - 1 must be true);
* the total number of exercises in all home tasks should be maximal possible.
All limitations are separately set for each school.
It turned out that in many cases ai and bi reach 1016 (however, as the Berland Minister of Education is famous for his love to half-measures, the value of bi - ai doesn't exceed 100). That also happened in the Berland School №256. Nevertheless, you as the school's principal still have to work out the timetable for the next academic year...
Input
The first line contains three integers n, m, k (1 ≤ n ≤ m ≤ 50, 1 ≤ k ≤ 100) which represent the number of days in an academic year, the number of subjects and the k parameter correspondingly. Each of the following m lines contains the description of a subject as three integers ai, bi, ci (1 ≤ ai ≤ bi ≤ 1016, bi - ai ≤ 100, 1 ≤ ci ≤ 100) — two limitations to the number of exercises on the i-th subject and the complexity of the i-th subject, correspondingly. Distinct subjects can have the same complexity. The subjects are numbered with integers from 1 to m.
Please do not use the %lld specificator to read or write 64-bit numbers in С++. It is preferred to use the cin stream or the %I64d specificator.
Output
If no valid solution exists, print the single word "NO" (without the quotes). Otherwise, the first line should contain the word "YES" (without the quotes) and the next n lines should contain any timetable that satisfies all the conditions. The i + 1-th line should contain two positive integers: the number of the subject to study on the i-th day and the number of home task exercises given for this subject. The timetable should contain exactly n subjects.
Examples
Input
4 5 2
1 10 1
1 10 2
1 10 3
1 20 4
1 100 5
Output
YES
2 8
3 10
4 20
5 40
Input
3 4 3
1 3 1
2 4 4
2 3 3
2 2 2
Output
NO | instruction | 0 | 16,921 | 4 | 33,842 |
Tags: dp
Correct Solution:
```
class Subject:
def __init__(self, id, low, high, complexity):
self.id = id
self.low = low
self.high = high
self.complexity = complexity
self.day_links = [ {} for i in range(high - low + 1) ]
def add_link(self, link):
days = link.days
links = self.day_links[link.weight - self.low]
if days not in links or links[days].total < link.total:
links[days] = link
def __str__(self):
return '[%d [%d, %d] %d]' % (self.id,
self.low, self.high, self.complexity)
class Link:
def __init__(self, subject, weight, total, days, previous):
self.subject = subject
self.weight = weight
self.total = total
self.days = days
self.previous = previous
class Group:
def __init__(self, complexity):
self.complexity = complexity
self.subjects = []
need_days, num_subjects, more = map(int, input().split())
groups = {}
for i in range(num_subjects):
subject = Subject(i + 1, *list(map(int, input().split())))
if subject.complexity not in groups:
groups[subject.complexity] = Group(subject.complexity)
groups[subject.complexity].subjects.append(subject)
groups = sorted(groups.values(), key = lambda group: group.complexity)
num_groups = len(groups)
def win(link):
print('YES')
schedule = need_days * [ None ]
while link:
subject = link.subject
subject.weight = link.weight
schedule[link.days - 1] = subject
link = link.previous
for subject in schedule:
print(subject.id, subject.weight)
import sys
sys.exit()
best_link = None
for pos, group in enumerate(groups):
#print(pos, '', ' '.join(map(str, group.subjects)))
if num_groups - pos >= need_days:
for subject in group.subjects:
for weight in range(subject.low, subject.high + 1):
subject.add_link(Link(subject, weight, weight, 1, None))
for subject in group.subjects:
for i, links in enumerate(subject.day_links):
weight = subject.low + i
for days, link in links.items():
if link.weight != weight:
print('expected weight %d, link has weight %d' % (
weight, link.weight))
import sys; sys.exit()
if days == need_days:
if not best_link or best_link.total < link.total:
best_link = link
continue
for next_weight in [ weight + more, weight * more ]:
max_pos = num_groups + days - need_days
for next_pos in range(pos + 1, max_pos + 1):
for next_subject in groups[next_pos].subjects:
if next_weight < next_subject.low:
continue
if next_weight > next_subject.high:
continue
next_subject.add_link(Link(
next_subject, next_weight,
next_weight + link.total, days + 1, link))
#print('%d -> %d (%d)' % (link.weight,
# next_weight, days + 1))
if best_link:
win(best_link)
else:
print('NO')
``` | output | 1 | 16,921 | 4 | 33,843 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Yet another education system reform has been carried out in Berland recently. The innovations are as follows:
An academic year now consists of n days. Each day pupils study exactly one of m subjects, besides, each subject is studied for no more than one day. After the lessons of the i-th subject pupils get the home task that contains no less than ai and no more than bi exercises. Besides, each subject has a special attribute, the complexity (ci). A school can make its own timetable, considering the following conditions are satisfied:
* the timetable should contain the subjects in the order of the complexity's strict increasing;
* each day, except for the first one, the task should contain either k times more exercises, or more by k compared to the previous day (more formally: let's call the number of home task exercises in the i-th day as xi, then for each i (1 < i ≤ n): either xi = k + xi - 1 or xi = k·xi - 1 must be true);
* the total number of exercises in all home tasks should be maximal possible.
All limitations are separately set for each school.
It turned out that in many cases ai and bi reach 1016 (however, as the Berland Minister of Education is famous for his love to half-measures, the value of bi - ai doesn't exceed 100). That also happened in the Berland School №256. Nevertheless, you as the school's principal still have to work out the timetable for the next academic year...
Input
The first line contains three integers n, m, k (1 ≤ n ≤ m ≤ 50, 1 ≤ k ≤ 100) which represent the number of days in an academic year, the number of subjects and the k parameter correspondingly. Each of the following m lines contains the description of a subject as three integers ai, bi, ci (1 ≤ ai ≤ bi ≤ 1016, bi - ai ≤ 100, 1 ≤ ci ≤ 100) — two limitations to the number of exercises on the i-th subject and the complexity of the i-th subject, correspondingly. Distinct subjects can have the same complexity. The subjects are numbered with integers from 1 to m.
Please do not use the %lld specificator to read or write 64-bit numbers in С++. It is preferred to use the cin stream or the %I64d specificator.
Output
If no valid solution exists, print the single word "NO" (without the quotes). Otherwise, the first line should contain the word "YES" (without the quotes) and the next n lines should contain any timetable that satisfies all the conditions. The i + 1-th line should contain two positive integers: the number of the subject to study on the i-th day and the number of home task exercises given for this subject. The timetable should contain exactly n subjects.
Examples
Input
4 5 2
1 10 1
1 10 2
1 10 3
1 20 4
1 100 5
Output
YES
2 8
3 10
4 20
5 40
Input
3 4 3
1 3 1
2 4 4
2 3 3
2 2 2
Output
NO | instruction | 0 | 16,922 | 4 | 33,844 |
Tags: dp
Correct Solution:
```
class Subject:
def __init__(self, id, low, high, complexity):
self.id = id
self.low = low
self.high = high
self.complexity = complexity
self.day_links = [ {} for i in range(high - low + 1) ]
def add_link(self, link):
days = link.days
links = self.day_links[link.weight - self.low]
if days not in links or links[days].total < link.total:
links[days] = link
def __str__(self):
return '[%d [%d, %d] %d]' % (self.id,
self.low, self.high, self.complexity)
class Link:
def __init__(self, subject, weight, total, days, previous):
self.subject = subject
self.weight = weight
self.total = total
self.days = days
self.previous = previous
class Group:
def __init__(self, complexity):
self.complexity = complexity
self.subjects = []
need_days, num_subjects, more = map(int, input().split())
groups = {}
for i in range(num_subjects):
subject = Subject(i + 1, *list(map(int, input().split())))
if subject.complexity not in groups:
groups[subject.complexity] = Group(subject.complexity)
groups[subject.complexity].subjects.append(subject)
groups = sorted(groups.values(), key = lambda group: group.complexity)
num_groups = len(groups)
def win(link):
print('YES')
schedule = need_days * [ None ]
while link:
subject = link.subject
subject.weight = link.weight
schedule[link.days - 1] = subject
link = link.previous
for subject in schedule:
print(subject.id, subject.weight)
import sys
sys.exit()
best_link = None
for pos, group in enumerate(groups):
#print(pos, '', ' '.join(map(str, group.subjects)))
if num_groups - pos >= need_days:
for subject in group.subjects:
for weight in range(subject.low, subject.high + 1):
subject.add_link(Link(subject, weight, weight, 1, None))
for subject in group.subjects:
for i, links in enumerate(subject.day_links):
weight = subject.low + i
for days, link in links.items():
if link.weight != weight:
print('expected weight %d, link has weight %d' % (
weight, link.weight))
import sys; sys.exit()
if days == need_days:
if not best_link or best_link.total < link.total:
best_link = link
continue
for next_weight in [ weight + more, weight * more ]:
max_pos = num_groups + days - need_days
for next_pos in range(pos + 1, max_pos + 1):
for next_subject in groups[next_pos].subjects:
if next_weight < next_subject.low:
continue
if next_weight > next_subject.high:
continue
next_subject.add_link(Link(
next_subject, next_weight,
next_weight + link.total, days + 1, link))
#print('%d -> %d (%d)' % (link.weight,
# next_weight, days + 1))
if best_link:
win(best_link)
else:
print('NO')
# Made By Mostafa_Khaled
``` | output | 1 | 16,922 | 4 | 33,845 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Yet another education system reform has been carried out in Berland recently. The innovations are as follows:
An academic year now consists of n days. Each day pupils study exactly one of m subjects, besides, each subject is studied for no more than one day. After the lessons of the i-th subject pupils get the home task that contains no less than ai and no more than bi exercises. Besides, each subject has a special attribute, the complexity (ci). A school can make its own timetable, considering the following conditions are satisfied:
* the timetable should contain the subjects in the order of the complexity's strict increasing;
* each day, except for the first one, the task should contain either k times more exercises, or more by k compared to the previous day (more formally: let's call the number of home task exercises in the i-th day as xi, then for each i (1 < i ≤ n): either xi = k + xi - 1 or xi = k·xi - 1 must be true);
* the total number of exercises in all home tasks should be maximal possible.
All limitations are separately set for each school.
It turned out that in many cases ai and bi reach 1016 (however, as the Berland Minister of Education is famous for his love to half-measures, the value of bi - ai doesn't exceed 100). That also happened in the Berland School №256. Nevertheless, you as the school's principal still have to work out the timetable for the next academic year...
Input
The first line contains three integers n, m, k (1 ≤ n ≤ m ≤ 50, 1 ≤ k ≤ 100) which represent the number of days in an academic year, the number of subjects and the k parameter correspondingly. Each of the following m lines contains the description of a subject as three integers ai, bi, ci (1 ≤ ai ≤ bi ≤ 1016, bi - ai ≤ 100, 1 ≤ ci ≤ 100) — two limitations to the number of exercises on the i-th subject and the complexity of the i-th subject, correspondingly. Distinct subjects can have the same complexity. The subjects are numbered with integers from 1 to m.
Please do not use the %lld specificator to read or write 64-bit numbers in С++. It is preferred to use the cin stream or the %I64d specificator.
Output
If no valid solution exists, print the single word "NO" (without the quotes). Otherwise, the first line should contain the word "YES" (without the quotes) and the next n lines should contain any timetable that satisfies all the conditions. The i + 1-th line should contain two positive integers: the number of the subject to study on the i-th day and the number of home task exercises given for this subject. The timetable should contain exactly n subjects.
Examples
Input
4 5 2
1 10 1
1 10 2
1 10 3
1 20 4
1 100 5
Output
YES
2 8
3 10
4 20
5 40
Input
3 4 3
1 3 1
2 4 4
2 3 3
2 2 2
Output
NO | instruction | 0 | 16,923 | 4 | 33,846 |
Tags: dp
Correct Solution:
```
class Subject:
def __init__(self, id, low, high, complexity):
self.id = id
self.low = low
self.high = high
self.complexity = complexity
self.day_links = [ {} for i in range(high - low + 1) ]
def add_link(self, link):
day = link.day
links = self.day_links[link.weight - self.low]
if day not in links or links[day].total < link.total:
links[day] = link
class Link:
def __init__(self, subject, weight, total, day, previous):
self.subject = subject
self.weight = weight
self.total = total
self.day = day
self.previous = previous
class Group:
def __init__(self, complexity):
self.complexity = complexity
self.subjects = []
need_day, num_subjects, more = map(int, input().split())
groups = {}
for i in range(num_subjects):
subject = Subject(i + 1, *list(map(int, input().split())))
if subject.complexity not in groups:
groups[subject.complexity] = Group(subject.complexity)
groups[subject.complexity].subjects.append(subject)
groups = sorted(groups.values(), key = lambda group: group.complexity)
num_groups = len(groups)
best_link = None
for pos, group in enumerate(groups):
if num_groups - pos >= need_day:
for subject in group.subjects:
for weight in range(subject.low, subject.high + 1):
subject.add_link(Link(subject, weight, weight, 1, None))
for subject in group.subjects:
for i, links in enumerate(subject.day_links):
weight = subject.low + i
for day, link in links.items():
if day == need_day:
if not best_link or best_link.total < link.total:
best_link = link
continue
for next_weight in [ weight + more, weight * more ]:
max_pos = num_groups + day - need_day
for next_pos in range(pos + 1, max_pos + 1):
for next_subject in groups[next_pos].subjects:
if next_weight < next_subject.low:
continue
if next_weight > next_subject.high:
continue
next_subject.add_link(Link(
next_subject, next_weight,
next_weight + link.total, day + 1, link))
if best_link:
print('YES')
schedule = need_day * [ None ]
link = best_link
while link:
subject = link.subject
subject.weight = link.weight
schedule[link.day - 1] = subject
link = link.previous
for subject in schedule:
print(subject.id, subject.weight)
import sys
sys.exit()
else:
print('NO')
``` | output | 1 | 16,923 | 4 | 33,847 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Yet another education system reform has been carried out in Berland recently. The innovations are as follows:
An academic year now consists of n days. Each day pupils study exactly one of m subjects, besides, each subject is studied for no more than one day. After the lessons of the i-th subject pupils get the home task that contains no less than ai and no more than bi exercises. Besides, each subject has a special attribute, the complexity (ci). A school can make its own timetable, considering the following conditions are satisfied:
* the timetable should contain the subjects in the order of the complexity's strict increasing;
* each day, except for the first one, the task should contain either k times more exercises, or more by k compared to the previous day (more formally: let's call the number of home task exercises in the i-th day as xi, then for each i (1 < i ≤ n): either xi = k + xi - 1 or xi = k·xi - 1 must be true);
* the total number of exercises in all home tasks should be maximal possible.
All limitations are separately set for each school.
It turned out that in many cases ai and bi reach 1016 (however, as the Berland Minister of Education is famous for his love to half-measures, the value of bi - ai doesn't exceed 100). That also happened in the Berland School №256. Nevertheless, you as the school's principal still have to work out the timetable for the next academic year...
Input
The first line contains three integers n, m, k (1 ≤ n ≤ m ≤ 50, 1 ≤ k ≤ 100) which represent the number of days in an academic year, the number of subjects and the k parameter correspondingly. Each of the following m lines contains the description of a subject as three integers ai, bi, ci (1 ≤ ai ≤ bi ≤ 1016, bi - ai ≤ 100, 1 ≤ ci ≤ 100) — two limitations to the number of exercises on the i-th subject and the complexity of the i-th subject, correspondingly. Distinct subjects can have the same complexity. The subjects are numbered with integers from 1 to m.
Please do not use the %lld specificator to read or write 64-bit numbers in С++. It is preferred to use the cin stream or the %I64d specificator.
Output
If no valid solution exists, print the single word "NO" (without the quotes). Otherwise, the first line should contain the word "YES" (without the quotes) and the next n lines should contain any timetable that satisfies all the conditions. The i + 1-th line should contain two positive integers: the number of the subject to study on the i-th day and the number of home task exercises given for this subject. The timetable should contain exactly n subjects.
Examples
Input
4 5 2
1 10 1
1 10 2
1 10 3
1 20 4
1 100 5
Output
YES
2 8
3 10
4 20
5 40
Input
3 4 3
1 3 1
2 4 4
2 3 3
2 2 2
Output
NO | instruction | 0 | 16,924 | 4 | 33,848 |
Tags: dp
Correct Solution:
```
class Subject:
def __init__(self, id, low, high, complexity):
self.id = id
self.low = low
self.high = high
self.complexity = complexity
self.day_links = [ {} for i in range(high - low + 1) ]
def add_link(self, link):
days = link.days
links = self.day_links[link.weight - self.low]
if days not in links or links[days].total < link.total:
links[days] = link
class Link:
def __init__(self, subject, weight, total, days, previous):
self.subject = subject
self.weight = weight
self.total = total
self.days = days
self.previous = previous
class Group:
def __init__(self, complexity):
self.complexity = complexity
self.subjects = []
need_days, num_subjects, more = map(int, input().split())
groups = {}
for i in range(num_subjects):
subject = Subject(i + 1, *list(map(int, input().split())))
if subject.complexity not in groups:
groups[subject.complexity] = Group(subject.complexity)
groups[subject.complexity].subjects.append(subject)
groups = sorted(groups.values(), key = lambda group: group.complexity)
num_groups = len(groups)
best_link = None
for pos, group in enumerate(groups):
if num_groups - pos >= need_days:
for subject in group.subjects:
for weight in range(subject.low, subject.high + 1):
subject.add_link(Link(subject, weight, weight, 1, None))
for subject in group.subjects:
for i, links in enumerate(subject.day_links):
weight = subject.low + i
for days, link in links.items():
if days == need_days:
if not best_link or best_link.total < link.total:
best_link = link
continue
for next_weight in [ weight + more, weight * more ]:
max_pos = num_groups + days - need_days
for next_pos in range(pos + 1, max_pos + 1):
for next_subject in groups[next_pos].subjects:
if next_weight < next_subject.low:
continue
if next_weight > next_subject.high:
continue
next_subject.add_link(Link(
next_subject, next_weight,
next_weight + link.total, days + 1, link))
if best_link:
print('YES')
schedule = need_days * [ None ]
link = best_link
while link:
subject = link.subject
subject.weight = link.weight
schedule[link.days - 1] = subject
link = link.previous
for subject in schedule:
print(subject.id, subject.weight)
import sys
sys.exit()
else:
print('NO')
``` | output | 1 | 16,924 | 4 | 33,849 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Yet another education system reform has been carried out in Berland recently. The innovations are as follows:
An academic year now consists of n days. Each day pupils study exactly one of m subjects, besides, each subject is studied for no more than one day. After the lessons of the i-th subject pupils get the home task that contains no less than ai and no more than bi exercises. Besides, each subject has a special attribute, the complexity (ci). A school can make its own timetable, considering the following conditions are satisfied:
* the timetable should contain the subjects in the order of the complexity's strict increasing;
* each day, except for the first one, the task should contain either k times more exercises, or more by k compared to the previous day (more formally: let's call the number of home task exercises in the i-th day as xi, then for each i (1 < i ≤ n): either xi = k + xi - 1 or xi = k·xi - 1 must be true);
* the total number of exercises in all home tasks should be maximal possible.
All limitations are separately set for each school.
It turned out that in many cases ai and bi reach 1016 (however, as the Berland Minister of Education is famous for his love to half-measures, the value of bi - ai doesn't exceed 100). That also happened in the Berland School №256. Nevertheless, you as the school's principal still have to work out the timetable for the next academic year...
Input
The first line contains three integers n, m, k (1 ≤ n ≤ m ≤ 50, 1 ≤ k ≤ 100) which represent the number of days in an academic year, the number of subjects and the k parameter correspondingly. Each of the following m lines contains the description of a subject as three integers ai, bi, ci (1 ≤ ai ≤ bi ≤ 1016, bi - ai ≤ 100, 1 ≤ ci ≤ 100) — two limitations to the number of exercises on the i-th subject and the complexity of the i-th subject, correspondingly. Distinct subjects can have the same complexity. The subjects are numbered with integers from 1 to m.
Please do not use the %lld specificator to read or write 64-bit numbers in С++. It is preferred to use the cin stream or the %I64d specificator.
Output
If no valid solution exists, print the single word "NO" (without the quotes). Otherwise, the first line should contain the word "YES" (without the quotes) and the next n lines should contain any timetable that satisfies all the conditions. The i + 1-th line should contain two positive integers: the number of the subject to study on the i-th day and the number of home task exercises given for this subject. The timetable should contain exactly n subjects.
Examples
Input
4 5 2
1 10 1
1 10 2
1 10 3
1 20 4
1 100 5
Output
YES
2 8
3 10
4 20
5 40
Input
3 4 3
1 3 1
2 4 4
2 3 3
2 2 2
Output
NO
Submitted Solution:
```
class Subject:
def __init__(self, id, low, high, complexity):
self.id = id
self.low = low
self.high = high
self.complexity = complexity
self.links = (high - low + 1) * [ None ]
def add_link(self, weight, new_link):
link = self.links[weight - self.low]
if link == None or link.days < new_link.days:
self.links[weight - self.low] = new_link
def __str__(self):
return '[%d [%d, %d] %d]' % (self.id,
self.low, self.high, self.complexity)
class Link:
def __init__(self, subject, weight, days, previous):
self.subject = subject
self.weight = weight
self.days = days
self.previous = previous
class Group:
def __init__(self, complexity):
self.complexity = complexity
self.subjects = []
need_days, num_subjects, more = map(int, input().split())
groups = {}
for i in range(num_subjects):
subject = Subject(i + 1, *list(map(int, input().split())))
if subject.complexity not in groups:
groups[subject.complexity] = Group(subject.complexity)
groups[subject.complexity].subjects.append(subject)
groups = sorted(groups.values(), key = lambda group: group.complexity)
num_groups = len(groups)
def win(link):
print('YES')
schedule = need_days * [ None ]
while link:
subject = link.subject
subject.weight = link.weight
schedule[link.days - 1] = subject
link = link.previous
for subject in schedule:
print(subject.id, subject.weight)
import sys
sys.exit()
for pos, group in enumerate(groups):
#print(pos, '', ' '.join(map(str, group.subjects)))
if num_groups - pos >= need_days:
for subject in group.subjects:
for weight in range(subject.low, subject.high + 1):
subject.add_link(weight, Link(subject, weight, 1, None))
#print(pos, weight, 1)
for subject in group.subjects:
for i, link in enumerate(subject.links):
if link == None:
continue
if link.days == need_days:
win(link)
weight = subject.low + i
for next_weight in [ weight + more, weight * more ]:
max_pos = num_groups + link.days - need_days
for next_pos in range(pos + 1, max_pos + 1):
for next_subject in groups[next_pos].subjects:
if next_weight < next_subject.low:
continue
if next_weight > next_subject.high:
continue
next_subject.add_link(next_weight, Link(
next_subject, next_weight, link.days + 1, link))
#print(next_pos, next_weight, link.days + 1)
print('NO')
``` | instruction | 0 | 16,925 | 4 | 33,850 |
No | output | 1 | 16,925 | 4 | 33,851 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Yet another education system reform has been carried out in Berland recently. The innovations are as follows:
An academic year now consists of n days. Each day pupils study exactly one of m subjects, besides, each subject is studied for no more than one day. After the lessons of the i-th subject pupils get the home task that contains no less than ai and no more than bi exercises. Besides, each subject has a special attribute, the complexity (ci). A school can make its own timetable, considering the following conditions are satisfied:
* the timetable should contain the subjects in the order of the complexity's strict increasing;
* each day, except for the first one, the task should contain either k times more exercises, or more by k compared to the previous day (more formally: let's call the number of home task exercises in the i-th day as xi, then for each i (1 < i ≤ n): either xi = k + xi - 1 or xi = k·xi - 1 must be true);
* the total number of exercises in all home tasks should be maximal possible.
All limitations are separately set for each school.
It turned out that in many cases ai and bi reach 1016 (however, as the Berland Minister of Education is famous for his love to half-measures, the value of bi - ai doesn't exceed 100). That also happened in the Berland School №256. Nevertheless, you as the school's principal still have to work out the timetable for the next academic year...
Input
The first line contains three integers n, m, k (1 ≤ n ≤ m ≤ 50, 1 ≤ k ≤ 100) which represent the number of days in an academic year, the number of subjects and the k parameter correspondingly. Each of the following m lines contains the description of a subject as three integers ai, bi, ci (1 ≤ ai ≤ bi ≤ 1016, bi - ai ≤ 100, 1 ≤ ci ≤ 100) — two limitations to the number of exercises on the i-th subject and the complexity of the i-th subject, correspondingly. Distinct subjects can have the same complexity. The subjects are numbered with integers from 1 to m.
Please do not use the %lld specificator to read or write 64-bit numbers in С++. It is preferred to use the cin stream or the %I64d specificator.
Output
If no valid solution exists, print the single word "NO" (without the quotes). Otherwise, the first line should contain the word "YES" (without the quotes) and the next n lines should contain any timetable that satisfies all the conditions. The i + 1-th line should contain two positive integers: the number of the subject to study on the i-th day and the number of home task exercises given for this subject. The timetable should contain exactly n subjects.
Examples
Input
4 5 2
1 10 1
1 10 2
1 10 3
1 20 4
1 100 5
Output
YES
2 8
3 10
4 20
5 40
Input
3 4 3
1 3 1
2 4 4
2 3 3
2 2 2
Output
NO
Submitted Solution:
```
class Subject:
def __init__(self, id, low, high, complexity):
self.id = id
self.low = low
self.high = high
self.complexity = complexity
self.day_links = [ {} for i in range(high - low + 1) ]
def add_link(self, link):
days = link.days
links = self.day_links[link.weight - self.low]
if days not in links or links[days].total < link.total:
links[days] = link
class Link:
def __init__(self, subject, weight, total, days, previous):
self.subject = subject
self.weight = weight
self.total = total
self.days = days
self.previous = previous
class Group:
def __init__(self, complexity):
self.complexity = complexity
self.subjects = []
need_days, num_subjects, more = map(int, input().split())
groups = {}
for i in range(num_subjects):
subject = Subject(i + 1, *list(map(int, input().split())))
if subject.complexity not in groups:
groups[subject.complexity] = Group(subject.complexity)
groups[subject.complexity].subjects.append(subject)
groups = sorted(groups.values(), key = lambda group: group.complexity)
num_groups = len(groups)
best_link = None
for pos, group in enumerate(groups):
if num_groups - pos >= need_days:
for subject in group.subjects:
for weight in range(subject.low, subject.high + 1):
subject.add_link(Link(subject, weight, weight, 1, None))
for subject in group.subjects:
for i, links in enumerate(subject.day_links):
weight = subject.low + i
for days, link in links.items():
if days == need_days:
if not best_link or best_link.total < link.total:
best_link = link
continue
for next_weight in [ weight + more, weight * more ]:
max_pos = num_groups + days - need_days
for next_pos in range(pos + 1, max_pos + 1):
for next_subject in groups[next_pos].subjects:
if next_weight < next_subject.low:
continue
if next_weight > next_subject.high:
continue
next_subject.add_link(Link(
next_subject, next_weight,
next_weight + link.total, days + 1, link))
if best_link:
print('YES')
schedule = need_days * [ None ]
while link:
subject = link.subject
subject.weight = link.weight
schedule[link.days - 1] = subject
link = link.previous
for subject in schedule:
print(subject.id, subject.weight)
import sys
sys.exit()
else:
print('NO')
``` | instruction | 0 | 16,926 | 4 | 33,852 |
No | output | 1 | 16,926 | 4 | 33,853 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is an automatic door at the entrance of a factory. The door works in the following way:
* when one or several people come to the door and it is closed, the door immediately opens automatically and all people immediately come inside,
* when one or several people come to the door and it is open, all people immediately come inside,
* opened door immediately closes in d seconds after its opening,
* if the door is closing and one or several people are coming to the door at the same moment, then all of them will have enough time to enter and only after that the door will close.
For example, if d = 3 and four people are coming at four different moments of time t1 = 4, t2 = 7, t3 = 9 and t4 = 13 then the door will open three times: at moments 4, 9 and 13. It will close at moments 7 and 12.
It is known that n employees will enter at moments a, 2·a, 3·a, ..., n·a (the value a is positive integer). Also m clients will enter at moments t1, t2, ..., tm.
Write program to find the number of times the automatic door will open. Assume that the door is initially closed.
Input
The first line contains four integers n, m, a and d (1 ≤ n, a ≤ 109, 1 ≤ m ≤ 105, 1 ≤ d ≤ 1018) — the number of the employees, the number of the clients, the moment of time when the first employee will come and the period of time in which the door closes.
The second line contains integer sequence t1, t2, ..., tm (1 ≤ ti ≤ 1018) — moments of time when clients will come. The values ti are given in non-decreasing order.
Output
Print the number of times the door will open.
Examples
Input
1 1 3 4
7
Output
1
Input
4 3 4 2
7 9 11
Output
4
Note
In the first example the only employee will come at moment 3. At this moment the door will open and will stay open until the moment 7. At the same moment of time the client will come, so at first he will enter and only after it the door will close. Thus the door will open one time.
Submitted Solution:
```
x=input()
z=input()
y=x.split()
n=int(y[0])
clients=z.split()
a=int(y[2])
d=int(y[3])
m=int(y[1])
client=int(clients[0])
employe=a
j=1
lenght=0
flag=1
mine1=0
mine=0
e=n
cl=m
k=2
print(len(clients))
while k in range(2,(m+n)) :
if cl==0 and e==0:
break
if cl!=0:
client=int(clients[0])
if cl==0 and mine<employe :
mine=employe+d
elif e==0 and mine<client :
mine=client+d
elif (cl!=0 and mine<client) and (e!=0 and mine<employe):
mine=min(client,employe)+d
if e!=0 and mine>=employe:
employe=k*a
k+=1
e-=1
if cl!=0 and mine>=client:
del(clients[0])
cl-=1
if (mine!=mine1) and (cl!=0 or e!=0):
flag+=1
mine1=mine
print(flag)
``` | instruction | 0 | 17,372 | 4 | 34,744 |
No | output | 1 | 17,372 | 4 | 34,745 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is an automatic door at the entrance of a factory. The door works in the following way:
* when one or several people come to the door and it is closed, the door immediately opens automatically and all people immediately come inside,
* when one or several people come to the door and it is open, all people immediately come inside,
* opened door immediately closes in d seconds after its opening,
* if the door is closing and one or several people are coming to the door at the same moment, then all of them will have enough time to enter and only after that the door will close.
For example, if d = 3 and four people are coming at four different moments of time t1 = 4, t2 = 7, t3 = 9 and t4 = 13 then the door will open three times: at moments 4, 9 and 13. It will close at moments 7 and 12.
It is known that n employees will enter at moments a, 2·a, 3·a, ..., n·a (the value a is positive integer). Also m clients will enter at moments t1, t2, ..., tm.
Write program to find the number of times the automatic door will open. Assume that the door is initially closed.
Input
The first line contains four integers n, m, a and d (1 ≤ n, a ≤ 109, 1 ≤ m ≤ 105, 1 ≤ d ≤ 1018) — the number of the employees, the number of the clients, the moment of time when the first employee will come and the period of time in which the door closes.
The second line contains integer sequence t1, t2, ..., tm (1 ≤ ti ≤ 1018) — moments of time when clients will come. The values ti are given in non-decreasing order.
Output
Print the number of times the door will open.
Examples
Input
1 1 3 4
7
Output
1
Input
4 3 4 2
7 9 11
Output
4
Note
In the first example the only employee will come at moment 3. At this moment the door will open and will stay open until the moment 7. At the same moment of time the client will come, so at first he will enter and only after it the door will close. Thus the door will open one time.
Submitted Solution:
```
n,m,a,d=list(map(int,input().split()))
ans,t,e=0,0,0
tt=d//a+1
tlist=list(map(int,input().split()))
for i in range(m):
x=tlist[i]
if t < n:
dd=min((x-1)//a,n)
if dd > t:
ans+=(dd-t-1)//tt+1
t+=((dd-t-1)//tt+1)*tt
e=min((t-tt+1),n)*a+d
t=min(t,n)
if e<x:
ans+=1
e=x+d
t=min(e//a,n)
if t < n:
ans+=(n-t+1)//t +1
print(ans)
``` | instruction | 0 | 17,374 | 4 | 34,748 |
No | output | 1 | 17,374 | 4 | 34,749 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is an automatic door at the entrance of a factory. The door works in the following way:
* when one or several people come to the door and it is closed, the door immediately opens automatically and all people immediately come inside,
* when one or several people come to the door and it is open, all people immediately come inside,
* opened door immediately closes in d seconds after its opening,
* if the door is closing and one or several people are coming to the door at the same moment, then all of them will have enough time to enter and only after that the door will close.
For example, if d = 3 and four people are coming at four different moments of time t1 = 4, t2 = 7, t3 = 9 and t4 = 13 then the door will open three times: at moments 4, 9 and 13. It will close at moments 7 and 12.
It is known that n employees will enter at moments a, 2·a, 3·a, ..., n·a (the value a is positive integer). Also m clients will enter at moments t1, t2, ..., tm.
Write program to find the number of times the automatic door will open. Assume that the door is initially closed.
Input
The first line contains four integers n, m, a and d (1 ≤ n, a ≤ 109, 1 ≤ m ≤ 105, 1 ≤ d ≤ 1018) — the number of the employees, the number of the clients, the moment of time when the first employee will come and the period of time in which the door closes.
The second line contains integer sequence t1, t2, ..., tm (1 ≤ ti ≤ 1018) — moments of time when clients will come. The values ti are given in non-decreasing order.
Output
Print the number of times the door will open.
Examples
Input
1 1 3 4
7
Output
1
Input
4 3 4 2
7 9 11
Output
4
Note
In the first example the only employee will come at moment 3. At this moment the door will open and will stay open until the moment 7. At the same moment of time the client will come, so at first he will enter and only after it the door will close. Thus the door will open one time.
Submitted Solution:
```
import sys
import math
def readIntLine():
return [int(n) for n in next(sys.stdin).strip().split()]
N, M, A, D = readIntLine()
times = readIntLine()
max_e_time = N * A
c = 0
count = 0
def catchUp(t):
global c, count
first_uncaught_e = math.ceil((c + 1) / A)
if first_uncaught_e > N:
return
first_uncaught_e_t = first_uncaught_e * A
last_uncaught_e = min((t // A), N)
last_uncaught_e_t = last_uncaught_e * A
if first_uncaught_e_t <= t:
total_employees = (last_uncaught_e - first_uncaught_e) + 1
per_door = math.ceil(D / A)
count += math.ceil(total_employees / per_door)
fully_used_doors = total_employees // per_door
unfully_used = total_employees % per_door
if unfully_used:
last_door_e = first_uncaught_e + (fully_used_doors * per_door + 1)
else:
last_door_e = first_uncaught_e + fully_used_doors - 1
last_d_time = last_door_e * A
c = max(c, last_d_time + D)
for t in times:
catchUp(t)
if t <= c:
continue
c = t + D
count += 1
catchUp(max_e_time)
print(count)
``` | instruction | 0 | 17,375 | 4 | 34,750 |
No | output | 1 | 17,375 | 4 | 34,751 |
Provide a correct Python 3 solution for this coding contest problem.
Based on the information of the time when study started and the time when study ended, check whether the total time studied in one day is t or more, and if not, create a program to find the shortage time. Time is one unit per hour, and minutes and seconds are not considered. The time is expressed in 24-hour notation in 1-hour units.
Enter the target time of study per day and the information of the time actually studied (number of studies n, start time s and end time f of each study), and check whether the total study time has reached the target. If it has reached, write "OK", and if it has not reached, write a program that outputs the insufficient time. However, the study time spent on each will not overlap.
Example: Target time | Study time | Judgment
--- | --- | ---
10 hours | 6:00 to 11:00 = 5 hours
12:00 to 15:00 = 3 hours
18:00 to 22:00 = 4 hours | OK
14 hours | 6:00 to 11:00 = 5 hours
13:00 to 20:00 = 7 hours
| 2 hours shortage
Input example
Ten
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output example
OK
2
input
Given a sequence of multiple datasets. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
t
n
s1 f1
s2 f2
::
sn fn
The first line gives the target time of the day t (0 ≤ t ≤ 22), and the second line gives the number of studies n (1 ≤ n ≤ 10). The following n lines are given the start time si and end time f (6 ≤ si, fi ≤ 22) of the i-th study.
The number of datasets does not exceed 100.
output
Outputs OK or missing time on one line for each dataset.
Example
Input
10
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output
OK
2 | instruction | 0 | 17,620 | 4 | 35,240 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
"""
Time to Study
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0238
"""
import sys
def solve(t):
n = int(input())
for _ in range(n):
s, f = map(int, input().split())
t -= (f-s)
return 'OK' if t <= 0 else t
def main(args):
while True:
t = int(input())
if t == 0:
break
ans = solve(t)
print(ans)
if __name__ == '__main__':
main(sys.argv[1:])
``` | output | 1 | 17,620 | 4 | 35,241 |
Provide a correct Python 3 solution for this coding contest problem.
Based on the information of the time when study started and the time when study ended, check whether the total time studied in one day is t or more, and if not, create a program to find the shortage time. Time is one unit per hour, and minutes and seconds are not considered. The time is expressed in 24-hour notation in 1-hour units.
Enter the target time of study per day and the information of the time actually studied (number of studies n, start time s and end time f of each study), and check whether the total study time has reached the target. If it has reached, write "OK", and if it has not reached, write a program that outputs the insufficient time. However, the study time spent on each will not overlap.
Example: Target time | Study time | Judgment
--- | --- | ---
10 hours | 6:00 to 11:00 = 5 hours
12:00 to 15:00 = 3 hours
18:00 to 22:00 = 4 hours | OK
14 hours | 6:00 to 11:00 = 5 hours
13:00 to 20:00 = 7 hours
| 2 hours shortage
Input example
Ten
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output example
OK
2
input
Given a sequence of multiple datasets. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
t
n
s1 f1
s2 f2
::
sn fn
The first line gives the target time of the day t (0 ≤ t ≤ 22), and the second line gives the number of studies n (1 ≤ n ≤ 10). The following n lines are given the start time si and end time f (6 ≤ si, fi ≤ 22) of the i-th study.
The number of datasets does not exceed 100.
output
Outputs OK or missing time on one line for each dataset.
Example
Input
10
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output
OK
2 | instruction | 0 | 17,621 | 4 | 35,242 |
"Correct Solution:
```
import sys,os
while 1:
t = int(input())
if t == 0: break
n = int(input())
sf = [list(map(int, input().split())) for _ in range(n)]
time = 0
for i in sf:
start,end = i
if start > end:
time += end - (start-24)
else:
time += end - start
if time >= t:
print("OK")
else:
print(t-time)
``` | output | 1 | 17,621 | 4 | 35,243 |
Provide a correct Python 3 solution for this coding contest problem.
Based on the information of the time when study started and the time when study ended, check whether the total time studied in one day is t or more, and if not, create a program to find the shortage time. Time is one unit per hour, and minutes and seconds are not considered. The time is expressed in 24-hour notation in 1-hour units.
Enter the target time of study per day and the information of the time actually studied (number of studies n, start time s and end time f of each study), and check whether the total study time has reached the target. If it has reached, write "OK", and if it has not reached, write a program that outputs the insufficient time. However, the study time spent on each will not overlap.
Example: Target time | Study time | Judgment
--- | --- | ---
10 hours | 6:00 to 11:00 = 5 hours
12:00 to 15:00 = 3 hours
18:00 to 22:00 = 4 hours | OK
14 hours | 6:00 to 11:00 = 5 hours
13:00 to 20:00 = 7 hours
| 2 hours shortage
Input example
Ten
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output example
OK
2
input
Given a sequence of multiple datasets. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
t
n
s1 f1
s2 f2
::
sn fn
The first line gives the target time of the day t (0 ≤ t ≤ 22), and the second line gives the number of studies n (1 ≤ n ≤ 10). The following n lines are given the start time si and end time f (6 ≤ si, fi ≤ 22) of the i-th study.
The number of datasets does not exceed 100.
output
Outputs OK or missing time on one line for each dataset.
Example
Input
10
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output
OK
2 | instruction | 0 | 17,622 | 4 | 35,244 |
"Correct Solution:
```
# Aizu Problem 0238: Time to Study
import sys, math, os, bisect
# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
sys.stdin = open("sample-input.txt", "rt")
while True:
T = int(input())
if T == 0:
break
n = int(input())
for _ in range(n):
start, end = [int(_) for _ in input().split()]
T -= (end - start)
print("OK" if T <= 0 else T)
``` | output | 1 | 17,622 | 4 | 35,245 |
Provide a correct Python 3 solution for this coding contest problem.
Based on the information of the time when study started and the time when study ended, check whether the total time studied in one day is t or more, and if not, create a program to find the shortage time. Time is one unit per hour, and minutes and seconds are not considered. The time is expressed in 24-hour notation in 1-hour units.
Enter the target time of study per day and the information of the time actually studied (number of studies n, start time s and end time f of each study), and check whether the total study time has reached the target. If it has reached, write "OK", and if it has not reached, write a program that outputs the insufficient time. However, the study time spent on each will not overlap.
Example: Target time | Study time | Judgment
--- | --- | ---
10 hours | 6:00 to 11:00 = 5 hours
12:00 to 15:00 = 3 hours
18:00 to 22:00 = 4 hours | OK
14 hours | 6:00 to 11:00 = 5 hours
13:00 to 20:00 = 7 hours
| 2 hours shortage
Input example
Ten
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output example
OK
2
input
Given a sequence of multiple datasets. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
t
n
s1 f1
s2 f2
::
sn fn
The first line gives the target time of the day t (0 ≤ t ≤ 22), and the second line gives the number of studies n (1 ≤ n ≤ 10). The following n lines are given the start time si and end time f (6 ≤ si, fi ≤ 22) of the i-th study.
The number of datasets does not exceed 100.
output
Outputs OK or missing time on one line for each dataset.
Example
Input
10
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output
OK
2 | instruction | 0 | 17,623 | 4 | 35,246 |
"Correct Solution:
```
while True:
t = int(input())
if t == 0:
break
n = int(input())
ans = 0
for _ in range(n):
s, f = map(int, input().split())
ans += f - s
if ans >= t:
print('OK')
else:
print(t - ans)
``` | output | 1 | 17,623 | 4 | 35,247 |
Provide a correct Python 3 solution for this coding contest problem.
Based on the information of the time when study started and the time when study ended, check whether the total time studied in one day is t or more, and if not, create a program to find the shortage time. Time is one unit per hour, and minutes and seconds are not considered. The time is expressed in 24-hour notation in 1-hour units.
Enter the target time of study per day and the information of the time actually studied (number of studies n, start time s and end time f of each study), and check whether the total study time has reached the target. If it has reached, write "OK", and if it has not reached, write a program that outputs the insufficient time. However, the study time spent on each will not overlap.
Example: Target time | Study time | Judgment
--- | --- | ---
10 hours | 6:00 to 11:00 = 5 hours
12:00 to 15:00 = 3 hours
18:00 to 22:00 = 4 hours | OK
14 hours | 6:00 to 11:00 = 5 hours
13:00 to 20:00 = 7 hours
| 2 hours shortage
Input example
Ten
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output example
OK
2
input
Given a sequence of multiple datasets. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
t
n
s1 f1
s2 f2
::
sn fn
The first line gives the target time of the day t (0 ≤ t ≤ 22), and the second line gives the number of studies n (1 ≤ n ≤ 10). The following n lines are given the start time si and end time f (6 ≤ si, fi ≤ 22) of the i-th study.
The number of datasets does not exceed 100.
output
Outputs OK or missing time on one line for each dataset.
Example
Input
10
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output
OK
2 | instruction | 0 | 17,624 | 4 | 35,248 |
"Correct Solution:
```
while 1:
t = int(input())
if t == 0:
break
n = int(input())
ans = 0
for _ in range(n):
s, f = map(int, input().split())
ans += f - s
if ans >= t:
print("OK")
else:
print(t - ans)
``` | output | 1 | 17,624 | 4 | 35,249 |
Provide a correct Python 3 solution for this coding contest problem.
Based on the information of the time when study started and the time when study ended, check whether the total time studied in one day is t or more, and if not, create a program to find the shortage time. Time is one unit per hour, and minutes and seconds are not considered. The time is expressed in 24-hour notation in 1-hour units.
Enter the target time of study per day and the information of the time actually studied (number of studies n, start time s and end time f of each study), and check whether the total study time has reached the target. If it has reached, write "OK", and if it has not reached, write a program that outputs the insufficient time. However, the study time spent on each will not overlap.
Example: Target time | Study time | Judgment
--- | --- | ---
10 hours | 6:00 to 11:00 = 5 hours
12:00 to 15:00 = 3 hours
18:00 to 22:00 = 4 hours | OK
14 hours | 6:00 to 11:00 = 5 hours
13:00 to 20:00 = 7 hours
| 2 hours shortage
Input example
Ten
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output example
OK
2
input
Given a sequence of multiple datasets. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
t
n
s1 f1
s2 f2
::
sn fn
The first line gives the target time of the day t (0 ≤ t ≤ 22), and the second line gives the number of studies n (1 ≤ n ≤ 10). The following n lines are given the start time si and end time f (6 ≤ si, fi ≤ 22) of the i-th study.
The number of datasets does not exceed 100.
output
Outputs OK or missing time on one line for each dataset.
Example
Input
10
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output
OK
2 | instruction | 0 | 17,625 | 4 | 35,250 |
"Correct Solution:
```
#標準入力をし0だった場合はループを抜ける
while True:
num = int(input())
if num == 0:break
else:
num1 = int(input())
kei = 0
#勉強時間の合計を計算する
for _ in range(num1):
a,b = map(int,input().split())
kei += b - a
#勉強時間が足りてたら"OK"足りてなかったら足りない時間を出力する
if num <= kei:print("OK")
else:print(num - kei)
``` | output | 1 | 17,625 | 4 | 35,251 |
Provide a correct Python 3 solution for this coding contest problem.
Based on the information of the time when study started and the time when study ended, check whether the total time studied in one day is t or more, and if not, create a program to find the shortage time. Time is one unit per hour, and minutes and seconds are not considered. The time is expressed in 24-hour notation in 1-hour units.
Enter the target time of study per day and the information of the time actually studied (number of studies n, start time s and end time f of each study), and check whether the total study time has reached the target. If it has reached, write "OK", and if it has not reached, write a program that outputs the insufficient time. However, the study time spent on each will not overlap.
Example: Target time | Study time | Judgment
--- | --- | ---
10 hours | 6:00 to 11:00 = 5 hours
12:00 to 15:00 = 3 hours
18:00 to 22:00 = 4 hours | OK
14 hours | 6:00 to 11:00 = 5 hours
13:00 to 20:00 = 7 hours
| 2 hours shortage
Input example
Ten
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output example
OK
2
input
Given a sequence of multiple datasets. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
t
n
s1 f1
s2 f2
::
sn fn
The first line gives the target time of the day t (0 ≤ t ≤ 22), and the second line gives the number of studies n (1 ≤ n ≤ 10). The following n lines are given the start time si and end time f (6 ≤ si, fi ≤ 22) of the i-th study.
The number of datasets does not exceed 100.
output
Outputs OK or missing time on one line for each dataset.
Example
Input
10
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output
OK
2 | instruction | 0 | 17,626 | 4 | 35,252 |
"Correct Solution:
```
while 1:
t = int(input())
if t == 0:break
n = int(input())
x = 0
for i in range(n):
x += (lambda lst:lst[-1] - lst[0])(list(map(int,input().split())))
print('OK' if t<=x else (t-x))
``` | output | 1 | 17,626 | 4 | 35,253 |
Provide a correct Python 3 solution for this coding contest problem.
Based on the information of the time when study started and the time when study ended, check whether the total time studied in one day is t or more, and if not, create a program to find the shortage time. Time is one unit per hour, and minutes and seconds are not considered. The time is expressed in 24-hour notation in 1-hour units.
Enter the target time of study per day and the information of the time actually studied (number of studies n, start time s and end time f of each study), and check whether the total study time has reached the target. If it has reached, write "OK", and if it has not reached, write a program that outputs the insufficient time. However, the study time spent on each will not overlap.
Example: Target time | Study time | Judgment
--- | --- | ---
10 hours | 6:00 to 11:00 = 5 hours
12:00 to 15:00 = 3 hours
18:00 to 22:00 = 4 hours | OK
14 hours | 6:00 to 11:00 = 5 hours
13:00 to 20:00 = 7 hours
| 2 hours shortage
Input example
Ten
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output example
OK
2
input
Given a sequence of multiple datasets. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
t
n
s1 f1
s2 f2
::
sn fn
The first line gives the target time of the day t (0 ≤ t ≤ 22), and the second line gives the number of studies n (1 ≤ n ≤ 10). The following n lines are given the start time si and end time f (6 ≤ si, fi ≤ 22) of the i-th study.
The number of datasets does not exceed 100.
output
Outputs OK or missing time on one line for each dataset.
Example
Input
10
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output
OK
2 | instruction | 0 | 17,627 | 4 | 35,254 |
"Correct Solution:
```
while 1:
a=int(input())
if a == 0: break
b=int(input())
d=0
for _ in range(b):
c=list(map(int,input().split()))
d+=c[1]-c[0]
print(a-d if a>d else 'OK')
``` | output | 1 | 17,627 | 4 | 35,255 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Based on the information of the time when study started and the time when study ended, check whether the total time studied in one day is t or more, and if not, create a program to find the shortage time. Time is one unit per hour, and minutes and seconds are not considered. The time is expressed in 24-hour notation in 1-hour units.
Enter the target time of study per day and the information of the time actually studied (number of studies n, start time s and end time f of each study), and check whether the total study time has reached the target. If it has reached, write "OK", and if it has not reached, write a program that outputs the insufficient time. However, the study time spent on each will not overlap.
Example: Target time | Study time | Judgment
--- | --- | ---
10 hours | 6:00 to 11:00 = 5 hours
12:00 to 15:00 = 3 hours
18:00 to 22:00 = 4 hours | OK
14 hours | 6:00 to 11:00 = 5 hours
13:00 to 20:00 = 7 hours
| 2 hours shortage
Input example
Ten
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output example
OK
2
input
Given a sequence of multiple datasets. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
t
n
s1 f1
s2 f2
::
sn fn
The first line gives the target time of the day t (0 ≤ t ≤ 22), and the second line gives the number of studies n (1 ≤ n ≤ 10). The following n lines are given the start time si and end time f (6 ≤ si, fi ≤ 22) of the i-th study.
The number of datasets does not exceed 100.
output
Outputs OK or missing time on one line for each dataset.
Example
Input
10
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output
OK
2
Submitted Solution:
```
while True:
a = int(input())
if a == 0:
break
b = int(input())
for i in range(b):
c,d = map(int,input().split())
a -= d-c
if a <= 0:
print("OK")
else:
print(a)
``` | instruction | 0 | 17,628 | 4 | 35,256 |
Yes | output | 1 | 17,628 | 4 | 35,257 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Based on the information of the time when study started and the time when study ended, check whether the total time studied in one day is t or more, and if not, create a program to find the shortage time. Time is one unit per hour, and minutes and seconds are not considered. The time is expressed in 24-hour notation in 1-hour units.
Enter the target time of study per day and the information of the time actually studied (number of studies n, start time s and end time f of each study), and check whether the total study time has reached the target. If it has reached, write "OK", and if it has not reached, write a program that outputs the insufficient time. However, the study time spent on each will not overlap.
Example: Target time | Study time | Judgment
--- | --- | ---
10 hours | 6:00 to 11:00 = 5 hours
12:00 to 15:00 = 3 hours
18:00 to 22:00 = 4 hours | OK
14 hours | 6:00 to 11:00 = 5 hours
13:00 to 20:00 = 7 hours
| 2 hours shortage
Input example
Ten
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output example
OK
2
input
Given a sequence of multiple datasets. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
t
n
s1 f1
s2 f2
::
sn fn
The first line gives the target time of the day t (0 ≤ t ≤ 22), and the second line gives the number of studies n (1 ≤ n ≤ 10). The following n lines are given the start time si and end time f (6 ≤ si, fi ≤ 22) of the i-th study.
The number of datasets does not exceed 100.
output
Outputs OK or missing time on one line for each dataset.
Example
Input
10
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output
OK
2
Submitted Solution:
```
# AOJ 0238 Time to Study
# Python3 2018.6.25 bal4u
while 1:
t = int(input())
if t == 0: break
n = int(input())
sm = 0
for i in range(n):
s, f = map(int, input().split())
sm += f-s
print("OK" if sm >= t else t - sm)
``` | instruction | 0 | 17,629 | 4 | 35,258 |
Yes | output | 1 | 17,629 | 4 | 35,259 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Based on the information of the time when study started and the time when study ended, check whether the total time studied in one day is t or more, and if not, create a program to find the shortage time. Time is one unit per hour, and minutes and seconds are not considered. The time is expressed in 24-hour notation in 1-hour units.
Enter the target time of study per day and the information of the time actually studied (number of studies n, start time s and end time f of each study), and check whether the total study time has reached the target. If it has reached, write "OK", and if it has not reached, write a program that outputs the insufficient time. However, the study time spent on each will not overlap.
Example: Target time | Study time | Judgment
--- | --- | ---
10 hours | 6:00 to 11:00 = 5 hours
12:00 to 15:00 = 3 hours
18:00 to 22:00 = 4 hours | OK
14 hours | 6:00 to 11:00 = 5 hours
13:00 to 20:00 = 7 hours
| 2 hours shortage
Input example
Ten
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output example
OK
2
input
Given a sequence of multiple datasets. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
t
n
s1 f1
s2 f2
::
sn fn
The first line gives the target time of the day t (0 ≤ t ≤ 22), and the second line gives the number of studies n (1 ≤ n ≤ 10). The following n lines are given the start time si and end time f (6 ≤ si, fi ≤ 22) of the i-th study.
The number of datasets does not exceed 100.
output
Outputs OK or missing time on one line for each dataset.
Example
Input
10
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output
OK
2
Submitted Solution:
```
while True:
t = int(input())
if t==0:
break
n = int(input())
hour = 0
for i in range(n):
s,f = map(int,input().split())
hour += (f-s)
if hour >= t:
print("OK")
else:
print(t-hour)
``` | instruction | 0 | 17,630 | 4 | 35,260 |
Yes | output | 1 | 17,630 | 4 | 35,261 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Based on the information of the time when study started and the time when study ended, check whether the total time studied in one day is t or more, and if not, create a program to find the shortage time. Time is one unit per hour, and minutes and seconds are not considered. The time is expressed in 24-hour notation in 1-hour units.
Enter the target time of study per day and the information of the time actually studied (number of studies n, start time s and end time f of each study), and check whether the total study time has reached the target. If it has reached, write "OK", and if it has not reached, write a program that outputs the insufficient time. However, the study time spent on each will not overlap.
Example: Target time | Study time | Judgment
--- | --- | ---
10 hours | 6:00 to 11:00 = 5 hours
12:00 to 15:00 = 3 hours
18:00 to 22:00 = 4 hours | OK
14 hours | 6:00 to 11:00 = 5 hours
13:00 to 20:00 = 7 hours
| 2 hours shortage
Input example
Ten
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output example
OK
2
input
Given a sequence of multiple datasets. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
t
n
s1 f1
s2 f2
::
sn fn
The first line gives the target time of the day t (0 ≤ t ≤ 22), and the second line gives the number of studies n (1 ≤ n ≤ 10). The following n lines are given the start time si and end time f (6 ≤ si, fi ≤ 22) of the i-th study.
The number of datasets does not exceed 100.
output
Outputs OK or missing time on one line for each dataset.
Example
Input
10
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output
OK
2
Submitted Solution:
```
while 1:
t=int(input())
if t==0:break
n=int(input())
for i in range(n):
s,f=map(int,input().split())
t-=f-s
if t<1:print("OK")
else:print(t)
``` | instruction | 0 | 17,631 | 4 | 35,262 |
Yes | output | 1 | 17,631 | 4 | 35,263 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Based on the information of the time when study started and the time when study ended, check whether the total time studied in one day is t or more, and if not, create a program to find the shortage time. Time is one unit per hour, and minutes and seconds are not considered. The time is expressed in 24-hour notation in 1-hour units.
Enter the target time of study per day and the information of the time actually studied (number of studies n, start time s and end time f of each study), and check whether the total study time has reached the target. If it has reached, write "OK", and if it has not reached, write a program that outputs the insufficient time. However, the study time spent on each will not overlap.
Example: Target time | Study time | Judgment
--- | --- | ---
10 hours | 6:00 to 11:00 = 5 hours
12:00 to 15:00 = 3 hours
18:00 to 22:00 = 4 hours | OK
14 hours | 6:00 to 11:00 = 5 hours
13:00 to 20:00 = 7 hours
| 2 hours shortage
Input example
Ten
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output example
OK
2
input
Given a sequence of multiple datasets. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
t
n
s1 f1
s2 f2
::
sn fn
The first line gives the target time of the day t (0 ≤ t ≤ 22), and the second line gives the number of studies n (1 ≤ n ≤ 10). The following n lines are given the start time si and end time f (6 ≤ si, fi ≤ 22) of the i-th study.
The number of datasets does not exceed 100.
output
Outputs OK or missing time on one line for each dataset.
Example
Input
10
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output
OK
2
Submitted Solution:
```
t=int(input())
n=int(input())
b=0
for i in range(n):
s,f=map(int,input().split())
a=f-s
b+=a
if t<=b:
print("OK")
else:
print(t-b)
``` | instruction | 0 | 17,632 | 4 | 35,264 |
No | output | 1 | 17,632 | 4 | 35,265 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Based on the information of the time when study started and the time when study ended, check whether the total time studied in one day is t or more, and if not, create a program to find the shortage time. Time is one unit per hour, and minutes and seconds are not considered. The time is expressed in 24-hour notation in 1-hour units.
Enter the target time of study per day and the information of the time actually studied (number of studies n, start time s and end time f of each study), and check whether the total study time has reached the target. If it has reached, write "OK", and if it has not reached, write a program that outputs the insufficient time. However, the study time spent on each will not overlap.
Example: Target time | Study time | Judgment
--- | --- | ---
10 hours | 6:00 to 11:00 = 5 hours
12:00 to 15:00 = 3 hours
18:00 to 22:00 = 4 hours | OK
14 hours | 6:00 to 11:00 = 5 hours
13:00 to 20:00 = 7 hours
| 2 hours shortage
Input example
Ten
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output example
OK
2
input
Given a sequence of multiple datasets. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
t
n
s1 f1
s2 f2
::
sn fn
The first line gives the target time of the day t (0 ≤ t ≤ 22), and the second line gives the number of studies n (1 ≤ n ≤ 10). The following n lines are given the start time si and end time f (6 ≤ si, fi ≤ 22) of the i-th study.
The number of datasets does not exceed 100.
output
Outputs OK or missing time on one line for each dataset.
Example
Input
10
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output
OK
2
Submitted Solution:
```
while True:
t=int(input())
n=int(input())
b=0
if t == 0:
break
for i in range(n):
s,f=map(int,input().split())
a=f-s
b+=a
if t<=b:
print("OK")
else:
print(t-b)
``` | instruction | 0 | 17,633 | 4 | 35,266 |
No | output | 1 | 17,633 | 4 | 35,267 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Based on the information of the time when study started and the time when study ended, check whether the total time studied in one day is t or more, and if not, create a program to find the shortage time. Time is one unit per hour, and minutes and seconds are not considered. The time is expressed in 24-hour notation in 1-hour units.
Enter the target time of study per day and the information of the time actually studied (number of studies n, start time s and end time f of each study), and check whether the total study time has reached the target. If it has reached, write "OK", and if it has not reached, write a program that outputs the insufficient time. However, the study time spent on each will not overlap.
Example: Target time | Study time | Judgment
--- | --- | ---
10 hours | 6:00 to 11:00 = 5 hours
12:00 to 15:00 = 3 hours
18:00 to 22:00 = 4 hours | OK
14 hours | 6:00 to 11:00 = 5 hours
13:00 to 20:00 = 7 hours
| 2 hours shortage
Input example
Ten
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output example
OK
2
input
Given a sequence of multiple datasets. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:
t
n
s1 f1
s2 f2
::
sn fn
The first line gives the target time of the day t (0 ≤ t ≤ 22), and the second line gives the number of studies n (1 ≤ n ≤ 10). The following n lines are given the start time si and end time f (6 ≤ si, fi ≤ 22) of the i-th study.
The number of datasets does not exceed 100.
output
Outputs OK or missing time on one line for each dataset.
Example
Input
10
3
6 11
12 15
18 22
14
2
6 11
13 20
0
Output
OK
2
Submitted Solution:
```
while 1:
t = int(input())
if t == 0:break
n = int(input())
x = 0
for i in range(n):
x += (lambda lst:lst[-1] - lst[0])(list(map(int,input().split())))
print('OK' if t<=x else (t-x))
while 1:
t = int(input())
if t == 0:break
#n = int(input())
#x = 0
#for i in range(n):
t -= sum(map(lambda lst:lst[-1] - lst[0],[ list(map(int,input().split())) for i in range(int(input())) ]))
print('OK' if t<=0 else t)
``` | instruction | 0 | 17,634 | 4 | 35,268 |
No | output | 1 | 17,634 | 4 | 35,269 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Gleb is a famous competitive programming teacher from Innopolis. He is planning a trip to N programming camps in the nearest future. Each camp will be held in a different country. For each of them, Gleb needs to apply for a visa.
For each of these trips Gleb knows three integers: the number of the first day of the trip si, the length of the trip in days leni, and the number of days ti this country's consulate will take to process a visa application and stick a visa in a passport. Gleb has P (1 ≤ P ≤ 2) valid passports and is able to decide which visa he wants to put in which passport.
For each trip, Gleb will have a flight to that country early in the morning of the day si and will return back late in the evening of the day si + leni - 1.
To apply for a visa on the day d, Gleb needs to be in Innopolis in the middle of this day. So he can't apply for a visa while he is on a trip, including the first and the last days. If a trip starts the next day after the end of the other one, Gleb can't apply for a visa between them as well. The earliest Gleb can apply for a visa is day 1.
After applying for a visa of country i on day d, Gleb will get his passport back in the middle of the day d + ti. Consulates use delivery services, so Gleb can get his passport back even if he is not in Innopolis on this day. Gleb can apply for another visa on the same day he received his passport back, if he is in Innopolis this day.
Gleb will not be able to start his trip on day si if he doesn't has a passport with a visa for the corresponding country in the morning of day si. In particular, the passport should not be in another country's consulate for visa processing.
Help Gleb to decide which visas he needs to receive in which passport, and when he should apply for each visa.
Input
In the first line of the input there are two integers N (1 ≤ N ≤ 22) and P (1 ≤ P ≤ 2)—the number of trips and the number of passports Gleb has, respectively.
The next N lines describe Gleb's trips. Each line contains three positive integers si, leni, ti (1 ≤ si, leni, ti ≤ 109)—the first day of the trip, the length of the trip and number of days the consulate of this country needs to process a visa application. It is guaranteed that no two trips intersect.
Output
If it is impossible to get all visas on time, just print "NO" (quotes for clarity). Otherwise, print "YES" and N lines describing trips. For each trip, first print number of the passport Gleb should put this country's visa in, and then print number of the day he should apply for it. Print trips in the same order as they appear in the input. Days are numbered from 1, starting with tomorrow—the first day you can apply for a visa. Passports are numbered from 1 to P.
If there are several possible answers, print any of them.
Examples
Input
2 1
3 1 1
6 1 1
Output
YES
1 1
1 4
Input
3 1
13 2 2
7 3 1
19 3 4
Output
YES
1 10
1 1
1 2
Input
7 2
15 1 1
14 1 1
18 1 1
21 1 1
9 4 6
22 2 5
5 4 3
Output
YES
2 13
1 1
1 16
1 19
1 2
2 16
2 1
Input
3 1
7 3 1
13 2 3
19 3 4
Output
NO
Note
Examples with answer "YES" are depicted below.
Each cell of the stripe represents a single day. Rectangles represent trips, each trip starts in the morning and ends in the evening. Rectangles with angled corners represent visa applications. Each application starts in the middle of a day and ends ti days after. The trip and the visa application for the same country have the same color.
In examples with two passports, visa applications and trips depicted above the time stripe are made using the first passport, visa applications and trips depicted below the time stripe are made using the second passport.
Example 1:
<image>
Example 2:
<image>
Example 3:
<image>
Submitted Solution:
```
N , P = input().split()
N = int(N)
P = int(P)
c = []
d = []
for i in range(N):
s,l,t = input().split()
c.append({'s': int(s), 'l': int(l), 't':int(t), 'i':i})
sorted(c, key = lambda i: i['s'])
day = 1
ans = 'YES'
for i in range(N):
# apply for passport
d.append({'d':day, 'i': c[i]['i']})
day += c[i]['t']
if(day>c[i]['s']):
ans = 'NO'
break
# fly to country and back
day = c[i]['s']
day += c[i]['l']
print(ans)
if ans == 'YES':
sorted(d, key = lambda i: i['i'])
for i in range(N):
print(P, d[i]['d'])
``` | instruction | 0 | 18,565 | 4 | 37,130 |
No | output | 1 | 18,565 | 4 | 37,131 |
Provide tags and a correct Python 3 solution for this coding contest problem.
School holidays come in Berland. The holidays are going to continue for n days. The students of school №N are having the time of their lives and the IT teacher Marina Sergeyevna, who has spent all the summer busy checking the BSE (Berland State Examination) results, has finally taken a vacation break! Some people are in charge of the daily watering of flowers in shifts according to the schedule. However when Marina Sergeyevna was making the schedule, she was so tired from work and so lost in dreams of the oncoming vacation that she perhaps made several mistakes. In fact, it is possible that according to the schedule, on some days during the holidays the flowers will not be watered or will be watered multiple times. Help Marina Sergeyevna to find a mistake.
Input
The first input line contains two numbers n and m (1 ≤ n, m ≤ 100) — the number of days in Berland holidays and the number of people in charge of the watering respectively. The next m lines contain the description of the duty schedule. Each line contains two integers ai and bi (1 ≤ ai ≤ bi ≤ n), meaning that the i-th person in charge should water the flowers from the ai-th to the bi-th day inclusively, once a day. The duty shifts are described sequentially, i.e. bi ≤ ai + 1 for all i from 1 to n - 1 inclusively.
Output
Print "OK" (without quotes), if the schedule does not contain mistakes. Otherwise you have to find the minimal number of a day when the flowers will not be watered or will be watered multiple times, and output two integers — the day number and the number of times the flowers will be watered that day.
Examples
Input
10 5
1 2
3 3
4 6
7 7
8 10
Output
OK
Input
10 5
1 2
2 3
4 5
7 8
9 10
Output
2 2
Input
10 5
1 2
3 3
5 7
7 7
7 10
Output
4 0
Note
Keep in mind that in the second sample the mistake occurs not only on the second day, but also on the sixth day, when nobody waters the flowers. However, you have to print the second day, i.e. the day with the minimal number. | instruction | 0 | 18,901 | 4 | 37,802 |
Tags: implementation
Correct Solution:
```
n,m = map(int,input().split())
Ln = [0]*n
while m!=0:
a,b = map(int,input().split())
for i in range(a,b+1):
Ln[i-1]+=1
m-=1
for i in range(0,len(Ln)):
if Ln[i]==0 :
print(i+1,0)
exit(0)
elif Ln[i]>1:
print(i+1,Ln[i])
exit(0)
print('OK')
exit(0)
``` | output | 1 | 18,901 | 4 | 37,803 |
Provide tags and a correct Python 3 solution for this coding contest problem.
School holidays come in Berland. The holidays are going to continue for n days. The students of school №N are having the time of their lives and the IT teacher Marina Sergeyevna, who has spent all the summer busy checking the BSE (Berland State Examination) results, has finally taken a vacation break! Some people are in charge of the daily watering of flowers in shifts according to the schedule. However when Marina Sergeyevna was making the schedule, she was so tired from work and so lost in dreams of the oncoming vacation that she perhaps made several mistakes. In fact, it is possible that according to the schedule, on some days during the holidays the flowers will not be watered or will be watered multiple times. Help Marina Sergeyevna to find a mistake.
Input
The first input line contains two numbers n and m (1 ≤ n, m ≤ 100) — the number of days in Berland holidays and the number of people in charge of the watering respectively. The next m lines contain the description of the duty schedule. Each line contains two integers ai and bi (1 ≤ ai ≤ bi ≤ n), meaning that the i-th person in charge should water the flowers from the ai-th to the bi-th day inclusively, once a day. The duty shifts are described sequentially, i.e. bi ≤ ai + 1 for all i from 1 to n - 1 inclusively.
Output
Print "OK" (without quotes), if the schedule does not contain mistakes. Otherwise you have to find the minimal number of a day when the flowers will not be watered or will be watered multiple times, and output two integers — the day number and the number of times the flowers will be watered that day.
Examples
Input
10 5
1 2
3 3
4 6
7 7
8 10
Output
OK
Input
10 5
1 2
2 3
4 5
7 8
9 10
Output
2 2
Input
10 5
1 2
3 3
5 7
7 7
7 10
Output
4 0
Note
Keep in mind that in the second sample the mistake occurs not only on the second day, but also on the sixth day, when nobody waters the flowers. However, you have to print the second day, i.e. the day with the minimal number. | instruction | 0 | 18,902 | 4 | 37,804 |
Tags: implementation
Correct Solution:
```
def getquanto(v,m,cs):
q=0
day=v[cs+1][0]
for c in range(cs,m):
if v[c][0]<=day:
q+=1
return q
def corr(v,m,n):
if v[0][0]>1:
return 0,1,0
for c in range(m-1):
if v[c+1][0]-v[c][1]<=0:
return 0,v[c+1][0],getquanto(v,m,c)
elif v[c+1][0]-v[c][1]>1:
return 0,v[c][1]+1,0
if v[m-1][1]<n:
return 0,v[m-1][1]+1,0
return 1,0,0
n,m=map(int,input().split(' '))
v=[]
for c in range(m):
a,b=map(int,input().split(' '))
v+=[(a,b)]
ok,day,quanto=corr(v,m,n)
if ok:
print('OK')
else:
print('{} {}'.format(day,quanto))
``` | output | 1 | 18,902 | 4 | 37,805 |
Provide tags and a correct Python 3 solution for this coding contest problem.
School holidays come in Berland. The holidays are going to continue for n days. The students of school №N are having the time of their lives and the IT teacher Marina Sergeyevna, who has spent all the summer busy checking the BSE (Berland State Examination) results, has finally taken a vacation break! Some people are in charge of the daily watering of flowers in shifts according to the schedule. However when Marina Sergeyevna was making the schedule, she was so tired from work and so lost in dreams of the oncoming vacation that she perhaps made several mistakes. In fact, it is possible that according to the schedule, on some days during the holidays the flowers will not be watered or will be watered multiple times. Help Marina Sergeyevna to find a mistake.
Input
The first input line contains two numbers n and m (1 ≤ n, m ≤ 100) — the number of days in Berland holidays and the number of people in charge of the watering respectively. The next m lines contain the description of the duty schedule. Each line contains two integers ai and bi (1 ≤ ai ≤ bi ≤ n), meaning that the i-th person in charge should water the flowers from the ai-th to the bi-th day inclusively, once a day. The duty shifts are described sequentially, i.e. bi ≤ ai + 1 for all i from 1 to n - 1 inclusively.
Output
Print "OK" (without quotes), if the schedule does not contain mistakes. Otherwise you have to find the minimal number of a day when the flowers will not be watered or will be watered multiple times, and output two integers — the day number and the number of times the flowers will be watered that day.
Examples
Input
10 5
1 2
3 3
4 6
7 7
8 10
Output
OK
Input
10 5
1 2
2 3
4 5
7 8
9 10
Output
2 2
Input
10 5
1 2
3 3
5 7
7 7
7 10
Output
4 0
Note
Keep in mind that in the second sample the mistake occurs not only on the second day, but also on the sixth day, when nobody waters the flowers. However, you have to print the second day, i.e. the day with the minimal number. | instruction | 0 | 18,903 | 4 | 37,806 |
Tags: implementation
Correct Solution:
```
n,m=map(int,input().split())
ar=[0 for _ in range(n)]
for _ in range(m):
a,b=map(int,input().split())
for j in range(a-1,b):
ar[j]+=1
for e in range(n):
if(ar[e]!=1):
print(e+1,ar[e])
break
else:
print("OK")
``` | output | 1 | 18,903 | 4 | 37,807 |
Provide tags and a correct Python 3 solution for this coding contest problem.
School holidays come in Berland. The holidays are going to continue for n days. The students of school №N are having the time of their lives and the IT teacher Marina Sergeyevna, who has spent all the summer busy checking the BSE (Berland State Examination) results, has finally taken a vacation break! Some people are in charge of the daily watering of flowers in shifts according to the schedule. However when Marina Sergeyevna was making the schedule, she was so tired from work and so lost in dreams of the oncoming vacation that she perhaps made several mistakes. In fact, it is possible that according to the schedule, on some days during the holidays the flowers will not be watered or will be watered multiple times. Help Marina Sergeyevna to find a mistake.
Input
The first input line contains two numbers n and m (1 ≤ n, m ≤ 100) — the number of days in Berland holidays and the number of people in charge of the watering respectively. The next m lines contain the description of the duty schedule. Each line contains two integers ai and bi (1 ≤ ai ≤ bi ≤ n), meaning that the i-th person in charge should water the flowers from the ai-th to the bi-th day inclusively, once a day. The duty shifts are described sequentially, i.e. bi ≤ ai + 1 for all i from 1 to n - 1 inclusively.
Output
Print "OK" (without quotes), if the schedule does not contain mistakes. Otherwise you have to find the minimal number of a day when the flowers will not be watered or will be watered multiple times, and output two integers — the day number and the number of times the flowers will be watered that day.
Examples
Input
10 5
1 2
3 3
4 6
7 7
8 10
Output
OK
Input
10 5
1 2
2 3
4 5
7 8
9 10
Output
2 2
Input
10 5
1 2
3 3
5 7
7 7
7 10
Output
4 0
Note
Keep in mind that in the second sample the mistake occurs not only on the second day, but also on the sixth day, when nobody waters the flowers. However, you have to print the second day, i.e. the day with the minimal number. | instruction | 0 | 18,904 | 4 | 37,808 |
Tags: implementation
Correct Solution:
```
# by hdev
def parsing(dual) :
a_b = dual.split()
a = int(a_b[0])
b = int(a_b[1])
return (a, b)
def creatTable(rows) :
table = []
index = 1
while index <= rows :
ai_bi = parsing(input())
table.append(ai_bi)
index += 1
return table
class schedule():
def __init__(self, n_m) :
days_people = parsing(n_m)
self.days = days_people[0]
self.people = days_people[1]
self.table = creatTable(self.people)
self.check2()
# def check(self) :
# print("CHECKING...")
#
# day_n = self.days
#
# day_i = 1
# index = 0
#
# while index < self.people :
# print(self.table[index])
#
#
# if row[index][0] = day_i :
# print(day_i)
# day_i += 1
# elif row[index] :
#
#
# day_i = None
# index += 1
def check2(self) :
self.fullTable = []
for row in self.table :
ai = row[0]
bi = row[1]
i = ai
while i <= bi :
self.fullTable.append(i)
i += 1
self.optimalTable = []
i = 1
while i <= self.days :
self.optimalTable.append(i)
i += 1
# print(self.fullTable)
# print(self.optimalTable)
for optimal in self.optimalTable :
goodSoFar = True
if self.fullTable.count(optimal) == 1 :
#print(optimal, "pass")
continue
else :
#print(optimal, "fail")
day = optimal
times = self.fullTable.count(optimal)
goodSoFar = False
break
if goodSoFar == True :
print("OK")
else :
print(day, times)
#def parsing(listoflines) :
schedule1 = schedule(input())
``` | output | 1 | 18,904 | 4 | 37,809 |
Provide tags and a correct Python 3 solution for this coding contest problem.
School holidays come in Berland. The holidays are going to continue for n days. The students of school №N are having the time of their lives and the IT teacher Marina Sergeyevna, who has spent all the summer busy checking the BSE (Berland State Examination) results, has finally taken a vacation break! Some people are in charge of the daily watering of flowers in shifts according to the schedule. However when Marina Sergeyevna was making the schedule, she was so tired from work and so lost in dreams of the oncoming vacation that she perhaps made several mistakes. In fact, it is possible that according to the schedule, on some days during the holidays the flowers will not be watered or will be watered multiple times. Help Marina Sergeyevna to find a mistake.
Input
The first input line contains two numbers n and m (1 ≤ n, m ≤ 100) — the number of days in Berland holidays and the number of people in charge of the watering respectively. The next m lines contain the description of the duty schedule. Each line contains two integers ai and bi (1 ≤ ai ≤ bi ≤ n), meaning that the i-th person in charge should water the flowers from the ai-th to the bi-th day inclusively, once a day. The duty shifts are described sequentially, i.e. bi ≤ ai + 1 for all i from 1 to n - 1 inclusively.
Output
Print "OK" (without quotes), if the schedule does not contain mistakes. Otherwise you have to find the minimal number of a day when the flowers will not be watered or will be watered multiple times, and output two integers — the day number and the number of times the flowers will be watered that day.
Examples
Input
10 5
1 2
3 3
4 6
7 7
8 10
Output
OK
Input
10 5
1 2
2 3
4 5
7 8
9 10
Output
2 2
Input
10 5
1 2
3 3
5 7
7 7
7 10
Output
4 0
Note
Keep in mind that in the second sample the mistake occurs not only on the second day, but also on the sixth day, when nobody waters the flowers. However, you have to print the second day, i.e. the day with the minimal number. | instruction | 0 | 18,905 | 4 | 37,810 |
Tags: implementation
Correct Solution:
```
a=[int(j) for j in input().split()]
n=a[0]
m=a[1]
count=0
b=[0 for i in range(m)]
for i in range(m):
b[i] = [int(j) for j in input().split()]
if b[0][0]!=1:
print(1,0)
else:
for i in range(m-1):
if b[i][1]==b[i+1][0]:
count=2
for k in range(i+2,m):
if b[k][0]==b[i][1]:
count+=1
print(b[i][1],count)
break
elif b[i+1][0]-b[i][1]>1:
print(b[i][1]+1,0)
count=1
break
if not count:
if b[m-1][1]!=n:
print(b[m-1][1]+1,0)
else:
print("OK")
``` | output | 1 | 18,905 | 4 | 37,811 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.