message stringlengths 2 22.7k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 145 109k | cluster float64 9 9 | __index_level_0__ int64 290 217k |
|---|---|---|---|---|---|
Provide a correct Python 3 solution for this coding contest problem.
There are N children, numbered 1, 2, \ldots, N.
They have decided to share K candies among themselves. Here, for each i (1 \leq i \leq N), Child i must receive between 0 and a_i candies (inclusive). Also, no candies should be left over.
Find the number of ways for them to share candies, modulo 10^9 + 7. Here, two ways are said to be different when there exists a child who receives a different number of candies.
Constraints
* All values in input are integers.
* 1 \leq N \leq 100
* 0 \leq K \leq 10^5
* 0 \leq a_i \leq K
Input
Input is given from Standard Input in the following format:
N K
a_1 a_2 \ldots a_N
Output
Print the number of ways for the children to share candies, modulo 10^9 + 7.
Examples
Input
3 4
1 2 3
Output
5
Input
1 10
9
Output
0
Input
2 0
0 0
Output
1
Input
4 100000
100000 100000 100000 100000
Output
665683269 | instruction | 0 | 62,941 | 9 | 125,882 |
"Correct Solution:
```
N , K = map(int,input().split(" "))
a = list(map(int,input().split(" ")))
mod = 10 ** 9 + 7
dp = [ [0]*(K+1) for _ in range(N) ]
acc = [ [0]*(K+1) for _ in range(N) ]
mn = min(K,a[0])
for i in range(K+1):
if i <= mn:
dp[0][i] = 1
acc[0][i] = (acc[0][i-1] + dp[0][i])%mod if i > 0 else dp[0][i]%mod
for i in range(1,N):
dp[i][0] = dp[i-1][0]
acc[i][0] = dp[i][0]
for k in range(1,K+1):
if k - a[i] <= 0:
dp[i][k] = acc[i-1][k] % mod
else:
dp[i][k] = (acc[i-1][k] - acc[i-1][k-a[i]-1]) % mod
acc[i][k] = (acc[i][k-1] + dp[i][k])%mod
print(dp[N-1][K]%mod)
``` | output | 1 | 62,941 | 9 | 125,883 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N children, numbered 1, 2, \ldots, N.
They have decided to share K candies among themselves. Here, for each i (1 \leq i \leq N), Child i must receive between 0 and a_i candies (inclusive). Also, no candies should be left over.
Find the number of ways for them to share candies, modulo 10^9 + 7. Here, two ways are said to be different when there exists a child who receives a different number of candies.
Constraints
* All values in input are integers.
* 1 \leq N \leq 100
* 0 \leq K \leq 10^5
* 0 \leq a_i \leq K
Input
Input is given from Standard Input in the following format:
N K
a_1 a_2 \ldots a_N
Output
Print the number of ways for the children to share candies, modulo 10^9 + 7.
Examples
Input
3 4
1 2 3
Output
5
Input
1 10
9
Output
0
Input
2 0
0 0
Output
1
Input
4 100000
100000 100000 100000 100000
Output
665683269
Submitted Solution:
```
def main():
MOD = 10**9 + 7
N, K = (int(i) for i in input().split())
A = [int(i) for i in input().split()]
dp = [[0]*(K+1) for i in range(N+1)]
dp[0][0] = 1
S = [0] * (K+2)
for i in range(1, N+1):
S[0] = 0
for j in range(1, K+2):
S[j] = (S[j-1] + dp[i-1][j-1]) % MOD
# print(S)
for j in range(K+1):
"""
for k in range(A[i-1]+1):
# i番目の子供がk個受け取る
if j - k >= 0:
dp[i][j] = (dp[i][j] + dp[i-1][j-k]) % MOD
"""
dp[i][j] = (S[j+1] - S[max(0, j-A[i-1])] + MOD) % MOD
print(dp[N][K])
# for i in range(N+1):
# print(*dp[i])
if __name__ == '__main__':
main()
``` | instruction | 0 | 62,942 | 9 | 125,884 |
Yes | output | 1 | 62,942 | 9 | 125,885 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N children, numbered 1, 2, \ldots, N.
They have decided to share K candies among themselves. Here, for each i (1 \leq i \leq N), Child i must receive between 0 and a_i candies (inclusive). Also, no candies should be left over.
Find the number of ways for them to share candies, modulo 10^9 + 7. Here, two ways are said to be different when there exists a child who receives a different number of candies.
Constraints
* All values in input are integers.
* 1 \leq N \leq 100
* 0 \leq K \leq 10^5
* 0 \leq a_i \leq K
Input
Input is given from Standard Input in the following format:
N K
a_1 a_2 \ldots a_N
Output
Print the number of ways for the children to share candies, modulo 10^9 + 7.
Examples
Input
3 4
1 2 3
Output
5
Input
1 10
9
Output
0
Input
2 0
0 0
Output
1
Input
4 100000
100000 100000 100000 100000
Output
665683269
Submitted Solution:
```
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10**9 + 7
dp = [[0] * (k+1) for _ in range(n+1)]
dp[0][0] = 1
for i in range(1, n+1):
cum = [0] * (k+2)
for j in range(k+1):
cum[j+1] = (cum[j] + dp[i-1][j]) % mod
dp[i][j] += cum[j+1] - cum[max(0, j-a[i-1])]
dp[i][j] %= mod
print(dp[n][k])
``` | instruction | 0 | 62,943 | 9 | 125,886 |
Yes | output | 1 | 62,943 | 9 | 125,887 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N children, numbered 1, 2, \ldots, N.
They have decided to share K candies among themselves. Here, for each i (1 \leq i \leq N), Child i must receive between 0 and a_i candies (inclusive). Also, no candies should be left over.
Find the number of ways for them to share candies, modulo 10^9 + 7. Here, two ways are said to be different when there exists a child who receives a different number of candies.
Constraints
* All values in input are integers.
* 1 \leq N \leq 100
* 0 \leq K \leq 10^5
* 0 \leq a_i \leq K
Input
Input is given from Standard Input in the following format:
N K
a_1 a_2 \ldots a_N
Output
Print the number of ways for the children to share candies, modulo 10^9 + 7.
Examples
Input
3 4
1 2 3
Output
5
Input
1 10
9
Output
0
Input
2 0
0 0
Output
1
Input
4 100000
100000 100000 100000 100000
Output
665683269
Submitted Solution:
```
def main():
mod = 10**9+7
n,k = map(int,input().split())
candies = list(map(int,input().split()))
dp = [[0 for i in range(k+1)] for j in range(n+1)]
dp[0][0] = 1
for pos in range(1,n+1):
for used in range(k+1):
a = candies[pos-1]
start = used
end = min(start+a+1,k+1)
dp[pos][start] += dp[pos-1][start]
if end <= k:
dp[pos][end] -= dp[pos-1][start]
for used in range(1,k+1):
dp[pos][used] += dp[pos][used-1]
dp[pos][used] %= mod
print(dp[-1][-1])
main()
``` | instruction | 0 | 62,944 | 9 | 125,888 |
Yes | output | 1 | 62,944 | 9 | 125,889 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N children, numbered 1, 2, \ldots, N.
They have decided to share K candies among themselves. Here, for each i (1 \leq i \leq N), Child i must receive between 0 and a_i candies (inclusive). Also, no candies should be left over.
Find the number of ways for them to share candies, modulo 10^9 + 7. Here, two ways are said to be different when there exists a child who receives a different number of candies.
Constraints
* All values in input are integers.
* 1 \leq N \leq 100
* 0 \leq K \leq 10^5
* 0 \leq a_i \leq K
Input
Input is given from Standard Input in the following format:
N K
a_1 a_2 \ldots a_N
Output
Print the number of ways for the children to share candies, modulo 10^9 + 7.
Examples
Input
3 4
1 2 3
Output
5
Input
1 10
9
Output
0
Input
2 0
0 0
Output
1
Input
4 100000
100000 100000 100000 100000
Output
665683269
Submitted Solution:
```
div = 10**9 + 7
n,k = map(int, input().split())
a = list(map(int, input().split()))
dp = [[0] * (n+1) for _ in range(k+1)]
dp[0] = [1]*(n+1)
for i in range(1,k+1):
for j in range(1, n+1):
if(i <= a[j-1]):
dp[i][j] = (dp[i-1][j] + dp[i][j-1])%div
else:
dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i - a[j-1] - 1][j -1])%div
print(dp[k][n] % div)
``` | instruction | 0 | 62,945 | 9 | 125,890 |
Yes | output | 1 | 62,945 | 9 | 125,891 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N children, numbered 1, 2, \ldots, N.
They have decided to share K candies among themselves. Here, for each i (1 \leq i \leq N), Child i must receive between 0 and a_i candies (inclusive). Also, no candies should be left over.
Find the number of ways for them to share candies, modulo 10^9 + 7. Here, two ways are said to be different when there exists a child who receives a different number of candies.
Constraints
* All values in input are integers.
* 1 \leq N \leq 100
* 0 \leq K \leq 10^5
* 0 \leq a_i \leq K
Input
Input is given from Standard Input in the following format:
N K
a_1 a_2 \ldots a_N
Output
Print the number of ways for the children to share candies, modulo 10^9 + 7.
Examples
Input
3 4
1 2 3
Output
5
Input
1 10
9
Output
0
Input
2 0
0 0
Output
1
Input
4 100000
100000 100000 100000 100000
Output
665683269
Submitted Solution:
```
import sys
input = sys.stdin.readline
MOD = 10**9+7
n, k = map(int, input().split())
A = list(map(int, input().split()))
dp = [[0]*(k+1) for _ in range(n+1)]
dp[0][0] = 1
for i, a in enumerate(A):
for j in range(k+1):
if j == 0:
dp[i+1][j] = 1
elif j <= a:
dp[i+1][j] = dp[i+1][j-1] + dp[i][j]
else:
dp[i+1][j] = dp[i+1][j-1] + dp[i][j] - dp[i][j-a-1]
dp[i+1][j] %= MOD
ans = dp[n][k]
print(ans)
``` | instruction | 0 | 62,946 | 9 | 125,892 |
No | output | 1 | 62,946 | 9 | 125,893 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N children, numbered 1, 2, \ldots, N.
They have decided to share K candies among themselves. Here, for each i (1 \leq i \leq N), Child i must receive between 0 and a_i candies (inclusive). Also, no candies should be left over.
Find the number of ways for them to share candies, modulo 10^9 + 7. Here, two ways are said to be different when there exists a child who receives a different number of candies.
Constraints
* All values in input are integers.
* 1 \leq N \leq 100
* 0 \leq K \leq 10^5
* 0 \leq a_i \leq K
Input
Input is given from Standard Input in the following format:
N K
a_1 a_2 \ldots a_N
Output
Print the number of ways for the children to share candies, modulo 10^9 + 7.
Examples
Input
3 4
1 2 3
Output
5
Input
1 10
9
Output
0
Input
2 0
0 0
Output
1
Input
4 100000
100000 100000 100000 100000
Output
665683269
Submitted Solution:
```
import numpy as np
def f(n, k, a_s):
md = 10 ** 9 + 7
dp = np.zeros(k + 1, dtype=np.int64)
dp[0] = 1
for a in a_s[:-1]:
dp = np.cumsum(dp)
dp[a + 1:] -= dp[:k - a]
return np.sum(dp[k - a_s[-1]:]) % md
n, k = map(int, input().split())
a_s = list(map(int, input().split()))
print(f(n, k, a_s))
``` | instruction | 0 | 62,947 | 9 | 125,894 |
No | output | 1 | 62,947 | 9 | 125,895 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N children, numbered 1, 2, \ldots, N.
They have decided to share K candies among themselves. Here, for each i (1 \leq i \leq N), Child i must receive between 0 and a_i candies (inclusive). Also, no candies should be left over.
Find the number of ways for them to share candies, modulo 10^9 + 7. Here, two ways are said to be different when there exists a child who receives a different number of candies.
Constraints
* All values in input are integers.
* 1 \leq N \leq 100
* 0 \leq K \leq 10^5
* 0 \leq a_i \leq K
Input
Input is given from Standard Input in the following format:
N K
a_1 a_2 \ldots a_N
Output
Print the number of ways for the children to share candies, modulo 10^9 + 7.
Examples
Input
3 4
1 2 3
Output
5
Input
1 10
9
Output
0
Input
2 0
0 0
Output
1
Input
4 100000
100000 100000 100000 100000
Output
665683269
Submitted Solution:
```
def main():
N, K = map(int, input().split())
if K == 0:
return 1
A = list(map(int, input().split()))
MOD = 10**9+7
dp = [[0]*(K+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(N):
a = A[i]
for j in range(K):
dp[i+1][j] += dp[i][j]
if j+a+1 <= K:
dp[i+1][j+a+1] -= dp[i][j]
for j in range(K):
dp[i+1][j+1] += dp[i+1][j]
dp[i+1][j+1] %= MOD
return dp[N][K]
print(main())
``` | instruction | 0 | 62,948 | 9 | 125,896 |
No | output | 1 | 62,948 | 9 | 125,897 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N children, numbered 1, 2, \ldots, N.
They have decided to share K candies among themselves. Here, for each i (1 \leq i \leq N), Child i must receive between 0 and a_i candies (inclusive). Also, no candies should be left over.
Find the number of ways for them to share candies, modulo 10^9 + 7. Here, two ways are said to be different when there exists a child who receives a different number of candies.
Constraints
* All values in input are integers.
* 1 \leq N \leq 100
* 0 \leq K \leq 10^5
* 0 \leq a_i \leq K
Input
Input is given from Standard Input in the following format:
N K
a_1 a_2 \ldots a_N
Output
Print the number of ways for the children to share candies, modulo 10^9 + 7.
Examples
Input
3 4
1 2 3
Output
5
Input
1 10
9
Output
0
Input
2 0
0 0
Output
1
Input
4 100000
100000 100000 100000 100000
Output
665683269
Submitted Solution:
```
n,k=map(int,input().split())
a=list(map(int,input().split()))
dp=[0]*(k+1)
dp[0]=1
mod=10**9+7
for i in range(n):
for j in range(k,0,-1):
if j>a[i]:dp[j]-=dp[j-a[i]-1]
for j in range(k):dp[j+1]=(dp[j+1]+dp[j])%mod
print(dp[k])
``` | instruction | 0 | 62,949 | 9 | 125,898 |
No | output | 1 | 62,949 | 9 | 125,899 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Pasha has two hamsters: Arthur and Alexander. Pasha put n apples in front of them. Pasha knows which apples Arthur likes. Similarly, Pasha knows which apples Alexander likes. Pasha doesn't want any conflict between the hamsters (as they may like the same apple), so he decided to distribute the apples between the hamsters on his own. He is going to give some apples to Arthur and some apples to Alexander. It doesn't matter how many apples each hamster gets but it is important that each hamster gets only the apples he likes. It is possible that somebody doesn't get any apples.
Help Pasha distribute all the apples between the hamsters. Note that Pasha wants to distribute all the apples, not just some of them.
Input
The first line contains integers n, a, b (1 ≤ n ≤ 100; 1 ≤ a, b ≤ n) — the number of apples Pasha has, the number of apples Arthur likes and the number of apples Alexander likes, correspondingly.
The next line contains a distinct integers — the numbers of the apples Arthur likes. The next line contains b distinct integers — the numbers of the apples Alexander likes.
Assume that the apples are numbered from 1 to n. The input is such that the answer exists.
Output
Print n characters, each of them equals either 1 or 2. If the i-h character equals 1, then the i-th apple should be given to Arthur, otherwise it should be given to Alexander. If there are multiple correct answers, you are allowed to print any of them.
Examples
Input
4 2 3
1 2
2 3 4
Output
1 1 2 2
Input
5 5 2
3 4 1 2 5
2 3
Output
1 1 1 1 1 | instruction | 0 | 63,482 | 9 | 126,964 |
Tags: constructive algorithms, implementation
Correct Solution:
```
def main():
t = input().split()
n, a, b = int(t[0]),int(t[1]),int(t[2])
s = [0 for i in range(n)]
l = input().split()
for ele in l:
s[int(ele)-1] = 1
l = input().split()
for ele in l:
if(s[int(ele)-1] != 1):
s[int(ele)-1] = 2
print(' '.join(map(str,s)))
main()
``` | output | 1 | 63,482 | 9 | 126,965 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Pasha has two hamsters: Arthur and Alexander. Pasha put n apples in front of them. Pasha knows which apples Arthur likes. Similarly, Pasha knows which apples Alexander likes. Pasha doesn't want any conflict between the hamsters (as they may like the same apple), so he decided to distribute the apples between the hamsters on his own. He is going to give some apples to Arthur and some apples to Alexander. It doesn't matter how many apples each hamster gets but it is important that each hamster gets only the apples he likes. It is possible that somebody doesn't get any apples.
Help Pasha distribute all the apples between the hamsters. Note that Pasha wants to distribute all the apples, not just some of them.
Input
The first line contains integers n, a, b (1 ≤ n ≤ 100; 1 ≤ a, b ≤ n) — the number of apples Pasha has, the number of apples Arthur likes and the number of apples Alexander likes, correspondingly.
The next line contains a distinct integers — the numbers of the apples Arthur likes. The next line contains b distinct integers — the numbers of the apples Alexander likes.
Assume that the apples are numbered from 1 to n. The input is such that the answer exists.
Output
Print n characters, each of them equals either 1 or 2. If the i-h character equals 1, then the i-th apple should be given to Arthur, otherwise it should be given to Alexander. If there are multiple correct answers, you are allowed to print any of them.
Examples
Input
4 2 3
1 2
2 3 4
Output
1 1 2 2
Input
5 5 2
3 4 1 2 5
2 3
Output
1 1 1 1 1 | instruction | 0 | 63,483 | 9 | 126,966 |
Tags: constructive algorithms, implementation
Correct Solution:
```
def homyaki(n, lst1, lst2):
result = list()
for i in range(1, n + 1):
if i in lst1:
result.append(1)
else:
result.append(2)
return result
N, a, b = [int(j) for j in input().split()]
arthur = [int(x) for x in input().split()]
alex = [int(y) for y in input().split()]
print(*homyaki(N, arthur, alex))
``` | output | 1 | 63,483 | 9 | 126,967 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Pasha has two hamsters: Arthur and Alexander. Pasha put n apples in front of them. Pasha knows which apples Arthur likes. Similarly, Pasha knows which apples Alexander likes. Pasha doesn't want any conflict between the hamsters (as they may like the same apple), so he decided to distribute the apples between the hamsters on his own. He is going to give some apples to Arthur and some apples to Alexander. It doesn't matter how many apples each hamster gets but it is important that each hamster gets only the apples he likes. It is possible that somebody doesn't get any apples.
Help Pasha distribute all the apples between the hamsters. Note that Pasha wants to distribute all the apples, not just some of them.
Input
The first line contains integers n, a, b (1 ≤ n ≤ 100; 1 ≤ a, b ≤ n) — the number of apples Pasha has, the number of apples Arthur likes and the number of apples Alexander likes, correspondingly.
The next line contains a distinct integers — the numbers of the apples Arthur likes. The next line contains b distinct integers — the numbers of the apples Alexander likes.
Assume that the apples are numbered from 1 to n. The input is such that the answer exists.
Output
Print n characters, each of them equals either 1 or 2. If the i-h character equals 1, then the i-th apple should be given to Arthur, otherwise it should be given to Alexander. If there are multiple correct answers, you are allowed to print any of them.
Examples
Input
4 2 3
1 2
2 3 4
Output
1 1 2 2
Input
5 5 2
3 4 1 2 5
2 3
Output
1 1 1 1 1 | instruction | 0 | 63,484 | 9 | 126,968 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n,a,b=map(int,input().split())
aa=list(map(int,input().split()))
ba=list(map(int,input().split()))
out=''
for i in range(1,n+1):
if i in aa:
out+='1 '
elif i in ba:
out+='2 '
print(out.strip())
``` | output | 1 | 63,484 | 9 | 126,969 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Pasha has two hamsters: Arthur and Alexander. Pasha put n apples in front of them. Pasha knows which apples Arthur likes. Similarly, Pasha knows which apples Alexander likes. Pasha doesn't want any conflict between the hamsters (as they may like the same apple), so he decided to distribute the apples between the hamsters on his own. He is going to give some apples to Arthur and some apples to Alexander. It doesn't matter how many apples each hamster gets but it is important that each hamster gets only the apples he likes. It is possible that somebody doesn't get any apples.
Help Pasha distribute all the apples between the hamsters. Note that Pasha wants to distribute all the apples, not just some of them.
Input
The first line contains integers n, a, b (1 ≤ n ≤ 100; 1 ≤ a, b ≤ n) — the number of apples Pasha has, the number of apples Arthur likes and the number of apples Alexander likes, correspondingly.
The next line contains a distinct integers — the numbers of the apples Arthur likes. The next line contains b distinct integers — the numbers of the apples Alexander likes.
Assume that the apples are numbered from 1 to n. The input is such that the answer exists.
Output
Print n characters, each of them equals either 1 or 2. If the i-h character equals 1, then the i-th apple should be given to Arthur, otherwise it should be given to Alexander. If there are multiple correct answers, you are allowed to print any of them.
Examples
Input
4 2 3
1 2
2 3 4
Output
1 1 2 2
Input
5 5 2
3 4 1 2 5
2 3
Output
1 1 1 1 1 | instruction | 0 | 63,485 | 9 | 126,970 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n, a, b = [int(x) for x in input().split()]
ar = [int(x) for x in input().split()]
al = [int(x) for x in input().split()]
an = [2] * n
for i in range(a):
an[ar[i] - 1] = 1
for i in an:
print(i)
``` | output | 1 | 63,485 | 9 | 126,971 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Pasha has two hamsters: Arthur and Alexander. Pasha put n apples in front of them. Pasha knows which apples Arthur likes. Similarly, Pasha knows which apples Alexander likes. Pasha doesn't want any conflict between the hamsters (as they may like the same apple), so he decided to distribute the apples between the hamsters on his own. He is going to give some apples to Arthur and some apples to Alexander. It doesn't matter how many apples each hamster gets but it is important that each hamster gets only the apples he likes. It is possible that somebody doesn't get any apples.
Help Pasha distribute all the apples between the hamsters. Note that Pasha wants to distribute all the apples, not just some of them.
Input
The first line contains integers n, a, b (1 ≤ n ≤ 100; 1 ≤ a, b ≤ n) — the number of apples Pasha has, the number of apples Arthur likes and the number of apples Alexander likes, correspondingly.
The next line contains a distinct integers — the numbers of the apples Arthur likes. The next line contains b distinct integers — the numbers of the apples Alexander likes.
Assume that the apples are numbered from 1 to n. The input is such that the answer exists.
Output
Print n characters, each of them equals either 1 or 2. If the i-h character equals 1, then the i-th apple should be given to Arthur, otherwise it should be given to Alexander. If there are multiple correct answers, you are allowed to print any of them.
Examples
Input
4 2 3
1 2
2 3 4
Output
1 1 2 2
Input
5 5 2
3 4 1 2 5
2 3
Output
1 1 1 1 1 | instruction | 0 | 63,486 | 9 | 126,972 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n,a,b=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
b=list(map(int,input().split()))
i=0
for j in range(n):
if i<len(a):
if j+1==a[i]:
print(1,end=' ')
i+=1
else:
print(2,end=' ')
else:
print(2,end=' ')
``` | output | 1 | 63,486 | 9 | 126,973 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Pasha has two hamsters: Arthur and Alexander. Pasha put n apples in front of them. Pasha knows which apples Arthur likes. Similarly, Pasha knows which apples Alexander likes. Pasha doesn't want any conflict between the hamsters (as they may like the same apple), so he decided to distribute the apples between the hamsters on his own. He is going to give some apples to Arthur and some apples to Alexander. It doesn't matter how many apples each hamster gets but it is important that each hamster gets only the apples he likes. It is possible that somebody doesn't get any apples.
Help Pasha distribute all the apples between the hamsters. Note that Pasha wants to distribute all the apples, not just some of them.
Input
The first line contains integers n, a, b (1 ≤ n ≤ 100; 1 ≤ a, b ≤ n) — the number of apples Pasha has, the number of apples Arthur likes and the number of apples Alexander likes, correspondingly.
The next line contains a distinct integers — the numbers of the apples Arthur likes. The next line contains b distinct integers — the numbers of the apples Alexander likes.
Assume that the apples are numbered from 1 to n. The input is such that the answer exists.
Output
Print n characters, each of them equals either 1 or 2. If the i-h character equals 1, then the i-th apple should be given to Arthur, otherwise it should be given to Alexander. If there are multiple correct answers, you are allowed to print any of them.
Examples
Input
4 2 3
1 2
2 3 4
Output
1 1 2 2
Input
5 5 2
3 4 1 2 5
2 3
Output
1 1 1 1 1 | instruction | 0 | 63,487 | 9 | 126,974 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n, _, _ = map(int, input().split())
a = map(int, input().split())
b = map(int, input().split())
r = [0] * n
for x in a:
r[x-1] = 1
for x in b:
r[x-1] = 2
print(*r, sep=" ")
``` | output | 1 | 63,487 | 9 | 126,975 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Pasha has two hamsters: Arthur and Alexander. Pasha put n apples in front of them. Pasha knows which apples Arthur likes. Similarly, Pasha knows which apples Alexander likes. Pasha doesn't want any conflict between the hamsters (as they may like the same apple), so he decided to distribute the apples between the hamsters on his own. He is going to give some apples to Arthur and some apples to Alexander. It doesn't matter how many apples each hamster gets but it is important that each hamster gets only the apples he likes. It is possible that somebody doesn't get any apples.
Help Pasha distribute all the apples between the hamsters. Note that Pasha wants to distribute all the apples, not just some of them.
Input
The first line contains integers n, a, b (1 ≤ n ≤ 100; 1 ≤ a, b ≤ n) — the number of apples Pasha has, the number of apples Arthur likes and the number of apples Alexander likes, correspondingly.
The next line contains a distinct integers — the numbers of the apples Arthur likes. The next line contains b distinct integers — the numbers of the apples Alexander likes.
Assume that the apples are numbered from 1 to n. The input is such that the answer exists.
Output
Print n characters, each of them equals either 1 or 2. If the i-h character equals 1, then the i-th apple should be given to Arthur, otherwise it should be given to Alexander. If there are multiple correct answers, you are allowed to print any of them.
Examples
Input
4 2 3
1 2
2 3 4
Output
1 1 2 2
Input
5 5 2
3 4 1 2 5
2 3
Output
1 1 1 1 1 | instruction | 0 | 63,488 | 9 | 126,976 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n, a, b = map(int, input().split(" "))
h1 = set(map(int, input().split(" ")))
ans = (1 if x + 1 in h1 else 2 for x in range(n))
print(*ans)
``` | output | 1 | 63,488 | 9 | 126,977 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Pasha has two hamsters: Arthur and Alexander. Pasha put n apples in front of them. Pasha knows which apples Arthur likes. Similarly, Pasha knows which apples Alexander likes. Pasha doesn't want any conflict between the hamsters (as they may like the same apple), so he decided to distribute the apples between the hamsters on his own. He is going to give some apples to Arthur and some apples to Alexander. It doesn't matter how many apples each hamster gets but it is important that each hamster gets only the apples he likes. It is possible that somebody doesn't get any apples.
Help Pasha distribute all the apples between the hamsters. Note that Pasha wants to distribute all the apples, not just some of them.
Input
The first line contains integers n, a, b (1 ≤ n ≤ 100; 1 ≤ a, b ≤ n) — the number of apples Pasha has, the number of apples Arthur likes and the number of apples Alexander likes, correspondingly.
The next line contains a distinct integers — the numbers of the apples Arthur likes. The next line contains b distinct integers — the numbers of the apples Alexander likes.
Assume that the apples are numbered from 1 to n. The input is such that the answer exists.
Output
Print n characters, each of them equals either 1 or 2. If the i-h character equals 1, then the i-th apple should be given to Arthur, otherwise it should be given to Alexander. If there are multiple correct answers, you are allowed to print any of them.
Examples
Input
4 2 3
1 2
2 3 4
Output
1 1 2 2
Input
5 5 2
3 4 1 2 5
2 3
Output
1 1 1 1 1 | instruction | 0 | 63,489 | 9 | 126,978 |
Tags: constructive algorithms, implementation
Correct Solution:
```
R = lambda: map(int, input().split())
n, a, b = R()
T = lambda: list(map(int, input().split()))
A = T()
B = T()
ans = [-1 for i in range(n + 1)]
for i in range(a):
ans[A[i]] = 1
for i in range(1, n + 1):
if ans[i] == -1:
ans[i] = 2
for i in range(1, n + 1):
print(ans[i], end = ' ')
``` | output | 1 | 63,489 | 9 | 126,979 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Pasha has two hamsters: Arthur and Alexander. Pasha put n apples in front of them. Pasha knows which apples Arthur likes. Similarly, Pasha knows which apples Alexander likes. Pasha doesn't want any conflict between the hamsters (as they may like the same apple), so he decided to distribute the apples between the hamsters on his own. He is going to give some apples to Arthur and some apples to Alexander. It doesn't matter how many apples each hamster gets but it is important that each hamster gets only the apples he likes. It is possible that somebody doesn't get any apples.
Help Pasha distribute all the apples between the hamsters. Note that Pasha wants to distribute all the apples, not just some of them.
Input
The first line contains integers n, a, b (1 ≤ n ≤ 100; 1 ≤ a, b ≤ n) — the number of apples Pasha has, the number of apples Arthur likes and the number of apples Alexander likes, correspondingly.
The next line contains a distinct integers — the numbers of the apples Arthur likes. The next line contains b distinct integers — the numbers of the apples Alexander likes.
Assume that the apples are numbered from 1 to n. The input is such that the answer exists.
Output
Print n characters, each of them equals either 1 or 2. If the i-h character equals 1, then the i-th apple should be given to Arthur, otherwise it should be given to Alexander. If there are multiple correct answers, you are allowed to print any of them.
Examples
Input
4 2 3
1 2
2 3 4
Output
1 1 2 2
Input
5 5 2
3 4 1 2 5
2 3
Output
1 1 1 1 1
Submitted Solution:
```
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = []
for i in range(1,n+1):
if i in a: ans.append(1)
else: ans.append(2)
print(*ans)
``` | instruction | 0 | 63,490 | 9 | 126,980 |
Yes | output | 1 | 63,490 | 9 | 126,981 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Pasha has two hamsters: Arthur and Alexander. Pasha put n apples in front of them. Pasha knows which apples Arthur likes. Similarly, Pasha knows which apples Alexander likes. Pasha doesn't want any conflict between the hamsters (as they may like the same apple), so he decided to distribute the apples between the hamsters on his own. He is going to give some apples to Arthur and some apples to Alexander. It doesn't matter how many apples each hamster gets but it is important that each hamster gets only the apples he likes. It is possible that somebody doesn't get any apples.
Help Pasha distribute all the apples between the hamsters. Note that Pasha wants to distribute all the apples, not just some of them.
Input
The first line contains integers n, a, b (1 ≤ n ≤ 100; 1 ≤ a, b ≤ n) — the number of apples Pasha has, the number of apples Arthur likes and the number of apples Alexander likes, correspondingly.
The next line contains a distinct integers — the numbers of the apples Arthur likes. The next line contains b distinct integers — the numbers of the apples Alexander likes.
Assume that the apples are numbered from 1 to n. The input is such that the answer exists.
Output
Print n characters, each of them equals either 1 or 2. If the i-h character equals 1, then the i-th apple should be given to Arthur, otherwise it should be given to Alexander. If there are multiple correct answers, you are allowed to print any of them.
Examples
Input
4 2 3
1 2
2 3 4
Output
1 1 2 2
Input
5 5 2
3 4 1 2 5
2 3
Output
1 1 1 1 1
Submitted Solution:
```
def main():
[n, a, b] = [int(_) for _ in input().split()]
arthur = [int(_) for _ in input().split()]
alex = [int(_) for _ in input().split()]
apples = ['2'] * (n + 1)
for apple in arthur:
apples[apple] = '1'
print(' '.join(apples[1:]))
if __name__ == '__main__':
main()
``` | instruction | 0 | 63,491 | 9 | 126,982 |
Yes | output | 1 | 63,491 | 9 | 126,983 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Pasha has two hamsters: Arthur and Alexander. Pasha put n apples in front of them. Pasha knows which apples Arthur likes. Similarly, Pasha knows which apples Alexander likes. Pasha doesn't want any conflict between the hamsters (as they may like the same apple), so he decided to distribute the apples between the hamsters on his own. He is going to give some apples to Arthur and some apples to Alexander. It doesn't matter how many apples each hamster gets but it is important that each hamster gets only the apples he likes. It is possible that somebody doesn't get any apples.
Help Pasha distribute all the apples between the hamsters. Note that Pasha wants to distribute all the apples, not just some of them.
Input
The first line contains integers n, a, b (1 ≤ n ≤ 100; 1 ≤ a, b ≤ n) — the number of apples Pasha has, the number of apples Arthur likes and the number of apples Alexander likes, correspondingly.
The next line contains a distinct integers — the numbers of the apples Arthur likes. The next line contains b distinct integers — the numbers of the apples Alexander likes.
Assume that the apples are numbered from 1 to n. The input is such that the answer exists.
Output
Print n characters, each of them equals either 1 or 2. If the i-h character equals 1, then the i-th apple should be given to Arthur, otherwise it should be given to Alexander. If there are multiple correct answers, you are allowed to print any of them.
Examples
Input
4 2 3
1 2
2 3 4
Output
1 1 2 2
Input
5 5 2
3 4 1 2 5
2 3
Output
1 1 1 1 1
Submitted Solution:
```
T_ON = 0
DEBUG_ON = 1
MOD = 998244353
def solve():
n, a, b = read_ints()
A = read_ints()
B = read_ints()
C = [0 for _ in range(n)]
for a in A:
C[a-1] = 1
for b in B:
if C[b-1] == 0:
C[b-1] = 2
print_nums(C)
def main():
T = read_int() if T_ON else 1
for i in range(T):
solve()
def debug(*xargs):
if DEBUG_ON:
print(*xargs)
from collections import *
import math
#---------------------------------FAST_IO---------------------------------------
import os
import sys
from io import BytesIO, IOBase
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
#----------------------------------IO_WRAP--------------------------------------
def read_int():
return int(input())
def read_ints():
return list(map(int, input().split()))
def print_nums(nums):
print(" ".join(map(str, nums)))
def YES():
print("YES")
def Yes():
print("Yes")
def NO():
print("NO")
def No():
print("No")
def First():
print("First")
def Second():
print("Second")
#----------------------------------FIB--------------------------------------
def fib(n):
"""
the nth fib, start from zero
"""
a, b = 0, 1
for _ in range(n):
a, b = b, a + b
return a
def fib_ns(n):
"""
the first n fibs, start from zero
"""
assert n >= 1
f = [0 for _ in range(n + 1)]
f[0] = 0
f[1] = 1
for i in range(2, n + 1):
f[i] = f[i - 1] + f[i - 2]
return f
def fib_to_n(n):
"""
return fibs <= n, start from zero
n=8
f=[0,1,1,2,3,5,8]
"""
f = []
a, b = 0, 1
while a <= n:
f.append(a)
a, b = b, a + b
return f
#----------------------------------MOD--------------------------------------
def gcd(a, b):
if a == 0:
return b
return gcd(b % a, a)
def xgcd(a, b):
"""return (g, x, y) such that a*x + b*y = g = gcd(a, b)"""
x0, x1, y0, y1 = 0, 1, 1, 0
while a != 0:
(q, a), b = divmod(b, a), a
y0, y1 = y1, y0 - q * y1
x0, x1 = x1, x0 - q * x1
return b, x0, y0
def lcm(a, b):
d = gcd(a, b)
return a * b // d
def is_even(x):
return x % 2 == 0
def is_odd(x):
return x % 2 == 1
def modinv(a, m):
"""return x such that (a * x) % m == 1"""
g, x, _ = xgcd(a, m)
if g != 1:
raise Exception('gcd(a, m) != 1')
return x % m
def mod_add(x, y):
x += y
while x >= MOD:
x -= MOD
while x < 0:
x += MOD
return x
def mod_mul(x, y):
return (x * y) % MOD
def mod_pow(x, y):
if y == 0:
return 1
if y % 2:
return mod_mul(x, mod_pow(x, y - 1))
p = mod_pow(x, y // 2)
return mod_mul(p, p)
def mod_inv(y):
return mod_pow(y, MOD - 2)
def mod_div(x, y):
# y^(-1): Fermat little theorem, MOD is a prime
return mod_mul(x, mod_inv(y))
#---------------------------------PRIME---------------------------------------
def is_prime(n):
if n == 1:
return False
for i in range(2, int(n ** 0.5) + 1):
if n % i:
return False
return True
def gen_primes(n):
"""
generate primes of [1..n] using sieve's method
"""
P = [True for _ in range(n + 1)]
P[0] = P[1] = False
for i in range(int(n ** 0.5) + 1):
if P[i]:
for j in range(2 * i, n + 1, i):
P[j] = False
return P
#---------------------------------MISC---------------------------------------
def is_lucky(n):
return set(list(str(n))).issubset({'4', '7'})
#---------------------------------MAIN---------------------------------------
main()
``` | instruction | 0 | 63,492 | 9 | 126,984 |
Yes | output | 1 | 63,492 | 9 | 126,985 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Pasha has two hamsters: Arthur and Alexander. Pasha put n apples in front of them. Pasha knows which apples Arthur likes. Similarly, Pasha knows which apples Alexander likes. Pasha doesn't want any conflict between the hamsters (as they may like the same apple), so he decided to distribute the apples between the hamsters on his own. He is going to give some apples to Arthur and some apples to Alexander. It doesn't matter how many apples each hamster gets but it is important that each hamster gets only the apples he likes. It is possible that somebody doesn't get any apples.
Help Pasha distribute all the apples between the hamsters. Note that Pasha wants to distribute all the apples, not just some of them.
Input
The first line contains integers n, a, b (1 ≤ n ≤ 100; 1 ≤ a, b ≤ n) — the number of apples Pasha has, the number of apples Arthur likes and the number of apples Alexander likes, correspondingly.
The next line contains a distinct integers — the numbers of the apples Arthur likes. The next line contains b distinct integers — the numbers of the apples Alexander likes.
Assume that the apples are numbered from 1 to n. The input is such that the answer exists.
Output
Print n characters, each of them equals either 1 or 2. If the i-h character equals 1, then the i-th apple should be given to Arthur, otherwise it should be given to Alexander. If there are multiple correct answers, you are allowed to print any of them.
Examples
Input
4 2 3
1 2
2 3 4
Output
1 1 2 2
Input
5 5 2
3 4 1 2 5
2 3
Output
1 1 1 1 1
Submitted Solution:
```
import sys
n, a, b = sys.stdin.readline().split()
n = int(n)
a = int(a)
b = int(b)
arr_a = sys.stdin.readline().split()
arr_b = sys.stdin.readline().split()
arr_a = [int(x) for x in arr_a]
arr_b = [int(x) for x in arr_b]
res = []
for i in range(n):
if((i +1) in arr_a):
res.append(1)
else:
res.append(2)
print(' '.join([str(x) for x in res]))
``` | instruction | 0 | 63,493 | 9 | 126,986 |
Yes | output | 1 | 63,493 | 9 | 126,987 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Pasha has two hamsters: Arthur and Alexander. Pasha put n apples in front of them. Pasha knows which apples Arthur likes. Similarly, Pasha knows which apples Alexander likes. Pasha doesn't want any conflict between the hamsters (as they may like the same apple), so he decided to distribute the apples between the hamsters on his own. He is going to give some apples to Arthur and some apples to Alexander. It doesn't matter how many apples each hamster gets but it is important that each hamster gets only the apples he likes. It is possible that somebody doesn't get any apples.
Help Pasha distribute all the apples between the hamsters. Note that Pasha wants to distribute all the apples, not just some of them.
Input
The first line contains integers n, a, b (1 ≤ n ≤ 100; 1 ≤ a, b ≤ n) — the number of apples Pasha has, the number of apples Arthur likes and the number of apples Alexander likes, correspondingly.
The next line contains a distinct integers — the numbers of the apples Arthur likes. The next line contains b distinct integers — the numbers of the apples Alexander likes.
Assume that the apples are numbered from 1 to n. The input is such that the answer exists.
Output
Print n characters, each of them equals either 1 or 2. If the i-h character equals 1, then the i-th apple should be given to Arthur, otherwise it should be given to Alexander. If there are multiple correct answers, you are allowed to print any of them.
Examples
Input
4 2 3
1 2
2 3 4
Output
1 1 2 2
Input
5 5 2
3 4 1 2 5
2 3
Output
1 1 1 1 1
Submitted Solution:
```
n,a,b = map(int,input().split())
a1 = list(map(int,input().split()))
b1 = list(map(int,input().split()))
print('1 '*max(a1)+'2 '*(n-max(a1)))
``` | instruction | 0 | 63,494 | 9 | 126,988 |
No | output | 1 | 63,494 | 9 | 126,989 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Pasha has two hamsters: Arthur and Alexander. Pasha put n apples in front of them. Pasha knows which apples Arthur likes. Similarly, Pasha knows which apples Alexander likes. Pasha doesn't want any conflict between the hamsters (as they may like the same apple), so he decided to distribute the apples between the hamsters on his own. He is going to give some apples to Arthur and some apples to Alexander. It doesn't matter how many apples each hamster gets but it is important that each hamster gets only the apples he likes. It is possible that somebody doesn't get any apples.
Help Pasha distribute all the apples between the hamsters. Note that Pasha wants to distribute all the apples, not just some of them.
Input
The first line contains integers n, a, b (1 ≤ n ≤ 100; 1 ≤ a, b ≤ n) — the number of apples Pasha has, the number of apples Arthur likes and the number of apples Alexander likes, correspondingly.
The next line contains a distinct integers — the numbers of the apples Arthur likes. The next line contains b distinct integers — the numbers of the apples Alexander likes.
Assume that the apples are numbered from 1 to n. The input is such that the answer exists.
Output
Print n characters, each of them equals either 1 or 2. If the i-h character equals 1, then the i-th apple should be given to Arthur, otherwise it should be given to Alexander. If there are multiple correct answers, you are allowed to print any of them.
Examples
Input
4 2 3
1 2
2 3 4
Output
1 1 2 2
Input
5 5 2
3 4 1 2 5
2 3
Output
1 1 1 1 1
Submitted Solution:
```
#421A
NApples, N1, N2 = map(int,input().split())
A1 = list(map(int,input().strip().split()))[:N1]
A2 = list(map(int,input().strip().split()))[:N2]
A1.sort()
A2.sort()
giveto = []
for i in range(1,NApples+1):
if(i in A1):
giveto.append(1)
elif(i in A2):
giveto.append(2)
else:
giveto.append(0)
print(giveto)
``` | instruction | 0 | 63,495 | 9 | 126,990 |
No | output | 1 | 63,495 | 9 | 126,991 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Pasha has two hamsters: Arthur and Alexander. Pasha put n apples in front of them. Pasha knows which apples Arthur likes. Similarly, Pasha knows which apples Alexander likes. Pasha doesn't want any conflict between the hamsters (as they may like the same apple), so he decided to distribute the apples between the hamsters on his own. He is going to give some apples to Arthur and some apples to Alexander. It doesn't matter how many apples each hamster gets but it is important that each hamster gets only the apples he likes. It is possible that somebody doesn't get any apples.
Help Pasha distribute all the apples between the hamsters. Note that Pasha wants to distribute all the apples, not just some of them.
Input
The first line contains integers n, a, b (1 ≤ n ≤ 100; 1 ≤ a, b ≤ n) — the number of apples Pasha has, the number of apples Arthur likes and the number of apples Alexander likes, correspondingly.
The next line contains a distinct integers — the numbers of the apples Arthur likes. The next line contains b distinct integers — the numbers of the apples Alexander likes.
Assume that the apples are numbered from 1 to n. The input is such that the answer exists.
Output
Print n characters, each of them equals either 1 or 2. If the i-h character equals 1, then the i-th apple should be given to Arthur, otherwise it should be given to Alexander. If there are multiple correct answers, you are allowed to print any of them.
Examples
Input
4 2 3
1 2
2 3 4
Output
1 1 2 2
Input
5 5 2
3 4 1 2 5
2 3
Output
1 1 1 1 1
Submitted Solution:
```
n,a,b=map(int,input('').split())
a=list(map(int,input('').split()))
b=list(map(int,input('').split()))
for i in range(n):print(('1' if (i in a) else '2'),end=" ")
``` | instruction | 0 | 63,496 | 9 | 126,992 |
No | output | 1 | 63,496 | 9 | 126,993 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Pasha has two hamsters: Arthur and Alexander. Pasha put n apples in front of them. Pasha knows which apples Arthur likes. Similarly, Pasha knows which apples Alexander likes. Pasha doesn't want any conflict between the hamsters (as they may like the same apple), so he decided to distribute the apples between the hamsters on his own. He is going to give some apples to Arthur and some apples to Alexander. It doesn't matter how many apples each hamster gets but it is important that each hamster gets only the apples he likes. It is possible that somebody doesn't get any apples.
Help Pasha distribute all the apples between the hamsters. Note that Pasha wants to distribute all the apples, not just some of them.
Input
The first line contains integers n, a, b (1 ≤ n ≤ 100; 1 ≤ a, b ≤ n) — the number of apples Pasha has, the number of apples Arthur likes and the number of apples Alexander likes, correspondingly.
The next line contains a distinct integers — the numbers of the apples Arthur likes. The next line contains b distinct integers — the numbers of the apples Alexander likes.
Assume that the apples are numbered from 1 to n. The input is such that the answer exists.
Output
Print n characters, each of them equals either 1 or 2. If the i-h character equals 1, then the i-th apple should be given to Arthur, otherwise it should be given to Alexander. If there are multiple correct answers, you are allowed to print any of them.
Examples
Input
4 2 3
1 2
2 3 4
Output
1 1 2 2
Input
5 5 2
3 4 1 2 5
2 3
Output
1 1 1 1 1
Submitted Solution:
```
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = 'x' in file.mode or 'r' not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b'\n') + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode('ascii'))
self.read = lambda: self.buffer.read().decode('ascii')
self.readline = lambda: self.buffer.readline().decode('ascii')
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')
from itertools import repeat
n, a, b = map(int, input().split())
ax = [*map(int, input().split())]
bx = [*map(int, input().split())]
ans = [*repeat(0, n)]
for i in ax:
ans[i - 1] = 1
for i in bx:
ans[i - 1] = 1
print(*ans)
``` | instruction | 0 | 63,497 | 9 | 126,994 |
No | output | 1 | 63,497 | 9 | 126,995 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In some game by Playrix it takes t minutes for an oven to bake k carrot cakes, all cakes are ready at the same moment t minutes after they started baking. Arkady needs at least n cakes to complete a task, but he currently don't have any. However, he has infinitely many ingredients and one oven. Moreover, Arkady can build one more similar oven to make the process faster, it would take d minutes to build the oven. While the new oven is being built, only old one can bake cakes, after the new oven is built, both ovens bake simultaneously. Arkady can't build more than one oven.
Determine if it is reasonable to build the second oven, i.e. will it decrease the minimum time needed to get n cakes or not. If the time needed with the second oven is the same as with one oven, then it is unreasonable.
Input
The only line contains four integers n, t, k, d (1 ≤ n, t, k, d ≤ 1 000) — the number of cakes needed, the time needed for one oven to bake k cakes, the number of cakes baked at the same time, the time needed to build the second oven.
Output
If it is reasonable to build the second oven, print "YES". Otherwise print "NO".
Examples
Input
8 6 4 5
Output
YES
Input
8 6 4 6
Output
NO
Input
10 3 11 4
Output
NO
Input
4 2 1 4
Output
YES
Note
In the first example it is possible to get 8 cakes in 12 minutes using one oven. The second oven can be built in 5 minutes, so after 6 minutes the first oven bakes 4 cakes, the second oven bakes 4 more ovens after 11 minutes. Thus, it is reasonable to build the second oven.
In the second example it doesn't matter whether we build the second oven or not, thus it takes 12 minutes to bake 8 cakes in both cases. Thus, it is unreasonable to build the second oven.
In the third example the first oven bakes 11 cakes in 3 minutes, that is more than needed 10. It is unreasonable to build the second oven, because its building takes more time that baking the needed number of cakes using the only oven. | instruction | 0 | 63,600 | 9 | 127,200 |
Tags: brute force, implementation
Correct Solution:
```
n,t,k,d=list(map(int,input().split()))
if k*(1 + d // t) < n:
print("YES")
else:
print("NO")
``` | output | 1 | 63,600 | 9 | 127,201 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In some game by Playrix it takes t minutes for an oven to bake k carrot cakes, all cakes are ready at the same moment t minutes after they started baking. Arkady needs at least n cakes to complete a task, but he currently don't have any. However, he has infinitely many ingredients and one oven. Moreover, Arkady can build one more similar oven to make the process faster, it would take d minutes to build the oven. While the new oven is being built, only old one can bake cakes, after the new oven is built, both ovens bake simultaneously. Arkady can't build more than one oven.
Determine if it is reasonable to build the second oven, i.e. will it decrease the minimum time needed to get n cakes or not. If the time needed with the second oven is the same as with one oven, then it is unreasonable.
Input
The only line contains four integers n, t, k, d (1 ≤ n, t, k, d ≤ 1 000) — the number of cakes needed, the time needed for one oven to bake k cakes, the number of cakes baked at the same time, the time needed to build the second oven.
Output
If it is reasonable to build the second oven, print "YES". Otherwise print "NO".
Examples
Input
8 6 4 5
Output
YES
Input
8 6 4 6
Output
NO
Input
10 3 11 4
Output
NO
Input
4 2 1 4
Output
YES
Note
In the first example it is possible to get 8 cakes in 12 minutes using one oven. The second oven can be built in 5 minutes, so after 6 minutes the first oven bakes 4 cakes, the second oven bakes 4 more ovens after 11 minutes. Thus, it is reasonable to build the second oven.
In the second example it doesn't matter whether we build the second oven or not, thus it takes 12 minutes to bake 8 cakes in both cases. Thus, it is unreasonable to build the second oven.
In the third example the first oven bakes 11 cakes in 3 minutes, that is more than needed 10. It is unreasonable to build the second oven, because its building takes more time that baking the needed number of cakes using the only oven. | instruction | 0 | 63,601 | 9 | 127,202 |
Tags: brute force, implementation
Correct Solution:
```
# https://codeforces.com/contest/799/problem/A
noOfCakesToBeMade, minsOvenReqToBakeABatchOfCakes, noOfCakesInABatch, minsReqToBuildAOven = [int(x) for x in input().split(' ')]
noOfCakesReady = 0
timer = 0
while timer <= minsReqToBuildAOven:
noOfCakesReady += noOfCakesInABatch
timer += minsOvenReqToBakeABatchOfCakes
if noOfCakesReady < noOfCakesToBeMade:
print('YES')
else:
print('NO')
``` | output | 1 | 63,601 | 9 | 127,203 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In some game by Playrix it takes t minutes for an oven to bake k carrot cakes, all cakes are ready at the same moment t minutes after they started baking. Arkady needs at least n cakes to complete a task, but he currently don't have any. However, he has infinitely many ingredients and one oven. Moreover, Arkady can build one more similar oven to make the process faster, it would take d minutes to build the oven. While the new oven is being built, only old one can bake cakes, after the new oven is built, both ovens bake simultaneously. Arkady can't build more than one oven.
Determine if it is reasonable to build the second oven, i.e. will it decrease the minimum time needed to get n cakes or not. If the time needed with the second oven is the same as with one oven, then it is unreasonable.
Input
The only line contains four integers n, t, k, d (1 ≤ n, t, k, d ≤ 1 000) — the number of cakes needed, the time needed for one oven to bake k cakes, the number of cakes baked at the same time, the time needed to build the second oven.
Output
If it is reasonable to build the second oven, print "YES". Otherwise print "NO".
Examples
Input
8 6 4 5
Output
YES
Input
8 6 4 6
Output
NO
Input
10 3 11 4
Output
NO
Input
4 2 1 4
Output
YES
Note
In the first example it is possible to get 8 cakes in 12 minutes using one oven. The second oven can be built in 5 minutes, so after 6 minutes the first oven bakes 4 cakes, the second oven bakes 4 more ovens after 11 minutes. Thus, it is reasonable to build the second oven.
In the second example it doesn't matter whether we build the second oven or not, thus it takes 12 minutes to bake 8 cakes in both cases. Thus, it is unreasonable to build the second oven.
In the third example the first oven bakes 11 cakes in 3 minutes, that is more than needed 10. It is unreasonable to build the second oven, because its building takes more time that baking the needed number of cakes using the only oven. | instruction | 0 | 63,602 | 9 | 127,204 |
Tags: brute force, implementation
Correct Solution:
```
def main():
ncakes_needed, time_to_bake, kcakes, time_to_build = map(int, input().split())
def is_reasanable(ncakes_needed, time_to_bake, kcakes, time_to_build):
time_spended = 0
new_oven = False
while ncakes_needed > 0:
if time_spended > time_to_build:
kcakes *= 2
new_oven = True
time_spended += time_to_bake
ncakes_needed -= kcakes
return "YES" if new_oven is True else "NO"
print(is_reasanable(ncakes_needed, time_to_bake, kcakes, time_to_build))
if __name__ == '__main__':
main()
``` | output | 1 | 63,602 | 9 | 127,205 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In some game by Playrix it takes t minutes for an oven to bake k carrot cakes, all cakes are ready at the same moment t minutes after they started baking. Arkady needs at least n cakes to complete a task, but he currently don't have any. However, he has infinitely many ingredients and one oven. Moreover, Arkady can build one more similar oven to make the process faster, it would take d minutes to build the oven. While the new oven is being built, only old one can bake cakes, after the new oven is built, both ovens bake simultaneously. Arkady can't build more than one oven.
Determine if it is reasonable to build the second oven, i.e. will it decrease the minimum time needed to get n cakes or not. If the time needed with the second oven is the same as with one oven, then it is unreasonable.
Input
The only line contains four integers n, t, k, d (1 ≤ n, t, k, d ≤ 1 000) — the number of cakes needed, the time needed for one oven to bake k cakes, the number of cakes baked at the same time, the time needed to build the second oven.
Output
If it is reasonable to build the second oven, print "YES". Otherwise print "NO".
Examples
Input
8 6 4 5
Output
YES
Input
8 6 4 6
Output
NO
Input
10 3 11 4
Output
NO
Input
4 2 1 4
Output
YES
Note
In the first example it is possible to get 8 cakes in 12 minutes using one oven. The second oven can be built in 5 minutes, so after 6 minutes the first oven bakes 4 cakes, the second oven bakes 4 more ovens after 11 minutes. Thus, it is reasonable to build the second oven.
In the second example it doesn't matter whether we build the second oven or not, thus it takes 12 minutes to bake 8 cakes in both cases. Thus, it is unreasonable to build the second oven.
In the third example the first oven bakes 11 cakes in 3 minutes, that is more than needed 10. It is unreasonable to build the second oven, because its building takes more time that baking the needed number of cakes using the only oven. | instruction | 0 | 63,603 | 9 | 127,206 |
Tags: brute force, implementation
Correct Solution:
```
import math
n,t,k,d=map(int,input().split())
a = math.ceil(d/t)
n=n-(a*k)
if n>0:
if d%t!=0:
print("YES")
else:
if n>k:
print("YES")
else:
print("NO")
else:
print("NO")
``` | output | 1 | 63,603 | 9 | 127,207 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In some game by Playrix it takes t minutes for an oven to bake k carrot cakes, all cakes are ready at the same moment t minutes after they started baking. Arkady needs at least n cakes to complete a task, but he currently don't have any. However, he has infinitely many ingredients and one oven. Moreover, Arkady can build one more similar oven to make the process faster, it would take d minutes to build the oven. While the new oven is being built, only old one can bake cakes, after the new oven is built, both ovens bake simultaneously. Arkady can't build more than one oven.
Determine if it is reasonable to build the second oven, i.e. will it decrease the minimum time needed to get n cakes or not. If the time needed with the second oven is the same as with one oven, then it is unreasonable.
Input
The only line contains four integers n, t, k, d (1 ≤ n, t, k, d ≤ 1 000) — the number of cakes needed, the time needed for one oven to bake k cakes, the number of cakes baked at the same time, the time needed to build the second oven.
Output
If it is reasonable to build the second oven, print "YES". Otherwise print "NO".
Examples
Input
8 6 4 5
Output
YES
Input
8 6 4 6
Output
NO
Input
10 3 11 4
Output
NO
Input
4 2 1 4
Output
YES
Note
In the first example it is possible to get 8 cakes in 12 minutes using one oven. The second oven can be built in 5 minutes, so after 6 minutes the first oven bakes 4 cakes, the second oven bakes 4 more ovens after 11 minutes. Thus, it is reasonable to build the second oven.
In the second example it doesn't matter whether we build the second oven or not, thus it takes 12 minutes to bake 8 cakes in both cases. Thus, it is unreasonable to build the second oven.
In the third example the first oven bakes 11 cakes in 3 minutes, that is more than needed 10. It is unreasonable to build the second oven, because its building takes more time that baking the needed number of cakes using the only oven. | instruction | 0 | 63,604 | 9 | 127,208 |
Tags: brute force, implementation
Correct Solution:
```
import math
n, t, k, d=map(int,input().split())
if d // t * k + k < n :
print("YES")
else:
print("NO")
``` | output | 1 | 63,604 | 9 | 127,209 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In some game by Playrix it takes t minutes for an oven to bake k carrot cakes, all cakes are ready at the same moment t minutes after they started baking. Arkady needs at least n cakes to complete a task, but he currently don't have any. However, he has infinitely many ingredients and one oven. Moreover, Arkady can build one more similar oven to make the process faster, it would take d minutes to build the oven. While the new oven is being built, only old one can bake cakes, after the new oven is built, both ovens bake simultaneously. Arkady can't build more than one oven.
Determine if it is reasonable to build the second oven, i.e. will it decrease the minimum time needed to get n cakes or not. If the time needed with the second oven is the same as with one oven, then it is unreasonable.
Input
The only line contains four integers n, t, k, d (1 ≤ n, t, k, d ≤ 1 000) — the number of cakes needed, the time needed for one oven to bake k cakes, the number of cakes baked at the same time, the time needed to build the second oven.
Output
If it is reasonable to build the second oven, print "YES". Otherwise print "NO".
Examples
Input
8 6 4 5
Output
YES
Input
8 6 4 6
Output
NO
Input
10 3 11 4
Output
NO
Input
4 2 1 4
Output
YES
Note
In the first example it is possible to get 8 cakes in 12 minutes using one oven. The second oven can be built in 5 minutes, so after 6 minutes the first oven bakes 4 cakes, the second oven bakes 4 more ovens after 11 minutes. Thus, it is reasonable to build the second oven.
In the second example it doesn't matter whether we build the second oven or not, thus it takes 12 minutes to bake 8 cakes in both cases. Thus, it is unreasonable to build the second oven.
In the third example the first oven bakes 11 cakes in 3 minutes, that is more than needed 10. It is unreasonable to build the second oven, because its building takes more time that baking the needed number of cakes using the only oven. | instruction | 0 | 63,605 | 9 | 127,210 |
Tags: brute force, implementation
Correct Solution:
```
import math
a=input()
a=a.split(" ")
a=[int(x) for x in a]
n=a[0]
t=a[1]
k=a[2]
d=a[3]
t1=math.ceil(n/k)*t
#print(t1)
#t2=d+math.ceil((n-k*math.ceil(d/t))/(2*k))*t
if (t1-d)/t>1:
print("YES")
else:
print("NO")
``` | output | 1 | 63,605 | 9 | 127,211 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In some game by Playrix it takes t minutes for an oven to bake k carrot cakes, all cakes are ready at the same moment t minutes after they started baking. Arkady needs at least n cakes to complete a task, but he currently don't have any. However, he has infinitely many ingredients and one oven. Moreover, Arkady can build one more similar oven to make the process faster, it would take d minutes to build the oven. While the new oven is being built, only old one can bake cakes, after the new oven is built, both ovens bake simultaneously. Arkady can't build more than one oven.
Determine if it is reasonable to build the second oven, i.e. will it decrease the minimum time needed to get n cakes or not. If the time needed with the second oven is the same as with one oven, then it is unreasonable.
Input
The only line contains four integers n, t, k, d (1 ≤ n, t, k, d ≤ 1 000) — the number of cakes needed, the time needed for one oven to bake k cakes, the number of cakes baked at the same time, the time needed to build the second oven.
Output
If it is reasonable to build the second oven, print "YES". Otherwise print "NO".
Examples
Input
8 6 4 5
Output
YES
Input
8 6 4 6
Output
NO
Input
10 3 11 4
Output
NO
Input
4 2 1 4
Output
YES
Note
In the first example it is possible to get 8 cakes in 12 minutes using one oven. The second oven can be built in 5 minutes, so after 6 minutes the first oven bakes 4 cakes, the second oven bakes 4 more ovens after 11 minutes. Thus, it is reasonable to build the second oven.
In the second example it doesn't matter whether we build the second oven or not, thus it takes 12 minutes to bake 8 cakes in both cases. Thus, it is unreasonable to build the second oven.
In the third example the first oven bakes 11 cakes in 3 minutes, that is more than needed 10. It is unreasonable to build the second oven, because its building takes more time that baking the needed number of cakes using the only oven. | instruction | 0 | 63,606 | 9 | 127,212 |
Tags: brute force, implementation
Correct Solution:
```
n, t, k, d = [int(n) for n in input().split()]
if (n%k) != 0:
a = (int(n/k)+1)*t
else:
a = int(n/k)*t
if (d+t < a):
print("YES")
else:
print("NO")
``` | output | 1 | 63,606 | 9 | 127,213 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In some game by Playrix it takes t minutes for an oven to bake k carrot cakes, all cakes are ready at the same moment t minutes after they started baking. Arkady needs at least n cakes to complete a task, but he currently don't have any. However, he has infinitely many ingredients and one oven. Moreover, Arkady can build one more similar oven to make the process faster, it would take d minutes to build the oven. While the new oven is being built, only old one can bake cakes, after the new oven is built, both ovens bake simultaneously. Arkady can't build more than one oven.
Determine if it is reasonable to build the second oven, i.e. will it decrease the minimum time needed to get n cakes or not. If the time needed with the second oven is the same as with one oven, then it is unreasonable.
Input
The only line contains four integers n, t, k, d (1 ≤ n, t, k, d ≤ 1 000) — the number of cakes needed, the time needed for one oven to bake k cakes, the number of cakes baked at the same time, the time needed to build the second oven.
Output
If it is reasonable to build the second oven, print "YES". Otherwise print "NO".
Examples
Input
8 6 4 5
Output
YES
Input
8 6 4 6
Output
NO
Input
10 3 11 4
Output
NO
Input
4 2 1 4
Output
YES
Note
In the first example it is possible to get 8 cakes in 12 minutes using one oven. The second oven can be built in 5 minutes, so after 6 minutes the first oven bakes 4 cakes, the second oven bakes 4 more ovens after 11 minutes. Thus, it is reasonable to build the second oven.
In the second example it doesn't matter whether we build the second oven or not, thus it takes 12 minutes to bake 8 cakes in both cases. Thus, it is unreasonable to build the second oven.
In the third example the first oven bakes 11 cakes in 3 minutes, that is more than needed 10. It is unreasonable to build the second oven, because its building takes more time that baking the needed number of cakes using the only oven. | instruction | 0 | 63,607 | 9 | 127,214 |
Tags: brute force, implementation
Correct Solution:
```
#!/usr/bin/env python3
from sys import stdin,stdout
def readint():
return map(int, stdin.readline().split())
#lines = stdin.readlines()
n, t, k, d = readint()
tt = (n//k)*t
if n%k:
tt += t
if tt > d+t:
print("YES")
else:
print("NO")
``` | output | 1 | 63,607 | 9 | 127,215 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In some game by Playrix it takes t minutes for an oven to bake k carrot cakes, all cakes are ready at the same moment t minutes after they started baking. Arkady needs at least n cakes to complete a task, but he currently don't have any. However, he has infinitely many ingredients and one oven. Moreover, Arkady can build one more similar oven to make the process faster, it would take d minutes to build the oven. While the new oven is being built, only old one can bake cakes, after the new oven is built, both ovens bake simultaneously. Arkady can't build more than one oven.
Determine if it is reasonable to build the second oven, i.e. will it decrease the minimum time needed to get n cakes or not. If the time needed with the second oven is the same as with one oven, then it is unreasonable.
Input
The only line contains four integers n, t, k, d (1 ≤ n, t, k, d ≤ 1 000) — the number of cakes needed, the time needed for one oven to bake k cakes, the number of cakes baked at the same time, the time needed to build the second oven.
Output
If it is reasonable to build the second oven, print "YES". Otherwise print "NO".
Examples
Input
8 6 4 5
Output
YES
Input
8 6 4 6
Output
NO
Input
10 3 11 4
Output
NO
Input
4 2 1 4
Output
YES
Note
In the first example it is possible to get 8 cakes in 12 minutes using one oven. The second oven can be built in 5 minutes, so after 6 minutes the first oven bakes 4 cakes, the second oven bakes 4 more ovens after 11 minutes. Thus, it is reasonable to build the second oven.
In the second example it doesn't matter whether we build the second oven or not, thus it takes 12 minutes to bake 8 cakes in both cases. Thus, it is unreasonable to build the second oven.
In the third example the first oven bakes 11 cakes in 3 minutes, that is more than needed 10. It is unreasonable to build the second oven, because its building takes more time that baking the needed number of cakes using the only oven.
Submitted Solution:
```
from math import ceil
n, t, k, d = map(int,input().split())
time_o = ceil( n / k ) * t
if d + t >= time_o:
print('NO')
else:
print('YES')
``` | instruction | 0 | 63,608 | 9 | 127,216 |
Yes | output | 1 | 63,608 | 9 | 127,217 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In some game by Playrix it takes t minutes for an oven to bake k carrot cakes, all cakes are ready at the same moment t minutes after they started baking. Arkady needs at least n cakes to complete a task, but he currently don't have any. However, he has infinitely many ingredients and one oven. Moreover, Arkady can build one more similar oven to make the process faster, it would take d minutes to build the oven. While the new oven is being built, only old one can bake cakes, after the new oven is built, both ovens bake simultaneously. Arkady can't build more than one oven.
Determine if it is reasonable to build the second oven, i.e. will it decrease the minimum time needed to get n cakes or not. If the time needed with the second oven is the same as with one oven, then it is unreasonable.
Input
The only line contains four integers n, t, k, d (1 ≤ n, t, k, d ≤ 1 000) — the number of cakes needed, the time needed for one oven to bake k cakes, the number of cakes baked at the same time, the time needed to build the second oven.
Output
If it is reasonable to build the second oven, print "YES". Otherwise print "NO".
Examples
Input
8 6 4 5
Output
YES
Input
8 6 4 6
Output
NO
Input
10 3 11 4
Output
NO
Input
4 2 1 4
Output
YES
Note
In the first example it is possible to get 8 cakes in 12 minutes using one oven. The second oven can be built in 5 minutes, so after 6 minutes the first oven bakes 4 cakes, the second oven bakes 4 more ovens after 11 minutes. Thus, it is reasonable to build the second oven.
In the second example it doesn't matter whether we build the second oven or not, thus it takes 12 minutes to bake 8 cakes in both cases. Thus, it is unreasonable to build the second oven.
In the third example the first oven bakes 11 cakes in 3 minutes, that is more than needed 10. It is unreasonable to build the second oven, because its building takes more time that baking the needed number of cakes using the only oven.
Submitted Solution:
```
"""609C"""
def main():
n,t,k,d = map(int,input().split())
if ((d//t)+1)*k >=n :
print("NO")
else:
print("YES")
main()
``` | instruction | 0 | 63,609 | 9 | 127,218 |
Yes | output | 1 | 63,609 | 9 | 127,219 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In some game by Playrix it takes t minutes for an oven to bake k carrot cakes, all cakes are ready at the same moment t minutes after they started baking. Arkady needs at least n cakes to complete a task, but he currently don't have any. However, he has infinitely many ingredients and one oven. Moreover, Arkady can build one more similar oven to make the process faster, it would take d minutes to build the oven. While the new oven is being built, only old one can bake cakes, after the new oven is built, both ovens bake simultaneously. Arkady can't build more than one oven.
Determine if it is reasonable to build the second oven, i.e. will it decrease the minimum time needed to get n cakes or not. If the time needed with the second oven is the same as with one oven, then it is unreasonable.
Input
The only line contains four integers n, t, k, d (1 ≤ n, t, k, d ≤ 1 000) — the number of cakes needed, the time needed for one oven to bake k cakes, the number of cakes baked at the same time, the time needed to build the second oven.
Output
If it is reasonable to build the second oven, print "YES". Otherwise print "NO".
Examples
Input
8 6 4 5
Output
YES
Input
8 6 4 6
Output
NO
Input
10 3 11 4
Output
NO
Input
4 2 1 4
Output
YES
Note
In the first example it is possible to get 8 cakes in 12 minutes using one oven. The second oven can be built in 5 minutes, so after 6 minutes the first oven bakes 4 cakes, the second oven bakes 4 more ovens after 11 minutes. Thus, it is reasonable to build the second oven.
In the second example it doesn't matter whether we build the second oven or not, thus it takes 12 minutes to bake 8 cakes in both cases. Thus, it is unreasonable to build the second oven.
In the third example the first oven bakes 11 cakes in 3 minutes, that is more than needed 10. It is unreasonable to build the second oven, because its building takes more time that baking the needed number of cakes using the only oven.
Submitted Solution:
```
import math
n,t,k,d = map(int,input().split())
baking_time = math.ceil(n / k) * t
for i in range(0,d+1,t) :
# print(i)
n-= k
if n > 0 :
print("YES")
else :
print("No")
# print(n)
``` | instruction | 0 | 63,610 | 9 | 127,220 |
Yes | output | 1 | 63,610 | 9 | 127,221 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In some game by Playrix it takes t minutes for an oven to bake k carrot cakes, all cakes are ready at the same moment t minutes after they started baking. Arkady needs at least n cakes to complete a task, but he currently don't have any. However, he has infinitely many ingredients and one oven. Moreover, Arkady can build one more similar oven to make the process faster, it would take d minutes to build the oven. While the new oven is being built, only old one can bake cakes, after the new oven is built, both ovens bake simultaneously. Arkady can't build more than one oven.
Determine if it is reasonable to build the second oven, i.e. will it decrease the minimum time needed to get n cakes or not. If the time needed with the second oven is the same as with one oven, then it is unreasonable.
Input
The only line contains four integers n, t, k, d (1 ≤ n, t, k, d ≤ 1 000) — the number of cakes needed, the time needed for one oven to bake k cakes, the number of cakes baked at the same time, the time needed to build the second oven.
Output
If it is reasonable to build the second oven, print "YES". Otherwise print "NO".
Examples
Input
8 6 4 5
Output
YES
Input
8 6 4 6
Output
NO
Input
10 3 11 4
Output
NO
Input
4 2 1 4
Output
YES
Note
In the first example it is possible to get 8 cakes in 12 minutes using one oven. The second oven can be built in 5 minutes, so after 6 minutes the first oven bakes 4 cakes, the second oven bakes 4 more ovens after 11 minutes. Thus, it is reasonable to build the second oven.
In the second example it doesn't matter whether we build the second oven or not, thus it takes 12 minutes to bake 8 cakes in both cases. Thus, it is unreasonable to build the second oven.
In the third example the first oven bakes 11 cakes in 3 minutes, that is more than needed 10. It is unreasonable to build the second oven, because its building takes more time that baking the needed number of cakes using the only oven.
Submitted Solution:
```
from math import ceil
n, t, k, d = map(int, input().split())
time_one_oven = ceil(n / k) * t
cakes_while_building_new_oven = ceil(d / t) * k
remaining_cakes = n - cakes_while_building_new_oven
if remaining_cakes < 0:
remaining_cakes = 0
time_two_ovens = d + max(ceil(cakes_while_building_new_oven / k) * t - d, ceil(remaining_cakes / (2 * k)) * t)
if time_two_ovens < time_one_oven:
print("YES")
else:
print("NO")
``` | instruction | 0 | 63,611 | 9 | 127,222 |
Yes | output | 1 | 63,611 | 9 | 127,223 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In some game by Playrix it takes t minutes for an oven to bake k carrot cakes, all cakes are ready at the same moment t minutes after they started baking. Arkady needs at least n cakes to complete a task, but he currently don't have any. However, he has infinitely many ingredients and one oven. Moreover, Arkady can build one more similar oven to make the process faster, it would take d minutes to build the oven. While the new oven is being built, only old one can bake cakes, after the new oven is built, both ovens bake simultaneously. Arkady can't build more than one oven.
Determine if it is reasonable to build the second oven, i.e. will it decrease the minimum time needed to get n cakes or not. If the time needed with the second oven is the same as with one oven, then it is unreasonable.
Input
The only line contains four integers n, t, k, d (1 ≤ n, t, k, d ≤ 1 000) — the number of cakes needed, the time needed for one oven to bake k cakes, the number of cakes baked at the same time, the time needed to build the second oven.
Output
If it is reasonable to build the second oven, print "YES". Otherwise print "NO".
Examples
Input
8 6 4 5
Output
YES
Input
8 6 4 6
Output
NO
Input
10 3 11 4
Output
NO
Input
4 2 1 4
Output
YES
Note
In the first example it is possible to get 8 cakes in 12 minutes using one oven. The second oven can be built in 5 minutes, so after 6 minutes the first oven bakes 4 cakes, the second oven bakes 4 more ovens after 11 minutes. Thus, it is reasonable to build the second oven.
In the second example it doesn't matter whether we build the second oven or not, thus it takes 12 minutes to bake 8 cakes in both cases. Thus, it is unreasonable to build the second oven.
In the third example the first oven bakes 11 cakes in 3 minutes, that is more than needed 10. It is unreasonable to build the second oven, because its building takes more time that baking the needed number of cakes using the only oven.
Submitted Solution:
```
from sys import maxsize, stdout, stdin, stderr
# mod = int(1e9 + 7)
import re # can use multiple splits
tup = lambda: map(int, stdin.readline().split())
I = lambda: int(stdin.readline())
lint = lambda: [int(x) for x in stdin.readline().split()]
S = lambda: stdin.readline().replace('\n', '').strip()
def grid(r, c): return [lint() for i in range(r)]
def debug(*args, c=6): print('\033[3{}m'.format(c), *args, '\033[0m', file=stderr)
stpr = lambda x : stdout.write(f'{x}' + '\n')
star = lambda x : print(' '.join(map(str , x)))
from math import ceil
n , t , k , d = tup()
cnta , cntb = 0,d
ni = n
while n >0:
n-=k
cnta+=k
while ni > 0:
ni-=(2*k)
cntb+=t
#print(cnta,cntb)
if cntb < cnta:
print("YES")
else:print("NO")
``` | instruction | 0 | 63,612 | 9 | 127,224 |
No | output | 1 | 63,612 | 9 | 127,225 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In some game by Playrix it takes t minutes for an oven to bake k carrot cakes, all cakes are ready at the same moment t minutes after they started baking. Arkady needs at least n cakes to complete a task, but he currently don't have any. However, he has infinitely many ingredients and one oven. Moreover, Arkady can build one more similar oven to make the process faster, it would take d minutes to build the oven. While the new oven is being built, only old one can bake cakes, after the new oven is built, both ovens bake simultaneously. Arkady can't build more than one oven.
Determine if it is reasonable to build the second oven, i.e. will it decrease the minimum time needed to get n cakes or not. If the time needed with the second oven is the same as with one oven, then it is unreasonable.
Input
The only line contains four integers n, t, k, d (1 ≤ n, t, k, d ≤ 1 000) — the number of cakes needed, the time needed for one oven to bake k cakes, the number of cakes baked at the same time, the time needed to build the second oven.
Output
If it is reasonable to build the second oven, print "YES". Otherwise print "NO".
Examples
Input
8 6 4 5
Output
YES
Input
8 6 4 6
Output
NO
Input
10 3 11 4
Output
NO
Input
4 2 1 4
Output
YES
Note
In the first example it is possible to get 8 cakes in 12 minutes using one oven. The second oven can be built in 5 minutes, so after 6 minutes the first oven bakes 4 cakes, the second oven bakes 4 more ovens after 11 minutes. Thus, it is reasonable to build the second oven.
In the second example it doesn't matter whether we build the second oven or not, thus it takes 12 minutes to bake 8 cakes in both cases. Thus, it is unreasonable to build the second oven.
In the third example the first oven bakes 11 cakes in 3 minutes, that is more than needed 10. It is unreasonable to build the second oven, because its building takes more time that baking the needed number of cakes using the only oven.
Submitted Solution:
```
import operator as op
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import reduce
from itertools import (
accumulate, combinations, combinations_with_replacement, groupby,
permutations, product)
from math import (acos, asin, atan, ceil, cos, degrees, factorial, gcd, hypot,
log2, pi, radians, sin, sqrt, tan)
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits
def inp():
return(int(input()))
def inlist():
return(list(map(int, input().split())))
def instr():
s = input()
return(list(s[:len(s)]))
def invr():
return(map(int, input().split()))
def def_value():
return 0
def time_lagbe(n, k, t):
if n == 0:
return 0
if k > n:
return t
time1 = (n // k)*t + (n % k)*t
return time1
# For getting input from input.txt file
#sys.stdin = open('input.txt', 'r')
# Printing the Output to output.txt file
#sys.stdout = open('output.txt', 'w')
n, t, k, d = invr()
TIME = [0]*1001
TIME2 = [0]*1001
for i in range(t, 1001, t):
TIME[i] = k*(i//t)
for i in range(d+t, 1001, t):
TIME2[i] = k * (i//t) * 2
res = "NO"
for i in range(1001):
if TIME[i] < n:
if TIME2[i] > TIME[i]:
res = "YES"
print(i)
break
else:
break
# print(TIME[:20])
# print(TIME2[:20])
print(res)
``` | instruction | 0 | 63,613 | 9 | 127,226 |
No | output | 1 | 63,613 | 9 | 127,227 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In some game by Playrix it takes t minutes for an oven to bake k carrot cakes, all cakes are ready at the same moment t minutes after they started baking. Arkady needs at least n cakes to complete a task, but he currently don't have any. However, he has infinitely many ingredients and one oven. Moreover, Arkady can build one more similar oven to make the process faster, it would take d minutes to build the oven. While the new oven is being built, only old one can bake cakes, after the new oven is built, both ovens bake simultaneously. Arkady can't build more than one oven.
Determine if it is reasonable to build the second oven, i.e. will it decrease the minimum time needed to get n cakes or not. If the time needed with the second oven is the same as with one oven, then it is unreasonable.
Input
The only line contains four integers n, t, k, d (1 ≤ n, t, k, d ≤ 1 000) — the number of cakes needed, the time needed for one oven to bake k cakes, the number of cakes baked at the same time, the time needed to build the second oven.
Output
If it is reasonable to build the second oven, print "YES". Otherwise print "NO".
Examples
Input
8 6 4 5
Output
YES
Input
8 6 4 6
Output
NO
Input
10 3 11 4
Output
NO
Input
4 2 1 4
Output
YES
Note
In the first example it is possible to get 8 cakes in 12 minutes using one oven. The second oven can be built in 5 minutes, so after 6 minutes the first oven bakes 4 cakes, the second oven bakes 4 more ovens after 11 minutes. Thus, it is reasonable to build the second oven.
In the second example it doesn't matter whether we build the second oven or not, thus it takes 12 minutes to bake 8 cakes in both cases. Thus, it is unreasonable to build the second oven.
In the third example the first oven bakes 11 cakes in 3 minutes, that is more than needed 10. It is unreasonable to build the second oven, because its building takes more time that baking the needed number of cakes using the only oven.
Submitted Solution:
```
import sys
n,t,k,d=input().split()
m=int(int(n)//int(k))
q=int(int(n)%int(k))
if int(n)>int(k) and int(q)==0 and (int(m)*int(t))>int(t)+int(d):
print("YES")
else:
print("NO")
``` | instruction | 0 | 63,614 | 9 | 127,228 |
No | output | 1 | 63,614 | 9 | 127,229 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In some game by Playrix it takes t minutes for an oven to bake k carrot cakes, all cakes are ready at the same moment t minutes after they started baking. Arkady needs at least n cakes to complete a task, but he currently don't have any. However, he has infinitely many ingredients and one oven. Moreover, Arkady can build one more similar oven to make the process faster, it would take d minutes to build the oven. While the new oven is being built, only old one can bake cakes, after the new oven is built, both ovens bake simultaneously. Arkady can't build more than one oven.
Determine if it is reasonable to build the second oven, i.e. will it decrease the minimum time needed to get n cakes or not. If the time needed with the second oven is the same as with one oven, then it is unreasonable.
Input
The only line contains four integers n, t, k, d (1 ≤ n, t, k, d ≤ 1 000) — the number of cakes needed, the time needed for one oven to bake k cakes, the number of cakes baked at the same time, the time needed to build the second oven.
Output
If it is reasonable to build the second oven, print "YES". Otherwise print "NO".
Examples
Input
8 6 4 5
Output
YES
Input
8 6 4 6
Output
NO
Input
10 3 11 4
Output
NO
Input
4 2 1 4
Output
YES
Note
In the first example it is possible to get 8 cakes in 12 minutes using one oven. The second oven can be built in 5 minutes, so after 6 minutes the first oven bakes 4 cakes, the second oven bakes 4 more ovens after 11 minutes. Thus, it is reasonable to build the second oven.
In the second example it doesn't matter whether we build the second oven or not, thus it takes 12 minutes to bake 8 cakes in both cases. Thus, it is unreasonable to build the second oven.
In the third example the first oven bakes 11 cakes in 3 minutes, that is more than needed 10. It is unreasonable to build the second oven, because its building takes more time that baking the needed number of cakes using the only oven.
Submitted Solution:
```
a = list(map(int,input().split()))
n = a[0]
t = a[1]
k = a[2]
d = a[3]
count_1 = (n / k) * t
count_2 = d + t
if count_1 > count_2:
print("YES")
else:
print("NO")
``` | instruction | 0 | 63,615 | 9 | 127,230 |
No | output | 1 | 63,615 | 9 | 127,231 |
Provide a correct Python 3 solution for this coding contest problem.
Problem
Gaccho owns an N-sided field and M potatoes. Each field is numbered from 1 to N. Gaccho wants to increase the number of potatoes by planting and harvesting potatoes in the field.
Gaccho lives alone and can only manage fields up to the K side. In addition, the soil condition and area of each field vary, and the number of potatoes harvested and the number of potatoes that can be planted also vary. When potatoes are planted in field i, ai potatoes can be harvested for each potato planted in field i one year later. However, only bi potatoes can be planted in the field i at the maximum.
When you plant M or less potatoes in a field within K side, please find the maximum number of potatoes you can own one year later.
Constraints
* 1 ≤ N ≤ 15
* 1 ≤ M ≤ 104
* 1 ≤ K ≤ min (N, 3)
* 1 ≤ ai ≤ 103
* 1 ≤ bi ≤ 104
Input
The input is given in the following format.
NMK
a1 a2 ... aN
b1 b2 ... bN
Three integers N, M, K are given on the first line, separated by blanks.
N integers ai are given on the second line, separated by blanks.
N integers bi are given on the third line, separated by blanks.
Output
Output the maximum number of potatoes in one line.
Examples
Input
5 100 3
2 3 4 5 6
50 40 20 10 5
Output
280
Input
5 100 3
2 3 4 5 100
50 40 20 10 1
Output
339 | instruction | 0 | 63,945 | 9 | 127,890 |
"Correct Solution:
```
n, m, k = map(int, input().split())
aList = list(map(int, input().split()))
bList = list(map(int, input().split()))
abList = sorted(tuple(zip(aList, bList)), key=lambda x:-x[0])
ans = 0
#dp[y][x] ... y面x個の最大値
dp = [[0] * (m + 1) for _ in range(k + 1)]
for a, b in abList:
for y in range(k - 1, -1, -1):
for x in range(m - 1, -1, -1):
use = min(b, m - x)
dp[y + 1][x + use] = max(dp[y + 1][x + use], dp[y][x] + use * a)
ans = 0
for y in range(k + 1):
for x in range(m + 1):
ans = max(ans, dp[y][x] + m - x)
print(ans)
``` | output | 1 | 63,945 | 9 | 127,891 |
Provide a correct Python 3 solution for this coding contest problem.
There are N dishes, numbered 1, 2, \ldots, N. Initially, for each i (1 \leq i \leq N), Dish i has a_i (1 \leq a_i \leq 3) pieces of sushi on it.
Taro will perform the following operation repeatedly until all the pieces of sushi are eaten:
* Roll a die that shows the numbers 1, 2, \ldots, N with equal probabilities, and let i be the outcome. If there are some pieces of sushi on Dish i, eat one of them; if there is none, do nothing.
Find the expected number of times the operation is performed before all the pieces of sushi are eaten.
Constraints
* All values in input are integers.
* 1 \leq N \leq 300
* 1 \leq a_i \leq 3
Input
Input is given from Standard Input in the following format:
N
a_1 a_2 \ldots a_N
Output
Print the expected number of times the operation is performed before all the pieces of sushi are eaten. The output is considered correct when the relative difference is not greater than 10^{-9}.
Examples
Input
3
1 1 1
Output
5.5
Input
1
3
Output
3
Input
2
1 2
Output
4.5
Input
10
1 3 2 3 3 2 3 2 1 3
Output
54.48064457488221 | instruction | 0 | 64,639 | 9 | 129,278 |
"Correct Solution:
```
n = int(input())
a = list(map(int,input().split()))
ones , twos, threes = 0,0,0
for i in a:
if i ==1:
ones+=1
elif i ==2:
twos+=1
else:
threes+=1
max_ones = ones+twos+threes
max_twos = twos+threes
max_threes = threes
# dp[n][n][n]
dp = [[[0.0]*(n+1) for i in range(n+1)] for j in range(n+1)]
for k in range(max_threes+1):
for j in range(max_twos+1-k):
for i in range(max_ones+1-j-k):
if i+j+k==0:
continue
else:
dp[i][j][k] = n/(i+j+k)
if i>0:
dp[i][j][k] += (dp[i-1][j][k]*i)/(i+j+k)
if j>0:
dp[i][j][k] += (dp[i+1][j-1][k]*j)/(i+j+k)
if k>0:
dp[i][j][k] += (dp[i][j+1][k-1]*k)/(i+j+k)
print(dp[i][j][k])
``` | output | 1 | 64,639 | 9 | 129,279 |
Provide a correct Python 3 solution for this coding contest problem.
There are N dishes, numbered 1, 2, \ldots, N. Initially, for each i (1 \leq i \leq N), Dish i has a_i (1 \leq a_i \leq 3) pieces of sushi on it.
Taro will perform the following operation repeatedly until all the pieces of sushi are eaten:
* Roll a die that shows the numbers 1, 2, \ldots, N with equal probabilities, and let i be the outcome. If there are some pieces of sushi on Dish i, eat one of them; if there is none, do nothing.
Find the expected number of times the operation is performed before all the pieces of sushi are eaten.
Constraints
* All values in input are integers.
* 1 \leq N \leq 300
* 1 \leq a_i \leq 3
Input
Input is given from Standard Input in the following format:
N
a_1 a_2 \ldots a_N
Output
Print the expected number of times the operation is performed before all the pieces of sushi are eaten. The output is considered correct when the relative difference is not greater than 10^{-9}.
Examples
Input
3
1 1 1
Output
5.5
Input
1
3
Output
3
Input
2
1 2
Output
4.5
Input
10
1 3 2 3 3 2 3 2 1 3
Output
54.48064457488221 | instruction | 0 | 64,640 | 9 | 129,280 |
"Correct Solution:
```
def main():
n=int(input())
A=[0]*3
for i in map(int,input().split()):
A[i-1]+=1
dp=[[[0]*(n+2)for _ in range(n+2)]for __ in range(n+2)]
for i in range(A[2]+1):
for j in range(n-A[0]-i+1):
for k in range(n-i-j+1):
if i+j+k!=0:
dp[i][j][k]=(dp[i-1][j+1][k]*i+dp[i][j-1][k+1]*j+dp[i][j][k-1]*k+n)/(i+j+k)
i,j,k=A
print(dp[k][j][i])
main()
``` | output | 1 | 64,640 | 9 | 129,281 |
Provide a correct Python 3 solution for this coding contest problem.
There are N dishes, numbered 1, 2, \ldots, N. Initially, for each i (1 \leq i \leq N), Dish i has a_i (1 \leq a_i \leq 3) pieces of sushi on it.
Taro will perform the following operation repeatedly until all the pieces of sushi are eaten:
* Roll a die that shows the numbers 1, 2, \ldots, N with equal probabilities, and let i be the outcome. If there are some pieces of sushi on Dish i, eat one of them; if there is none, do nothing.
Find the expected number of times the operation is performed before all the pieces of sushi are eaten.
Constraints
* All values in input are integers.
* 1 \leq N \leq 300
* 1 \leq a_i \leq 3
Input
Input is given from Standard Input in the following format:
N
a_1 a_2 \ldots a_N
Output
Print the expected number of times the operation is performed before all the pieces of sushi are eaten. The output is considered correct when the relative difference is not greater than 10^{-9}.
Examples
Input
3
1 1 1
Output
5.5
Input
1
3
Output
3
Input
2
1 2
Output
4.5
Input
10
1 3 2 3 3 2 3 2 1 3
Output
54.48064457488221 | instruction | 0 | 64,641 | 9 | 129,282 |
"Correct Solution:
```
from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))
dic = defaultdict(int)
for a in A:
dic[a] += 1
a = dic[1]
b = dic[2]
c = dic[3]
dp = [[[0 for k in range(N+1)] for j in range(N+1)] for i in range(N+1)]
dp[a+b][a][0] = 1
for i in range(a+b,N+1):
for j in range(a,i+1):
for k in range(j+1):
p,q,r = j-k,i-j,N-i
if p:
dp[i][j][k+1] += dp[i][j][k] * p/(p+q+r)
if q:
dp[i][j+1][k] += dp[i][j][k] * q/(p+q+r)
if r:
dp[i+1][j][k] += dp[i][j][k] * r/(p+q+r)
ans = 0
for i in range(a+b,N+1):
for j in range(a,i+1):
for k in range(j+1):
p,q,r = j-k,i-j,N-i
if p:
ans += dp[i][j][k]*N/(p+q+r)*p/(p+q+r)
if q:
ans += dp[i][j][k]*N/(p+q+r)*q/(p+q+r)
if r:
ans += dp[i][j][k]*N/(p+q+r)*r/(p+q+r)
print(ans)
``` | output | 1 | 64,641 | 9 | 129,283 |
Provide a correct Python 3 solution for this coding contest problem.
There are N dishes, numbered 1, 2, \ldots, N. Initially, for each i (1 \leq i \leq N), Dish i has a_i (1 \leq a_i \leq 3) pieces of sushi on it.
Taro will perform the following operation repeatedly until all the pieces of sushi are eaten:
* Roll a die that shows the numbers 1, 2, \ldots, N with equal probabilities, and let i be the outcome. If there are some pieces of sushi on Dish i, eat one of them; if there is none, do nothing.
Find the expected number of times the operation is performed before all the pieces of sushi are eaten.
Constraints
* All values in input are integers.
* 1 \leq N \leq 300
* 1 \leq a_i \leq 3
Input
Input is given from Standard Input in the following format:
N
a_1 a_2 \ldots a_N
Output
Print the expected number of times the operation is performed before all the pieces of sushi are eaten. The output is considered correct when the relative difference is not greater than 10^{-9}.
Examples
Input
3
1 1 1
Output
5.5
Input
1
3
Output
3
Input
2
1 2
Output
4.5
Input
10
1 3 2 3 3 2 3 2 1 3
Output
54.48064457488221 | instruction | 0 | 64,642 | 9 | 129,284 |
"Correct Solution:
```
def main():
import sys
input = sys.stdin.buffer.readline
N = int(input())
a = list(map(int, input().split()))
c1, c2, c3 = 0, 0, 0
for aa in a:
if aa == 1:
c1 += 1
elif aa == 2:
c2 += 1
else:
c3 += 1
dp = [[[0]*(N+1) for _ in range(N+1)] for _ in range(N+1)]
# メモ化再帰ではpypy3でもTLEするのでforループを使う
# j==k==0の場合を計算 → k==0の場合を計算 → 一般の場合を計算
for k in range(c3+1):
for j in range(c3+c2-k+1):
for i in range(N-j-k+1):
if i == j == k == 0:
continue
else:
tmp = N
if i > 0: # IndexError防止
tmp += dp[k][j][i-1]*i
if j > 0:
tmp += dp[k][j-1][i+1]*j
if k > 0:
tmp += dp[k-1][j+1][i]*k
dp[k][j][i] = tmp/(i+j+k) # 割り算をまとめないとTLE
print(dp[c3][c2][c1])
if __name__ == '__main__':
main()
``` | output | 1 | 64,642 | 9 | 129,285 |
Provide a correct Python 3 solution for this coding contest problem.
There are N dishes, numbered 1, 2, \ldots, N. Initially, for each i (1 \leq i \leq N), Dish i has a_i (1 \leq a_i \leq 3) pieces of sushi on it.
Taro will perform the following operation repeatedly until all the pieces of sushi are eaten:
* Roll a die that shows the numbers 1, 2, \ldots, N with equal probabilities, and let i be the outcome. If there are some pieces of sushi on Dish i, eat one of them; if there is none, do nothing.
Find the expected number of times the operation is performed before all the pieces of sushi are eaten.
Constraints
* All values in input are integers.
* 1 \leq N \leq 300
* 1 \leq a_i \leq 3
Input
Input is given from Standard Input in the following format:
N
a_1 a_2 \ldots a_N
Output
Print the expected number of times the operation is performed before all the pieces of sushi are eaten. The output is considered correct when the relative difference is not greater than 10^{-9}.
Examples
Input
3
1 1 1
Output
5.5
Input
1
3
Output
3
Input
2
1 2
Output
4.5
Input
10
1 3 2 3 3 2 3 2 1 3
Output
54.48064457488221 | instruction | 0 | 64,643 | 9 | 129,286 |
"Correct Solution:
```
from collections import Counter
def main():
N = int(input())
a = Counter(map(int, input().split()))
a1, a2, a3 = a.get(1, 0), a.get(2, 0), a.get(3, 0)
a123 = a1 + a2 + a3 + 1
u = [[0.0] * (a123 - c2) for c2 in range(a123)]
v = [[0.0] * (a123 - c2) for c2 in range(a123)]
t1 = 0.0
v2 = v[0]
for c1 in range(1, a123):
v2[c1] = t1 = N / c1 + t1
for c2 in range(1, a123):
v2 = v[c2]
for c1, t2 in zip(range(301 - c2), v[c2 - 1][1:]):
v2[c1] = t1 = (N + c1 * t1 + c2 * t2) / (c1 + c2)
for c3 in range(1, a3 + 1):
u, v = v, u
v2 = v[0]
for c1, t3 in zip(range(a123 - c3), u[1]):
v2[c1] = t1 = (N + c1 * t1 + c3 * t3) / (c1 + c3)
for c2 in range(1, a123 - c3):
v2 = v[c2]
c23 = c2 + c3
for c1, t2, t3 in zip(range(a123 - c3 - c2), v[c2 - 1][1:], u[c2 + 1]):
v2[c1] = t1 = (N + c1 * t1 + c2 * t2 + c3 * t3) / (c1 + c23)
print(v[a2][a1])
main()
``` | output | 1 | 64,643 | 9 | 129,287 |
Provide a correct Python 3 solution for this coding contest problem.
There are N dishes, numbered 1, 2, \ldots, N. Initially, for each i (1 \leq i \leq N), Dish i has a_i (1 \leq a_i \leq 3) pieces of sushi on it.
Taro will perform the following operation repeatedly until all the pieces of sushi are eaten:
* Roll a die that shows the numbers 1, 2, \ldots, N with equal probabilities, and let i be the outcome. If there are some pieces of sushi on Dish i, eat one of them; if there is none, do nothing.
Find the expected number of times the operation is performed before all the pieces of sushi are eaten.
Constraints
* All values in input are integers.
* 1 \leq N \leq 300
* 1 \leq a_i \leq 3
Input
Input is given from Standard Input in the following format:
N
a_1 a_2 \ldots a_N
Output
Print the expected number of times the operation is performed before all the pieces of sushi are eaten. The output is considered correct when the relative difference is not greater than 10^{-9}.
Examples
Input
3
1 1 1
Output
5.5
Input
1
3
Output
3
Input
2
1 2
Output
4.5
Input
10
1 3 2 3 3 2 3 2 1 3
Output
54.48064457488221 | instruction | 0 | 64,644 | 9 | 129,288 |
"Correct Solution:
```
N = int(input())
dp = [[[0.0]*(N+1) for _ in range(N+1)] for _ in range(N+1)]
dic = {}
dic[0] = 0
dic[1] = 0
dic[2] = 0
dic[3] = 0
for a in map(int, input().split(" ")):
dic[a] += 1
for k in range(dic[3]+1):
for j in range(dic[2]+1+dic[3]-k):
for i in range(dic[1]+1+dic[2]-j+dic[3]-k):
if i == 0 and j == 0 and k == 0:
continue
res = 0.0
if i > 0:
res += dp[i-1][j][k] * i
if j > 0:
res += dp[i+1][j-1][k] * j
if k > 0:
res += dp[i][j+1][k-1] * k
res += N
res *= (1.0 / (i+j+k))
dp[i][j][k] = res
print(dp[dic[1]][dic[2]][dic[3]])
``` | output | 1 | 64,644 | 9 | 129,289 |
Provide a correct Python 3 solution for this coding contest problem.
There are N dishes, numbered 1, 2, \ldots, N. Initially, for each i (1 \leq i \leq N), Dish i has a_i (1 \leq a_i \leq 3) pieces of sushi on it.
Taro will perform the following operation repeatedly until all the pieces of sushi are eaten:
* Roll a die that shows the numbers 1, 2, \ldots, N with equal probabilities, and let i be the outcome. If there are some pieces of sushi on Dish i, eat one of them; if there is none, do nothing.
Find the expected number of times the operation is performed before all the pieces of sushi are eaten.
Constraints
* All values in input are integers.
* 1 \leq N \leq 300
* 1 \leq a_i \leq 3
Input
Input is given from Standard Input in the following format:
N
a_1 a_2 \ldots a_N
Output
Print the expected number of times the operation is performed before all the pieces of sushi are eaten. The output is considered correct when the relative difference is not greater than 10^{-9}.
Examples
Input
3
1 1 1
Output
5.5
Input
1
3
Output
3
Input
2
1 2
Output
4.5
Input
10
1 3 2 3 3 2 3 2 1 3
Output
54.48064457488221 | instruction | 0 | 64,645 | 9 | 129,290 |
"Correct Solution:
```
n=int(input())
dp=[[[0.0]*(n+1) for i in range(n+1)] for j in range(n+1)]
dp[0][0][0]=0
a=[float(i) for i in input().split()]
p=a.count(1)
q=a.count(2)
r=a.count(3)
l=[1]
for i in range(1,1000):
l.append(1.0/i)
for k in range(r+1):
for j in range(q+r-k+1):
for i in range(n-k-j+1):
if i==j==k==0:
continue
res=n
if i>0:
res+=i*dp[i-1][j][k]
if j>0:
res+=j*dp[i+1][j-1][k]
if k>0:
res+=k*dp[i][j+1][k-1]
res*=1/(i+j+k)
dp[i][j][k]=res
print(dp[p][q][r])
``` | output | 1 | 64,645 | 9 | 129,291 |
Provide a correct Python 3 solution for this coding contest problem.
There are N dishes, numbered 1, 2, \ldots, N. Initially, for each i (1 \leq i \leq N), Dish i has a_i (1 \leq a_i \leq 3) pieces of sushi on it.
Taro will perform the following operation repeatedly until all the pieces of sushi are eaten:
* Roll a die that shows the numbers 1, 2, \ldots, N with equal probabilities, and let i be the outcome. If there are some pieces of sushi on Dish i, eat one of them; if there is none, do nothing.
Find the expected number of times the operation is performed before all the pieces of sushi are eaten.
Constraints
* All values in input are integers.
* 1 \leq N \leq 300
* 1 \leq a_i \leq 3
Input
Input is given from Standard Input in the following format:
N
a_1 a_2 \ldots a_N
Output
Print the expected number of times the operation is performed before all the pieces of sushi are eaten. The output is considered correct when the relative difference is not greater than 10^{-9}.
Examples
Input
3
1 1 1
Output
5.5
Input
1
3
Output
3
Input
2
1 2
Output
4.5
Input
10
1 3 2 3 3 2 3 2 1 3
Output
54.48064457488221 | instruction | 0 | 64,646 | 9 | 129,292 |
"Correct Solution:
```
from collections import Counter
n = int(input())
A = [int(i) for i in input().split()]
C = Counter(A)
a, b, c = [C[i] for i in range(3, 0, -1)]
DP = [[[-1] * (a + b + c + 1) for i in range(a + b + 1)] for j in range(a + 1)]
DP[0][0][0] = 0
for i in range(a + 1):
for j in range(a + b - i + 1):
for k in range(a + b + c - i - j + 1):
if i == j == k == 0:
continue
DP[i][j][k] = 1
if i > 0: DP[i][j][k] += i / n * DP[i - 1][j + 1][k]
if j > 0: DP[i][j][k] += j / n * DP[i][j - 1][k + 1]
if k > 0: DP[i][j][k] += k / n * DP[i][j][k - 1]
DP[i][j][k] *= n / (i + j + k)
print(DP[a][b][c])
``` | output | 1 | 64,646 | 9 | 129,293 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.