output_description
stringlengths
15
956
submission_id
stringlengths
10
10
status
stringclasses
3 values
problem_id
stringlengths
6
6
input_description
stringlengths
9
2.55k
attempt
stringlengths
1
13.7k
problem_description
stringlengths
7
5.24k
samples
stringlengths
2
2.72k
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of roads connected to city i. * * *
s277245450
Runtime Error
p03720
Input is given from Standard Input in the following format: N M a_1 b_1 : a_M b_M
N = int(input()) count = [0]*N for i in range(N): x, y = [int(x) for x in input().split()] count[x-1] += 1 count[y-1] += 1 for c in count: print(c)
Statement There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
[{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}]
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of roads connected to city i. * * *
s337199470
Runtime Error
p03720
Input is given from Standard Input in the following format: N M a_1 b_1 : a_M b_M
n, m = map(int,input().split()) c = [0 for i in range(n)] for i in range(m) a, b = map(int,input().split()) c[a-1] += 1 c[b-1] += 1 for i in c: print(i)
Statement There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
[{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}]
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of roads connected to city i. * * *
s274241874
Runtime Error
p03720
Input is given from Standard Input in the following format: N M a_1 b_1 : a_M b_M
n, m = map(int, input()) s = open(0).read().split() for i in range(n): print(s.count(str(i)))
Statement There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
[{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}]
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of roads connected to city i. * * *
s014044478
Runtime Error
p03720
Input is given from Standard Input in the following format: N M a_1 b_1 : a_M b_M
N, M = [int(i) for i in input().split(" ")] for i in range(0,N) lst.append(input().split(" ")) for i in range(1,N+1) print(lst.count(i))
Statement There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
[{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}]
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of roads connected to city i. * * *
s183154204
Runtime Error
p03720
Input is given from Standard Input in the following format: N M a_1 b_1 : a_M b_M
I = lambda: map(int, input().split()) N, M = I() r = range(N) m = {i: 0 for i in r} for _ in [0] * M: a, b = I() m[a] += +1 m[b] += 1 for i in r: print(m[i])
Statement There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
[{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}]
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of roads connected to city i. * * *
s268542910
Runtime Error
p03720
Input is given from Standard Input in the following format: N M a_1 b_1 : a_M b_M
b
Statement There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
[{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}]
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of roads connected to city i. * * *
s174562018
Accepted
p03720
Input is given from Standard Input in the following format: N M a_1 b_1 : a_M b_M
a = [int(num) for num in input().split()] counts = [0 for i in range(a[0])] for i in range(0, a[1]): b = [int(num) for num in input().split()] counts[b[0] - 1] += 1 counts[b[1] - 1] += 1 for i in counts: print(i)
Statement There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
[{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}]
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of roads connected to city i. * * *
s006920748
Runtime Error
p03720
Input is given from Standard Input in the following format: N M a_1 b_1 : a_M b_M
n, m = map(int, input().split()) a = [list(map(int, input().split())) for _ in range(m)] b = [0] * n for i in range(m): b.index(a[i][0] - 1) += 1 b.index(a[i][1] - 1) += 1 for i in range(n): print(b[i])
Statement There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
[{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}]
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of roads connected to city i. * * *
s583997832
Runtime Error
p03720
Input is given from Standard Input in the following format: N M a_1 b_1 : a_M b_M
n, m = map(int, input().split(" ")) count = [0 for i in range(0,n)] for i in range(0, m): a, b = map(int, input().split(" ")) count[a] L= 1 count[b] += 1 for i in range(0, n): print(count[i])
Statement There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
[{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}]
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of roads connected to city i. * * *
s627816042
Runtime Error
p03720
Input is given from Standard Input in the following format: N M a_1 b_1 : a_M b_M
import sys n,m = [int(x) for x in sys.stdin.readline().split()] r = [0] * n for i in range m: a, b = [int(x) for x in sys.stdin.readline().split()] r[a-1] += 1 r[b-1] += 1 for i in range n: print(r[i])
Statement There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
[{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}]
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of roads connected to city i. * * *
s684211212
Runtime Error
p03720
Input is given from Standard Input in the following format: N M a_1 b_1 : a_M b_M
n, m = [int(item) for item in input().split()] count = [0] * n for i in range(n): a, b = [int(item) for item in input().split()] count[a - 1] += 1 count[b - 1] += 1 for item in count: print(item)
Statement There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
[{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}]
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of roads connected to city i. * * *
s606202639
Wrong Answer
p03720
Input is given from Standard Input in the following format: N M a_1 b_1 : a_M b_M
N, M = map(int, input().split()) L = "".join( list( map( str, sorted( sum( list( map( list, map( tuple, [list(map(int, input().split())) for _ in range(M)], ), ) ), [], ) ), ) ) ) [print(L.count(str(i))) for i in range(1, N + 1)]
Statement There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
[{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}]
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of roads connected to city i. * * *
s968225283
Wrong Answer
p03720
Input is given from Standard Input in the following format: N M a_1 b_1 : a_M b_M
try: N, M = map(int, input().split()) a = [] b = [] bucket = {} mx = 0 for i in range(M): a_, b_ = map(int, input().split()) a.append(a_) b.append(b_) for i in range(len(a)): if (a[i] in bucket) == False: bucket[a[i]] = [] bucket[a[i]].append(a[i]) if (b[i] in bucket) == False: bucket[b[i]] = [] bucket[b[i]].append(b[i]) if mx < a[i]: mx = a[i] if mx < b[i]: mx = b[i] b = sorted(bucket.items()) for key, value in b: print(len(value)) except EOFError: pass
Statement There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
[{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}]
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of roads connected to city i. * * *
s312921651
Accepted
p03720
Input is given from Standard Input in the following format: N M a_1 b_1 : a_M b_M
icase = 0 if icase == 0: n, m = map(int, input().split()) a = [] for i in range(m): ai, bi = map(int, input().split()) a.append(ai) a.append(bi) for i in range(1, n + 1): icnt = 0 for nn in a: if nn == i: icnt = icnt + 1 print(icnt)
Statement There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
[{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}]
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of roads connected to city i. * * *
s829799945
Runtime Error
p03720
Input is given from Standard Input in the following format: N M a_1 b_1 : a_M b_M
N, M = [int(i) for i in input().split(" ")] for i in range(0,N): lst.append(input().split(" ")) for i in range(1,N+1): print(lst.count(i)
Statement There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
[{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}]
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of roads connected to city i. * * *
s007542810
Runtime Error
p03720
Input is given from Standard Input in the following format: N M a_1 b_1 : a_M b_M
n, m = map(int, input().split()) s = "" [s += input() for i in range(0, m)] [print(s.count(str(i))) for i in range(1, m + 1)]
Statement There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
[{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}]
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of roads connected to city i. * * *
s529605024
Runtime Error
p03720
Input is given from Standard Input in the following format: N M a_1 b_1 : a_M b_M
n,_,*r=map(int,open(0).read().split());for i in range(n):print(r.count(-~i))
Statement There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
[{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}]
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of roads connected to city i. * * *
s141473585
Accepted
p03720
Input is given from Standard Input in the following format: N M a_1 b_1 : a_M b_M
n, m = input().split(" ", 2) a = [] for ii in range(int(n)): a.append(0) for ii in range(int(m)): tmpA, tmpB = input().split(" ", 2) a[int(tmpA) - 1] += 1 a[int(tmpB) - 1] += 1 for ii in range(int(n)): print(a[ii])
Statement There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
[{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}]
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of roads connected to city i. * * *
s139326338
Accepted
p03720
Input is given from Standard Input in the following format: N M a_1 b_1 : a_M b_M
cities, num = map(int, input().split()) ary = [0 for i in range(num)] result = [0 for i in range(cities)] check = 0 for i in range(num): ary[i] = list(map(int, input().split())) for i in range(num): check = ary[i][0] result[check - 1] += 1 check = ary[i][1] result[check - 1] += 1 for i in range(cities): print(result[i])
Statement There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
[{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}]
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of roads connected to city i. * * *
s329223328
Accepted
p03720
Input is given from Standard Input in the following format: N M a_1 b_1 : a_M b_M
N, _, *R = open(0).read().split() for i in range(int(N)): print(R.count(str(-~i)))
Statement There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
[{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}]
Print the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print `-1` if his desire is unsatisfiable. * * *
s238643282
Accepted
p02832
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
def tmpq4(n, alist): akouho = [] for tmpi, ai in enumerate(alist): i = tmpi + 1 if ai <= i: akouho.append(ai) if n == len(akouho): return akouho return tmpq4(len(akouho), akouho) def q4(n, alist): alis = tmpq4(n, alist) alis = list(set(alis)) anslist = [] for i in range(len(alis)): if (i + 1) == alis[i]: anslist.append(alis[i]) else: break if len(anslist) > 0: return n - len(anslist) else: return -1 n = int(input()) alisttmp = input().split() alist = [] for num in alisttmp: alist.append(int(num)) print(q4(n, alist))
Statement We have N bricks arranged in a row from left to right. The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it. Among them, you can break at most N-1 bricks of your choice. Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it. Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.
[{"input": "3\n 2 1 2", "output": "1\n \n\nIf we break the leftmost brick, the remaining bricks have integers 1 and 2\nwritten on them from left to right, in which case Snuke will be satisfied.\n\n* * *"}, {"input": "3\n 2 2 2", "output": "-1\n \n\nIn this case, there is no way to break some of the bricks to satisfy Snuke's\ndesire.\n\n* * *"}, {"input": "10\n 3 1 4 1 5 9 2 6 5 3", "output": "7\n \n\n* * *"}, {"input": "1\n 1", "output": "0\n \n\nThere may be no need to break the bricks at all."}]
Print the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print `-1` if his desire is unsatisfiable. * * *
s301060944
Runtime Error
p02832
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
x = int(input()) li = list(map(int, input())) from collections import deque l = deque(li) def m(p, lis): for i in range(len(lis)): if lis.leftpop() == p: return i + 1 return -1 print(m(x, l))
Statement We have N bricks arranged in a row from left to right. The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it. Among them, you can break at most N-1 bricks of your choice. Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it. Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.
[{"input": "3\n 2 1 2", "output": "1\n \n\nIf we break the leftmost brick, the remaining bricks have integers 1 and 2\nwritten on them from left to right, in which case Snuke will be satisfied.\n\n* * *"}, {"input": "3\n 2 2 2", "output": "-1\n \n\nIn this case, there is no way to break some of the bricks to satisfy Snuke's\ndesire.\n\n* * *"}, {"input": "10\n 3 1 4 1 5 9 2 6 5 3", "output": "7\n \n\n* * *"}, {"input": "1\n 1", "output": "0\n \n\nThere may be no need to break the bricks at all."}]
Print the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print `-1` if his desire is unsatisfiable. * * *
s396105459
Wrong Answer
p02832
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
1 1
Statement We have N bricks arranged in a row from left to right. The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it. Among them, you can break at most N-1 bricks of your choice. Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it. Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.
[{"input": "3\n 2 1 2", "output": "1\n \n\nIf we break the leftmost brick, the remaining bricks have integers 1 and 2\nwritten on them from left to right, in which case Snuke will be satisfied.\n\n* * *"}, {"input": "3\n 2 2 2", "output": "-1\n \n\nIn this case, there is no way to break some of the bricks to satisfy Snuke's\ndesire.\n\n* * *"}, {"input": "10\n 3 1 4 1 5 9 2 6 5 3", "output": "7\n \n\n* * *"}, {"input": "1\n 1", "output": "0\n \n\nThere may be no need to break the bricks at all."}]
Print the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print `-1` if his desire is unsatisfiable. * * *
s885976108
Accepted
p02832
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
N = int(input()) a = input().split(" ") def search(): # import pdb; pdb.set_trace() search_start = 0 for target in range(1, N + 1): for j in range(search_start, N): if int(a[j]) == target: search_start = j + 1 break else: # ここが実行できていると言うことは、右端まで探索が終わったということ # 従って、targetを返す必要がある if N != 1 and target == 1: return -1 else: return N - (target - 1) else: # ここが実行できているということは、N個の数字全部の探索が終わったということ # すなわち、ブロックを壊す必要がない return 0 return False print(search())
Statement We have N bricks arranged in a row from left to right. The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it. Among them, you can break at most N-1 bricks of your choice. Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it. Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.
[{"input": "3\n 2 1 2", "output": "1\n \n\nIf we break the leftmost brick, the remaining bricks have integers 1 and 2\nwritten on them from left to right, in which case Snuke will be satisfied.\n\n* * *"}, {"input": "3\n 2 2 2", "output": "-1\n \n\nIn this case, there is no way to break some of the bricks to satisfy Snuke's\ndesire.\n\n* * *"}, {"input": "10\n 3 1 4 1 5 9 2 6 5 3", "output": "7\n \n\n* * *"}, {"input": "1\n 1", "output": "0\n \n\nThere may be no need to break the bricks at all."}]
Print the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print `-1` if his desire is unsatisfiable. * * *
s049649345
Accepted
p02832
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
a = int(input()) q = [] q += [int(x) for x in input().split()] s = q.count(1) r = 1 e = 0 if s == 0: print("-1") else: for i in range(a): if r == q[i]: r += 1 print(a - r + 1)
Statement We have N bricks arranged in a row from left to right. The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it. Among them, you can break at most N-1 bricks of your choice. Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it. Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.
[{"input": "3\n 2 1 2", "output": "1\n \n\nIf we break the leftmost brick, the remaining bricks have integers 1 and 2\nwritten on them from left to right, in which case Snuke will be satisfied.\n\n* * *"}, {"input": "3\n 2 2 2", "output": "-1\n \n\nIn this case, there is no way to break some of the bricks to satisfy Snuke's\ndesire.\n\n* * *"}, {"input": "10\n 3 1 4 1 5 9 2 6 5 3", "output": "7\n \n\n* * *"}, {"input": "1\n 1", "output": "0\n \n\nThere may be no need to break the bricks at all."}]
Print the maximum number of times we can do the operation. * * *
s412685626
Accepted
p02998
Input is given from Standard Input in the following format: N x_1 y_1 : x_N y_N
# -*- coding: utf-8 -*- import sys # sys.setrecursionlimit(10**6) # buff_readline = sys.stdin.buffer.readline buff_readline = sys.stdin.readline readline = sys.stdin.readline INF = 2**62 - 1 def read_int(): return int(buff_readline()) def read_int_n(): return list(map(int, buff_readline().split())) def read_float(): return float(buff_readline()) def read_float_n(): return list(map(float, buff_readline().split())) def read_str(): return readline().strip() def read_str_n(): return readline().strip().split() def error_print(*args): print(*args, file=sys.stderr) def mt(f): import time def wrap(*args, **kwargs): s = time.time() ret = f(*args, **kwargs) e = time.time() error_print(e - s, "sec") return ret return wrap @mt def slv(N, XY): from collections import defaultdict g = defaultdict(set) yo = 10**6 V = set() for x, y in XY: y += yo g[x].add(y) g[y].add(x) V.add(x) V.add(y) rem = set(v for v in V) done = set() ans = 0 while rem: u = rem.pop() s = [u] done.add(u) xs = set() ys = set() if u >= yo: ys.add(u) else: xs.add(u) while s: u = s.pop() if u >= yo: ys.add(u) else: xs.add(u) for v in g[u]: if v in done: continue s.append(v) done.add(v) rem -= xs rem -= ys e = 0 for u in xs: e += len(g[u]) ans += len(xs) * len(ys) - e return ans def main(): N = read_int() XY = [read_int_n() for _ in range(N)] print(slv(N, XY)) if __name__ == "__main__": main()
Statement There are N dots in a two-dimensional plane. The coordinates of the i-th dot are (x_i, y_i). We will repeat the following operation as long as possible: * Choose four integers a, b, c, d (a \neq c, b \neq d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b) and (c, d), and add a dot at the remaining position. We can prove that we can only do this operation a finite number of times. Find the maximum number of times we can do the operation.
[{"input": "3\n 1 1\n 5 1\n 5 5", "output": "1\n \n\nBy choosing a = 1, b = 1, c = 5, d = 5, we can add a dot at (1, 5). We cannot\ndo the operation any more, so the maximum number of operations is 1.\n\n* * *"}, {"input": "2\n 10 10\n 20 20", "output": "0\n \n\nThere are only two dots, so we cannot do the operation at all.\n\n* * *"}, {"input": "9\n 1 1\n 2 1\n 3 1\n 4 1\n 5 1\n 1 2\n 1 3\n 1 4\n 1 5", "output": "16\n \n\nWe can do the operation for all choices of the form a = 1, b = 1, c = i, d = j\n(2 \\leq i,j \\leq 5), and no more. Thus, the maximum number of operations is\n16."}]
Print the maximum number of times we can do the operation. * * *
s686850569
Wrong Answer
p02998
Input is given from Standard Input in the following format: N x_1 y_1 : x_N y_N
n = int(input()) xys = [list(map(int, input().split())) for i in range(n)] x = [0] * (10**5 + 3) y = [0] * (10**5 + 3) for i in range(n): x[xys[i][0]] += 1 y[xys[i][1]] += 1 cntx = 0 cnty = 0 for i in range(10**5 + 2): cntx += max(0, x[i] - 1) cnty += max(0, y[i] - 1) print(cntx * cnty)
Statement There are N dots in a two-dimensional plane. The coordinates of the i-th dot are (x_i, y_i). We will repeat the following operation as long as possible: * Choose four integers a, b, c, d (a \neq c, b \neq d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b) and (c, d), and add a dot at the remaining position. We can prove that we can only do this operation a finite number of times. Find the maximum number of times we can do the operation.
[{"input": "3\n 1 1\n 5 1\n 5 5", "output": "1\n \n\nBy choosing a = 1, b = 1, c = 5, d = 5, we can add a dot at (1, 5). We cannot\ndo the operation any more, so the maximum number of operations is 1.\n\n* * *"}, {"input": "2\n 10 10\n 20 20", "output": "0\n \n\nThere are only two dots, so we cannot do the operation at all.\n\n* * *"}, {"input": "9\n 1 1\n 2 1\n 3 1\n 4 1\n 5 1\n 1 2\n 1 3\n 1 4\n 1 5", "output": "16\n \n\nWe can do the operation for all choices of the form a = 1, b = 1, c = i, d = j\n(2 \\leq i,j \\leq 5), and no more. Thus, the maximum number of operations is\n16."}]
Print the maximum number of times we can do the operation. * * *
s519570386
Accepted
p02998
Input is given from Standard Input in the following format: N x_1 y_1 : x_N y_N
import sys sys.setrecursionlimit(10**6) n = int(input()) edges = [[] for i in range(2 * 10**5)] for i in range(n): xi, yi = map(int, input().split()) xi -= 1 yi = yi - 1 + 10**5 edges[xi].append(yi) edges[yi].append(xi) already = set([]) def dfs(x, y, node): if node in already: return x, y if node < 10**5: x += 1 else: y += 1 already.add(node) for next_node in edges[node]: x, y = dfs(x, y, next_node) return x, y num = 0 for i in range(10**5): x, y = dfs(0, 0, i) num += x * y print(num - n)
Statement There are N dots in a two-dimensional plane. The coordinates of the i-th dot are (x_i, y_i). We will repeat the following operation as long as possible: * Choose four integers a, b, c, d (a \neq c, b \neq d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b) and (c, d), and add a dot at the remaining position. We can prove that we can only do this operation a finite number of times. Find the maximum number of times we can do the operation.
[{"input": "3\n 1 1\n 5 1\n 5 5", "output": "1\n \n\nBy choosing a = 1, b = 1, c = 5, d = 5, we can add a dot at (1, 5). We cannot\ndo the operation any more, so the maximum number of operations is 1.\n\n* * *"}, {"input": "2\n 10 10\n 20 20", "output": "0\n \n\nThere are only two dots, so we cannot do the operation at all.\n\n* * *"}, {"input": "9\n 1 1\n 2 1\n 3 1\n 4 1\n 5 1\n 1 2\n 1 3\n 1 4\n 1 5", "output": "16\n \n\nWe can do the operation for all choices of the form a = 1, b = 1, c = i, d = j\n(2 \\leq i,j \\leq 5), and no more. Thus, the maximum number of operations is\n16."}]
Print the maximum number of times we can do the operation. * * *
s029828697
Wrong Answer
p02998
Input is given from Standard Input in the following format: N x_1 y_1 : x_N y_N
# 最大も何も一意では n = int(input()) p = [tuple(map(int, input().split())) for _ in range(n)] x = set([p[i][0] for i in range(n)]) y = set([p[i][1] for i in range(n)]) print(len(x) * len(y) - n)
Statement There are N dots in a two-dimensional plane. The coordinates of the i-th dot are (x_i, y_i). We will repeat the following operation as long as possible: * Choose four integers a, b, c, d (a \neq c, b \neq d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b) and (c, d), and add a dot at the remaining position. We can prove that we can only do this operation a finite number of times. Find the maximum number of times we can do the operation.
[{"input": "3\n 1 1\n 5 1\n 5 5", "output": "1\n \n\nBy choosing a = 1, b = 1, c = 5, d = 5, we can add a dot at (1, 5). We cannot\ndo the operation any more, so the maximum number of operations is 1.\n\n* * *"}, {"input": "2\n 10 10\n 20 20", "output": "0\n \n\nThere are only two dots, so we cannot do the operation at all.\n\n* * *"}, {"input": "9\n 1 1\n 2 1\n 3 1\n 4 1\n 5 1\n 1 2\n 1 3\n 1 4\n 1 5", "output": "16\n \n\nWe can do the operation for all choices of the form a = 1, b = 1, c = i, d = j\n(2 \\leq i,j \\leq 5), and no more. Thus, the maximum number of operations is\n16."}]
Print the maximum number of times we can do the operation. * * *
s783511353
Wrong Answer
p02998
Input is given from Standard Input in the following format: N x_1 y_1 : x_N y_N
def append_p(p, xpeers_s, ypeers_s): x = p[X] if not x in xpeers_s: xpeers_s[x] = [] xpeers_s[x].append(p) y = p[Y] if not y in ypeers_s: ypeers_s[y] = [] ypeers_s[y].append(p) X = 0 Y = 1 n = int(input()) p_set = set(tuple(int(v) for v in input().split()) for _ in range(n)) xpeers_s = {} ypeers_s = {} for p in p_set: append_p(p, xpeers_s, ypeers_s) # print(p_set) # print(xpeers_s) # print(ypeers_s) # print("") ans = 0 for _rep in range(10): # while True: repeat = False p_set_new = set() for p in p_set: x = p[X] y = p[Y] if (x in xpeers_s) and (y in ypeers_s): xpeers = xpeers_s[x] ypeers = ypeers_s[y] # print(xpeers, ypeers) for xpeer in xpeers: for ypeer in ypeers: dpeer = (ypeer[X], xpeer[Y]) # print(xpeer, ypeer) if not dpeer in p_set: ans += 1 repeat = True p_set_new.add(dpeer) # print("repeat={}, ans={}".format(repeat, ans)) p_set |= p_set_new for p_new in p_set_new: # print(p_new) append_p(p_new, xpeers_s, ypeers_s) if not repeat: break print(ans)
Statement There are N dots in a two-dimensional plane. The coordinates of the i-th dot are (x_i, y_i). We will repeat the following operation as long as possible: * Choose four integers a, b, c, d (a \neq c, b \neq d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b) and (c, d), and add a dot at the remaining position. We can prove that we can only do this operation a finite number of times. Find the maximum number of times we can do the operation.
[{"input": "3\n 1 1\n 5 1\n 5 5", "output": "1\n \n\nBy choosing a = 1, b = 1, c = 5, d = 5, we can add a dot at (1, 5). We cannot\ndo the operation any more, so the maximum number of operations is 1.\n\n* * *"}, {"input": "2\n 10 10\n 20 20", "output": "0\n \n\nThere are only two dots, so we cannot do the operation at all.\n\n* * *"}, {"input": "9\n 1 1\n 2 1\n 3 1\n 4 1\n 5 1\n 1 2\n 1 3\n 1 4\n 1 5", "output": "16\n \n\nWe can do the operation for all choices of the form a = 1, b = 1, c = i, d = j\n(2 \\leq i,j \\leq 5), and no more. Thus, the maximum number of operations is\n16."}]
Print the maximum number of times we can do the operation. * * *
s997784667
Accepted
p02998
Input is given from Standard Input in the following format: N x_1 y_1 : x_N y_N
class UnionFind: def __init__(self, size): self.parent = list(range(size)) self.height = [0] * size self.size = [1] * size self.component = size def root(self, index): if self.parent[index] == index: # 根の場合 return index rootIndex = self.root(self.parent[index]) # 葉の場合親の根を取得 self.parent[index] = rootIndex # 親の付け直し return rootIndex def union(self, index1, index2): # 結合 root1 = self.root(index1) root2 = self.root(index2) if root1 == root2: # 連結されている場合 return self.component -= 1 # 連結成分を減らす if self.height[root1] < self.height[root2]: self.parent[root1] = root2 # root2に結合 self.size[root2] += self.size[root1] else: self.parent[root2] = root1 # root1に結合 self.size[root1] += self.size[root2] if self.height[root1] == self.height[root2]: self.height[root1] += 1 return def isSameRoot(self, index1, index2): return self.root(index1) == self.root(index2) def sizeOfSameRoot(self, index): return self.size[self.root(index)] def getComponent(self): return self.component N = int(input()) R = 10**5 + 10 IXY = [] for i in range(N): x, y = map(int, input().split()) IXY.append((i, x, y)) X = [[] for _ in range(R)] Y = [[] for _ in range(R)] for i, x, y in IXY: X[x].append(i) Y[y].append(i) tree = UnionFind(N) for x in X: for fr, to in zip(x, x[1:]): tree.union(fr, to) for y in Y: for fr, to in zip(y, y[1:]): tree.union(fr, to) G = [[0, set(), set()] for _ in range(N)] for i, x, y in IXY: r = tree.root(i) G[r][0] += 1 G[r][1].add(x) G[r][2].add(y) ans = 0 for grp in G: if grp[0] < 3: continue x = len(grp[1]) y = len(grp[2]) A = x * y ans += max(0, A - grp[0]) print(ans)
Statement There are N dots in a two-dimensional plane. The coordinates of the i-th dot are (x_i, y_i). We will repeat the following operation as long as possible: * Choose four integers a, b, c, d (a \neq c, b \neq d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b) and (c, d), and add a dot at the remaining position. We can prove that we can only do this operation a finite number of times. Find the maximum number of times we can do the operation.
[{"input": "3\n 1 1\n 5 1\n 5 5", "output": "1\n \n\nBy choosing a = 1, b = 1, c = 5, d = 5, we can add a dot at (1, 5). We cannot\ndo the operation any more, so the maximum number of operations is 1.\n\n* * *"}, {"input": "2\n 10 10\n 20 20", "output": "0\n \n\nThere are only two dots, so we cannot do the operation at all.\n\n* * *"}, {"input": "9\n 1 1\n 2 1\n 3 1\n 4 1\n 5 1\n 1 2\n 1 3\n 1 4\n 1 5", "output": "16\n \n\nWe can do the operation for all choices of the form a = 1, b = 1, c = i, d = j\n(2 \\leq i,j \\leq 5), and no more. Thus, the maximum number of operations is\n16."}]
Print the maximum number of times we can do the operation. * * *
s826014396
Accepted
p02998
Input is given from Standard Input in the following format: N x_1 y_1 : x_N y_N
def main(): n = int(input()) xy = [list(map(int, input().split())) for _ in [0] * n] ixy = [[i, x, y] for i, (x, y) in enumerate(xy)] class unionfind: # size:要素数,tree:unionfind木 def __init__(self, size): # self,要素数 self.size = size self.tree_root = list(range(self.size)) self.tree_depth = [1] * self.size # rootを探す def root(self, index): temp_list = [] temp = self.tree_root[index] while index != temp: temp_list.append(index) index = temp temp = self.tree_root[index] for i in temp_list: self.tree_root[i] = index return index # 結合 def unite(self, index1, index2): r1 = self.root(index1) r2 = self.root(index2) if r1 != r2: d1, d2 = self.tree_depth[r1], self.tree_depth[r2] if d1 <= d2: self.tree_root[r1] = r2 self.tree_depth[r2] = max(d1 + 1, d2) else: self.tree_root[r2] = r1 self.tree_depth[r1] = max(d2 + 1, d1) # 同じか判定 def same(self, index1, index2): r1 = self.root(index1) r2 = self.root(index2) return r1 == r2 # 連結成分の個数 def component(self): return len({self.root(i) for i in range(self.size)}) u = unionfind(n) ixy.sort(key=lambda x: x[1]) for i in range(n - 1): if ixy[i][1] == ixy[i + 1][1]: u.unite(ixy[i][0], ixy[i + 1][0]) ixy.sort(key=lambda x: x[2]) for i in range(n - 1): if ixy[i][2] == ixy[i + 1][2]: u.unite(ixy[i][0], ixy[i + 1][0]) tate = [set() for _ in [0] * n] yoko = [set() for _ in [0] * n] cnt = [0] * n for i in range(n): r = u.root(i) tate[r].add(xy[i][0]) yoko[r].add(xy[i][1]) cnt[r] += 1 print(sum([len(tate[i]) * len(yoko[i]) - cnt[i] for i in range(n)])) main()
Statement There are N dots in a two-dimensional plane. The coordinates of the i-th dot are (x_i, y_i). We will repeat the following operation as long as possible: * Choose four integers a, b, c, d (a \neq c, b \neq d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b) and (c, d), and add a dot at the remaining position. We can prove that we can only do this operation a finite number of times. Find the maximum number of times we can do the operation.
[{"input": "3\n 1 1\n 5 1\n 5 5", "output": "1\n \n\nBy choosing a = 1, b = 1, c = 5, d = 5, we can add a dot at (1, 5). We cannot\ndo the operation any more, so the maximum number of operations is 1.\n\n* * *"}, {"input": "2\n 10 10\n 20 20", "output": "0\n \n\nThere are only two dots, so we cannot do the operation at all.\n\n* * *"}, {"input": "9\n 1 1\n 2 1\n 3 1\n 4 1\n 5 1\n 1 2\n 1 3\n 1 4\n 1 5", "output": "16\n \n\nWe can do the operation for all choices of the form a = 1, b = 1, c = i, d = j\n(2 \\leq i,j \\leq 5), and no more. Thus, the maximum number of operations is\n16."}]
Print the maximum number of times we can do the operation. * * *
s086114257
Wrong Answer
p02998
Input is given from Standard Input in the following format: N x_1 y_1 : x_N y_N
N = int(input()) P = [] for i in range(N): x, y = list(map(int, input().strip().split(" "))) P += [[x, y]] P1 = sorted(P, key=lambda x: (x[0], x[1])) P2 = sorted(P, key=lambda x: (x[1], x[0])) # print(P,P1,P2) num = 0 for i in range(N): for j in range(i, N): if P[i][0] == P[j][0]: continue if P[i][1] == P[j][1]: continue if [P[i][0], P[j][1]] in P: num += 1 if [P[i][1], P[j][0]] in P: num += 1 print(num)
Statement There are N dots in a two-dimensional plane. The coordinates of the i-th dot are (x_i, y_i). We will repeat the following operation as long as possible: * Choose four integers a, b, c, d (a \neq c, b \neq d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b) and (c, d), and add a dot at the remaining position. We can prove that we can only do this operation a finite number of times. Find the maximum number of times we can do the operation.
[{"input": "3\n 1 1\n 5 1\n 5 5", "output": "1\n \n\nBy choosing a = 1, b = 1, c = 5, d = 5, we can add a dot at (1, 5). We cannot\ndo the operation any more, so the maximum number of operations is 1.\n\n* * *"}, {"input": "2\n 10 10\n 20 20", "output": "0\n \n\nThere are only two dots, so we cannot do the operation at all.\n\n* * *"}, {"input": "9\n 1 1\n 2 1\n 3 1\n 4 1\n 5 1\n 1 2\n 1 3\n 1 4\n 1 5", "output": "16\n \n\nWe can do the operation for all choices of the form a = 1, b = 1, c = i, d = j\n(2 \\leq i,j \\leq 5), and no more. Thus, the maximum number of operations is\n16."}]
Print the maximum number of times we can do the operation. * * *
s954911646
Wrong Answer
p02998
Input is given from Standard Input in the following format: N x_1 y_1 : x_N y_N
N = int(input()) points = [] for i in range(0, N): points.append(list(map(int, input().split(" ")))) abcd = list(set(sum(points, []))) count = 0 for i, a in enumerate(abcd): for j, b in enumerate(abcd): for c in abcd[i + 1 :]: for d in abcd[j + 1 :]: if a == c and b == d: continue p = [] if [a, b] not in points: p.append([a, b]) if [a, d] not in points: p.append([a, d]) if [c, b] not in points: p.append([c, b]) if [c, d] not in points: p.append([c, d]) if len(p) == 1: count += 1 points.append(p[0]) print(count)
Statement There are N dots in a two-dimensional plane. The coordinates of the i-th dot are (x_i, y_i). We will repeat the following operation as long as possible: * Choose four integers a, b, c, d (a \neq c, b \neq d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b) and (c, d), and add a dot at the remaining position. We can prove that we can only do this operation a finite number of times. Find the maximum number of times we can do the operation.
[{"input": "3\n 1 1\n 5 1\n 5 5", "output": "1\n \n\nBy choosing a = 1, b = 1, c = 5, d = 5, we can add a dot at (1, 5). We cannot\ndo the operation any more, so the maximum number of operations is 1.\n\n* * *"}, {"input": "2\n 10 10\n 20 20", "output": "0\n \n\nThere are only two dots, so we cannot do the operation at all.\n\n* * *"}, {"input": "9\n 1 1\n 2 1\n 3 1\n 4 1\n 5 1\n 1 2\n 1 3\n 1 4\n 1 5", "output": "16\n \n\nWe can do the operation for all choices of the form a = 1, b = 1, c = i, d = j\n(2 \\leq i,j \\leq 5), and no more. Thus, the maximum number of operations is\n16."}]
Print the maximum number of times we can do the operation. * * *
s262203186
Wrong Answer
p02998
Input is given from Standard Input in the following format: N x_1 y_1 : x_N y_N
N = int(input()) xy = [list(map(int, input().split())) for _ in range(N)] tmp_x = [] tmp_y = [] x_list = [] x2y_dic = {} y_list = [] y2x_dic = {} for p in xy: if p[0] in tmp_x: x_list.append(p[0]) if p[1] in tmp_y: y_list.append(p[1]) tmp_x.append(p[0]) tmp_y.append(p[1]) if p[0] not in x2y_dic: x2y_dic[p[0]] = [] x2y_dic[p[0]].append(p[1]) if p[1] not in y2x_dic: y2x_dic[p[1]] = [] y2x_dic[p[1]].append(p[0]) cnt = 0 x_list = list(set(x_list)) y_list = list(set(y_list)) for x in x_list: for y in y_list: if [x, y] in xy: for xx in x2y_dic[x]: for yy in y2x_dic[y]: if [xx, yy] not in xy: cnt += 1 print(cnt)
Statement There are N dots in a two-dimensional plane. The coordinates of the i-th dot are (x_i, y_i). We will repeat the following operation as long as possible: * Choose four integers a, b, c, d (a \neq c, b \neq d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b) and (c, d), and add a dot at the remaining position. We can prove that we can only do this operation a finite number of times. Find the maximum number of times we can do the operation.
[{"input": "3\n 1 1\n 5 1\n 5 5", "output": "1\n \n\nBy choosing a = 1, b = 1, c = 5, d = 5, we can add a dot at (1, 5). We cannot\ndo the operation any more, so the maximum number of operations is 1.\n\n* * *"}, {"input": "2\n 10 10\n 20 20", "output": "0\n \n\nThere are only two dots, so we cannot do the operation at all.\n\n* * *"}, {"input": "9\n 1 1\n 2 1\n 3 1\n 4 1\n 5 1\n 1 2\n 1 3\n 1 4\n 1 5", "output": "16\n \n\nWe can do the operation for all choices of the form a = 1, b = 1, c = i, d = j\n(2 \\leq i,j \\leq 5), and no more. Thus, the maximum number of operations is\n16."}]
Print the maximum number of times we can do the operation. * * *
s472890130
Wrong Answer
p02998
Input is given from Standard Input in the following format: N x_1 y_1 : x_N y_N
N = int(input()) P = [None] * N Q = set() for n in range(N): P[n] = tuple(map(int, input().split())) Q.add(P[n]) ans = 0 T = range(N) s = -1 for w in P: s += 1 x = P[s][0] y = P[s][1] for t in range(s + 1, len(P)): p = P[t][0] - x q = P[t][1] - y if p == 0 and q != 0: if {(x + q, y)} <= Q and Q.isdisjoint({(x + q, y + q)}): ans += 1 Q.add((x + q, y + q)) P.append((x + q, y + q)) elif {(x + q, y + q)} <= Q and Q.isdisjoint({(x + q, y)}): ans += 1 Q.add((x + q, y)) P.append((x + q, y)) elif p != 0 and q == 0: if {(x, y + p)} <= Q and Q.isdisjoint({(x + p, y + p)}): ans += 1 Q.add((x + p, y + p)) P.append((x + q, y + q)) elif {(x + p, y + p)} <= Q and Q.isdisjoint({(x, y + p)}): ans += 1 Q.add((x, y + p)) P.append((x, y + q)) elif p == q and p != 0: if {(x + p, y)} <= Q and Q.isdisjoint({(x, y + p)}): ans += 1 Q.add((x + p, y + p)) P.append((x + q, y + q)) elif {(x, y + p)} <= Q and Q.isdisjoint({(x + p, y)}): ans += 1 Q.add((x + p, y)) P.append((x + q, y)) print(ans)
Statement There are N dots in a two-dimensional plane. The coordinates of the i-th dot are (x_i, y_i). We will repeat the following operation as long as possible: * Choose four integers a, b, c, d (a \neq c, b \neq d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b) and (c, d), and add a dot at the remaining position. We can prove that we can only do this operation a finite number of times. Find the maximum number of times we can do the operation.
[{"input": "3\n 1 1\n 5 1\n 5 5", "output": "1\n \n\nBy choosing a = 1, b = 1, c = 5, d = 5, we can add a dot at (1, 5). We cannot\ndo the operation any more, so the maximum number of operations is 1.\n\n* * *"}, {"input": "2\n 10 10\n 20 20", "output": "0\n \n\nThere are only two dots, so we cannot do the operation at all.\n\n* * *"}, {"input": "9\n 1 1\n 2 1\n 3 1\n 4 1\n 5 1\n 1 2\n 1 3\n 1 4\n 1 5", "output": "16\n \n\nWe can do the operation for all choices of the form a = 1, b = 1, c = i, d = j\n(2 \\leq i,j \\leq 5), and no more. Thus, the maximum number of operations is\n16."}]
Print the maximum number of times we can do the operation. * * *
s011995373
Accepted
p02998
Input is given from Standard Input in the following format: N x_1 y_1 : x_N y_N
import sys from collections import defaultdict import queue n = int(sys.stdin.readline()) graph = defaultdict(list) X, Y = [[] for i in range(n)], [[] for i in range(n)] atX, atY = defaultdict(list), defaultdict(list) for i in range(n): a, b = map(int, sys.stdin.readline().split()) a -= 1 b -= 1 X[i] = a Y[i] = b atX[X[i]].append(i) atY[Y[i]].append(i) visX = set() visY = set() found = [False] * n ans = n * (-1) for root in range(n): if found[root]: continue usedX, usedY = set(), set() que = queue.Queue() que.put(root) found[root] = True usedX.add(X[root]) usedY.add(Y[root]) while not que.empty(): cur = que.get() toVisit = [] if X[cur] not in visX: visX.add(X[cur]) for ele in atX[X[cur]]: toVisit.append(ele) if Y[cur] not in visY: visY.add(Y[cur]) for ele in atY[Y[cur]]: toVisit.append(ele) for ele in toVisit: if found[ele]: continue found[ele] = True usedX.add(X[ele]) usedY.add(Y[ele]) que.put(ele) ans += len(usedX) * len(usedY) print(ans)
Statement There are N dots in a two-dimensional plane. The coordinates of the i-th dot are (x_i, y_i). We will repeat the following operation as long as possible: * Choose four integers a, b, c, d (a \neq c, b \neq d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b) and (c, d), and add a dot at the remaining position. We can prove that we can only do this operation a finite number of times. Find the maximum number of times we can do the operation.
[{"input": "3\n 1 1\n 5 1\n 5 5", "output": "1\n \n\nBy choosing a = 1, b = 1, c = 5, d = 5, we can add a dot at (1, 5). We cannot\ndo the operation any more, so the maximum number of operations is 1.\n\n* * *"}, {"input": "2\n 10 10\n 20 20", "output": "0\n \n\nThere are only two dots, so we cannot do the operation at all.\n\n* * *"}, {"input": "9\n 1 1\n 2 1\n 3 1\n 4 1\n 5 1\n 1 2\n 1 3\n 1 4\n 1 5", "output": "16\n \n\nWe can do the operation for all choices of the form a = 1, b = 1, c = i, d = j\n(2 \\leq i,j \\leq 5), and no more. Thus, the maximum number of operations is\n16."}]
Print the maximum number of times we can do the operation. * * *
s415359036
Wrong Answer
p02998
Input is given from Standard Input in the following format: N x_1 y_1 : x_N y_N
N = int(input()) xs = {} ys = {} for i in range(N): pair = tuple(map(int, input().split())) if pair[0] not in xs: xs[pair[0]] = [] xs[pair[0]].append(pair) if pair[1] not in ys: ys[pair[1]] = [] ys[pair[1]].append(pair) # print(xs) # print(ys) newy = set() sumix = set() sumiy = set() sumi = set() for k in xs: if len(xs[k]) > 1: for pair in xs[k]: newy.add(pair[1]) sumiy.add(pair[1]) sumi.add(pair) sumiy.add(k) newx = set() while True: for y in newy: for pair in ys[y]: if pair[0] not in sumix: newx.add(pair[0]) sumix.add(pair[0]) sumi.add(pair) # print(newx) newy = set() for x in newx: for pair in xs[x]: if pair[1] not in sumiy: newy.add(pair[1]) sumiy.add(pair[1]) sumi.add(pair) if newy == set(): break for k in ys: if len(ys[k]) > 1: for pair in ys[k]: newx.add(pair[0]) sumix.add(pair[0]) sumi.add(pair) sumix.add(k) newy = set() while True: for x in newx: for pair in xs[x]: if pair[1] not in sumiy: newy.add(pair[1]) sumiy.add(pair[1]) sumi.add(pair) # print(newx) newx = set() for y in newy: for pair in ys[y]: if pair[0] not in sumix: newx.add(pair[0]) sumix.add(pair[0]) sumi.add(pair) if newx == set(): break if sumi == set(): print(0) exit() ssx = sorted(sumix) xran = len(ssx) ssy = sorted(sumiy) yran = len(ssy) print(xran * yran - len(sumi))
Statement There are N dots in a two-dimensional plane. The coordinates of the i-th dot are (x_i, y_i). We will repeat the following operation as long as possible: * Choose four integers a, b, c, d (a \neq c, b \neq d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b) and (c, d), and add a dot at the remaining position. We can prove that we can only do this operation a finite number of times. Find the maximum number of times we can do the operation.
[{"input": "3\n 1 1\n 5 1\n 5 5", "output": "1\n \n\nBy choosing a = 1, b = 1, c = 5, d = 5, we can add a dot at (1, 5). We cannot\ndo the operation any more, so the maximum number of operations is 1.\n\n* * *"}, {"input": "2\n 10 10\n 20 20", "output": "0\n \n\nThere are only two dots, so we cannot do the operation at all.\n\n* * *"}, {"input": "9\n 1 1\n 2 1\n 3 1\n 4 1\n 5 1\n 1 2\n 1 3\n 1 4\n 1 5", "output": "16\n \n\nWe can do the operation for all choices of the form a = 1, b = 1, c = i, d = j\n(2 \\leq i,j \\leq 5), and no more. Thus, the maximum number of operations is\n16."}]
Print the maximum number of times we can do the operation. * * *
s015974226
Accepted
p02998
Input is given from Standard Input in the following format: N x_1 y_1 : x_N y_N
import sys from bisect import bisect_left sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N = ir() XY = [lr() for _ in range(N)] V = list(range(2 * 10**5 + 1)) # 1-indexed X coordinate、Y coordinateの順番 # Aでxの根を求める def find(A, x): p = A[x] if p == x: return x a = find(A, p) A[x] = a return a # Aでxとyの属する集合の併合 def union(A, x, y): if find(A, x) > find(A, y): bx, by = find(A, y), find(A, x) else: bx, by = find(A, x), find(A, y) A[by] = bx # 根をbxに統一 for x, y in XY: y += 10**5 if find(V, x) != find(V, y): union(V, x, y) set_V = [set() for _ in range(2 * 10**5 + 1)] # 1-indexed for x, y in XY: root = find(V, x) set_V[root] |= set([x, y + 10**5]) set_V = [x for x in set_V if x] answer = 0 for z in set_V: z = sorted(list(z)) cnt_x = bisect_left(z, 10**5 + 1) cnt_y = len(z) - cnt_x answer += cnt_x * cnt_y answer -= N print(answer) # 48
Statement There are N dots in a two-dimensional plane. The coordinates of the i-th dot are (x_i, y_i). We will repeat the following operation as long as possible: * Choose four integers a, b, c, d (a \neq c, b \neq d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b) and (c, d), and add a dot at the remaining position. We can prove that we can only do this operation a finite number of times. Find the maximum number of times we can do the operation.
[{"input": "3\n 1 1\n 5 1\n 5 5", "output": "1\n \n\nBy choosing a = 1, b = 1, c = 5, d = 5, we can add a dot at (1, 5). We cannot\ndo the operation any more, so the maximum number of operations is 1.\n\n* * *"}, {"input": "2\n 10 10\n 20 20", "output": "0\n \n\nThere are only two dots, so we cannot do the operation at all.\n\n* * *"}, {"input": "9\n 1 1\n 2 1\n 3 1\n 4 1\n 5 1\n 1 2\n 1 3\n 1 4\n 1 5", "output": "16\n \n\nWe can do the operation for all choices of the form a = 1, b = 1, c = i, d = j\n(2 \\leq i,j \\leq 5), and no more. Thus, the maximum number of operations is\n16."}]
Print the maximum number of times we can do the operation. * * *
s810299980
Runtime Error
p02998
Input is given from Standard Input in the following format: N x_1 y_1 : x_N y_N
def f_must_be_rectangular(N, Positions): # 参考: https://atcoder.jp/contests/abc131/submissions/6086451 # x軸, y軸をまとめて1つのリストで扱う import sys sys.setrecursionlimit(10**6) vertex_maxsize = 10**5 target = [[] for _ in range(2 * vertex_maxsize)] is_visited = [False] * (2 * vertex_maxsize) for x, y in Positions: y += vertex_maxsize # 1つのリストで扱う都合上、ずらす target[x].append(y) target[y].append(x) def dfs(v): if is_visited[v]: return is_visited[v] = True count[v // vertex_maxsize] += 1 # vがx軸とy軸のどっちを指しているか for u in target[v]: dfs(u) # 頂点vに接続されている頂点へ向かう ans = 0 for i in range(2 * vertex_maxsize): if is_visited[i]: continue count = [0] * 2 dfs(i) # 頂点iにつながっている頂点を調べる # x座標とy座標のそれぞれについて、ペアにすると矩形が完成する # 座標がいくつあるか。その積が解となる ans += count[0] * count[1] return ans - N # 最初に与えられた座標の分、引く N = int(input()) Positions = [[int(i) for i in input().split()] for j in range(N)] print(f_must_be_rectangular(N, Positions))
Statement There are N dots in a two-dimensional plane. The coordinates of the i-th dot are (x_i, y_i). We will repeat the following operation as long as possible: * Choose four integers a, b, c, d (a \neq c, b \neq d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b) and (c, d), and add a dot at the remaining position. We can prove that we can only do this operation a finite number of times. Find the maximum number of times we can do the operation.
[{"input": "3\n 1 1\n 5 1\n 5 5", "output": "1\n \n\nBy choosing a = 1, b = 1, c = 5, d = 5, we can add a dot at (1, 5). We cannot\ndo the operation any more, so the maximum number of operations is 1.\n\n* * *"}, {"input": "2\n 10 10\n 20 20", "output": "0\n \n\nThere are only two dots, so we cannot do the operation at all.\n\n* * *"}, {"input": "9\n 1 1\n 2 1\n 3 1\n 4 1\n 5 1\n 1 2\n 1 3\n 1 4\n 1 5", "output": "16\n \n\nWe can do the operation for all choices of the form a = 1, b = 1, c = i, d = j\n(2 \\leq i,j \\leq 5), and no more. Thus, the maximum number of operations is\n16."}]
Print the maximum number of times we can do the operation. * * *
s367488004
Accepted
p02998
Input is given from Standard Input in the following format: N x_1 y_1 : x_N y_N
from bisect import bisect_left N = int(input()) points = list(tuple(map(int, input().split())) for _ in range(N)) X = sorted(set(x for x, y in points)) Y = sorted(set(y for x, y in points)) points = set((bisect_left(X, x), bisect_left(Y, y)) for x, y in points) xty = [list() for _ in range(len(X))] ytx = [list() for _ in range(len(Y))] for x, y in points: xty[x].append(y) ytx[y].append(x) area = 0 visited = set() for p in points: if p in visited: continue stack = [p] dx = set() dy = set() while stack: x, y = stack.pop() visited.add((x, y)) if x not in dx: for yy in xty[x]: if yy != y: stack.append((x, yy)) dx.add(x) if y not in dy: for xx in ytx[y]: if xx != x: stack.append((xx, y)) dy.add(y) area += len(dx) * len(dy) print(area - len(points))
Statement There are N dots in a two-dimensional plane. The coordinates of the i-th dot are (x_i, y_i). We will repeat the following operation as long as possible: * Choose four integers a, b, c, d (a \neq c, b \neq d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b) and (c, d), and add a dot at the remaining position. We can prove that we can only do this operation a finite number of times. Find the maximum number of times we can do the operation.
[{"input": "3\n 1 1\n 5 1\n 5 5", "output": "1\n \n\nBy choosing a = 1, b = 1, c = 5, d = 5, we can add a dot at (1, 5). We cannot\ndo the operation any more, so the maximum number of operations is 1.\n\n* * *"}, {"input": "2\n 10 10\n 20 20", "output": "0\n \n\nThere are only two dots, so we cannot do the operation at all.\n\n* * *"}, {"input": "9\n 1 1\n 2 1\n 3 1\n 4 1\n 5 1\n 1 2\n 1 3\n 1 4\n 1 5", "output": "16\n \n\nWe can do the operation for all choices of the form a = 1, b = 1, c = i, d = j\n(2 \\leq i,j \\leq 5), and no more. Thus, the maximum number of operations is\n16."}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s401276183
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
n, x, *m = map(int, open(0).read().split()) ans = -1 for i in sorted(m): if x>=i: x -= i ans+=1 print(ans+x//min(m))
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s375206305
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
n,x=map(int,input().split()) a=list(int(input()) for _ range(n)) print(n+(x-sum(a))//min(a))
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s516707213
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
n,x=map(int,input().suplit.()) a=list(int(input()) for _ range(n)) print(n+(x-sum(a))//min(a))
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s425002227
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
n,x=map(int,input().split.()) a=list(int(input()) for _ range(n)) print(n+(x-sum(a))//min(a))
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s236335749
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
n, x = map(int, input().split()) l = [] for i in range(n): l.append(int(input()) print(int((x- sum(l)) // min(l)))
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s153753591
Accepted
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
n, x = [int(num) for num in input().split()] list = [] for i in range(n): list.append(int(input())) counter = 0 # お菓子を全部作る counter += len(list) x -= sum(list) # mの小さいお菓子に集中投下 counter += x // min(list) print(counter)
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s030454871
Accepted
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
n, x = [int(x) for x in input().split()] ml = [] for i in range(n): ml.append(int(input())) ml.sort() if sum(ml) == x: ans = n elif sum(ml) < x: ans = n + (x - sum(ml)) // ml[0] print(ans)
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s536787124
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
n,x=map(int,input().split()) a=[int(input()) for _ range(n)] print(n+((x-sum(a))//min(a)))
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s813161908
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
n,x=map(int,input().split()) l=[int(input()) for i in range(n)] print(n+(x-sum(l)//min(l))
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s261686961
Wrong Answer
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
shurui, total = map(int, input().split(" ")) s = [int(input()) for i in range(shurui)] remain = total - sum(s) print(remain) flag = True count = len(s) while flag == True: if remain - min(s) >= 0: remain = remain - min(s) count += 1 else: flag = False print(count)
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s639827219
Accepted
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
def getinputdata(): # 配列初期化 array_result = [] data = input() array_result.append(data.split(" ")) flg = True try: while flg: data = input() array_temp = [] if data != "": array_result.append(data.split(" ")) flg = True else: flg = False finally: return array_result arr_data = getinputdata() n = int(arr_data[0][0]) x = int(arr_data[0][1]) mindata = int(arr_data[1][0]) for i in range(1, 1 + n): x -= int(arr_data[i][0]) mindata = int(arr_data[i][0]) if mindata > int(arr_data[i][0]) else mindata mysum = n print(mysum + x // mindata)
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s590154289
Accepted
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
x, y = map(int, input().split()) mi = 1000 for i in range(x): z = int(input()) y -= z mi = min(mi, z) print(x + (y // mi))
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s256843485
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
n = int(input().split()) t = [int(input()) for i in range(n)] b = n[1] for i in range(len(t)): b = b-t[i] print(n[0]+int(b/min(t))
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s252418915
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
a, b = list(map(int, input().split())) all_ = [] while a: all_.append(int(input())) else: num_a = a res_a = b - sum(all_) minimum = min(all_) num_b = res_a / minimum print(num_a + num_b)
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s499447452
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
#include <bits/stdc++.h> using namespace std; #define int long long #define FOR(i, j, k) for(int i = j; i < k; ++i) #define rep(i, j) FOR(i, 0, j) #define INF 1e9 #define LINF 1e18 typedef unsigned long long ull; typedef pair<int, int> P; typedef pair<P, int> Pi; typedef pair<P, P> PP; const int MOD = 1e9 + 7; const int dy[]={0, 0, 1, -1}; const int dx[]={1, -1, 0, 0}; template <class T> void chmin(T& a, const T& b) { a = min(a, b); } template <class T> void chmax(T& a, const T& b) { a = max(a, b); } int m[101]; signed main() { cin.tie(0); ios::sync_with_stdio(false); int n, x; cin >> n >> x; int mini = INF; rep(i, n) { cin >> m[i]; x -= m[i]; chmin(mini, m[i]); } cout << n + x / mini << endl; return 0; }
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s123034578
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
N,X = (map(int, input().split())) m = [0] * N for i in range(N): m[i] = int(input()) for i in range(N): X = X - m[i] min_value = min(m) ind = m.index(min_value) count = N while X - m[ind]=> 0: X = X - m[ind] count += 1 print(count)
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s416000586
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
N, X = map(int, input().split()) range_N = range(N) m = [] for i in range_N: m.append(int(input())) # 最低でも消費する量を求める。 min_consump = sum(m) # 残りのお菓子の元の量 rest = X - min_consump # 残りの量と、一つのドーナツを作るのに消費する量で最大公約数を求める if rest != 0: max_num = 0 for consump in m: doughnut = rest // consump if doughnut > max_num : max_num = doughnut print(len(m) + max_num) else:print(len(m))
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s039515674
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
=list(map(int,input().split())) N = l[0] X = l[1] list_m = [int(input()) for x in range(N)] list_m.sort() s = sum(list_m) r = X - s for i in range(10**5): r -= list_m[0] if r < 0: lim = i break print(N + lim)
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s652922931
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
kona,,kona = map(int,input().split()) grum = [] sum_grum=0 for i in range(kind): grum.append(input()) for j in range(kind): sum_grum = sum_grum+int(grum[j]) kona = kona - sum_grum minimun = int(min(grum)) if kona>=minimun: kona_sec = kona//minimun print(kind+kona_sec)
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s676743737
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] tmp = br.readLine().split(" "); int N = Integer.parseInt(tmp[0]); int X = Integer.parseInt(tmp[1]); List<Integer> m = new ArrayList<Integer>(); int oneDo = 0; for (int n = 0; n < N; n++) { m.add(Integer.parseInt(br.readLine())); oneDo += m.get(n); } X -= oneDo; int count = N; m.sort(null); int min = m.get(0); while(X >= min){ X -= min; count++; } System.out.println(count); } }
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s727447322
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
N = list(input().strip(",")) D =N[1] AA = [] for i in range(N[0]): Q = input().split() AA.append(Q) D -= Q if D==0: print(N[0]) else: ans = N[0] while True: if D>0 D -= min(AA) ans += 1 else: break print(ans)
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s801960013
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
N,X = map(int(),input().split()) a=[] for i in range(N): a.append(int(input()) a.sort() for j in range(N): X=X-a[j] count = n while True: if(x<int(a[0])): print(count) break else: x -= int(a[0]) count += 1 n,x=map(int,input().split()) a=[] for i in range(n): a.append(int(input())) a.sort() for j in range(0,n): x-=int(a[j]) count = n while True: if(x<int(a[0])): print(count) break else: x -= int(a[0]) count += 1
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s353818572
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
n, x = map(int, input().split()) m = [0]*n for i in range(n): m[i] = int(input()) m.sort() ans = 0 flag = False while x > 0: for i in range(n): if x >= m[i]: x -= m[i] ans += 1 else: flag = True break if flag: break key = m[0] while x > 0: if x >= key: x -= key ans += 1 else: flag = True break if flag: break print(ans)
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s593445810
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
sum = 0 answer = 900 a, b = (int(i) for i in input().split()) t = [int(input()) for j in range(a)] for k in range a: b = b - t[k] sum = sum + 1 t = t.sort() z = b % t[0] sum = sum + z print(sum)
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s028010440
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
N,X = map(int(),input().split()) a=[] for i in range(N): a.append(int(input()) a.sort() for j in range(N): X=X-a[N] F=X // a[0] print(N+F)
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s138832214
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
N,X = map(int(),input().split()) a=[] for i in range(N): a.append(int(input()) a.sort() for j in range(N): X=X-a[N] F=X//a[0] print(N+F)
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s875094807
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
N,X = map(int(),input().split()) a=[] for i in range(N): a.append(int(input()) a.sort() for j in range(N): X=X-a[j] F=X // a[0] print(N+F)
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s522410066
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
n = int(input()) li = list(map(int, input().split())) print(max(li) - min(li))
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s192583867
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
n, x = map(int, input().split()) l = [int(i) for i in range(n)] print(n+((x-sum(l))//min(l))
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s902453229
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
N, X, *m = input().split() num = N + (X - sum(m)) // min(m) print(m)
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s042739178
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
5 3000 150 130 150 130 110
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s122574680
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
n,x=map(int,input().split()) m=[int(input) for _ in range(n)] m.sort() num=x-sum(m) print(n+(num//(min(m)))
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s114869192
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
A,B,C,X,Y=(int(i) for i in input().split()) if A+B<2*C: print(A*X+B*Y) elif min(X,Y)<=2*C: if X>Y: print((X-Y)*A+2*Y*C) else: print((Y-X)*B+2*X*C) elif A<=B: if X>Y: print(2*C*Y+(X-Y)*A) else: orint(2*C*Y) else: if X<Y: print(2*C*X+(Y-X)*B) else: print(2*C*X) for i in range(print(2*C*max(X,Y))
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
Print the maximum number of doughnuts that can be made under the condition. * * *
s531040256
Runtime Error
p03370
Input is given from Standard Input in the following format: N X m_1 m_2 : m_N
N, X = [int(i) for i in input().split()] m = [input().split()] for i in range(N): m(i) = int(m(i)) X = X - sum(m) num = X // min(m) num = num + N print(num)
Statement Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
[{"input": "3 1000\n 120\n 100\n 140", "output": "9\n \n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes\none doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360\ngrams of Moto. From the 640 grams of Moto that remains here, she can make\nadditional six Doughnuts 2. This is how she can made a total of nine\ndoughnuts, which is the maximum.\n\n* * *"}, {"input": "4 360\n 90\n 90\n 90\n 90", "output": "4\n \n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\n* * *"}, {"input": "5 3000\n 150\n 130\n 150\n 130\n 110", "output": "26"}]
On the first line, print the maximum number of tiles that can be placed. On the next N lines, print a configulation that achieves the maximum. Precisely, output the strings t_1,t_2,\cdots,t_N constructed by the following way. * t_i is initialized to S_i. * For each (i,j), if there is a tile that occupies (i,j) and (i+1,j), change t_{i,j}:=`v`, t_{i+1,j}:=`^`. * For each (i,j), if there is a tile that occupies (i,j) and (i,j+1), change t_{i,j}:=`>`, t_{i,j+1}:=`<`. See samples for further information. You may print any configulation that maximizes the number of tiles. * * *
s939099330
Accepted
p02561
Input is given from Standard Input in the following format: N M S_1 S_2 \vdots S_N
class mf_graph: def __init__(self, n=0): self._n = n self.g = [[] for _ in range(n)] self.pos = [] def add_edge(self, frm, to, cap): m = len(self.pos) e1 = mf_graph._edge(to, cap) e2 = mf_graph._edge(frm, 0) e1.rev = e2 e2.rev = e1 self.pos.append(e1) self.g[frm].append(e1) self.g[to].append(e2) return m class edge: def __init__(self, frm, to, cap, flow): self.frm = frm self.to = to self.cap = cap self.flow = flow def __iter__(self): yield self.frm yield self.to yield self.cap yield self.flow def get_edge(self, i): e1 = self.pos[i] e2 = e1.rev return mf_graph.edge(e2.to, e1.to, e1.cap + e2.cap, e2.cap) def edges(self): return [self.get_edge(i) for i in range(len(self.pos))] def change_edge(self, i, new_cap, new_flow): e = self.pos[i] e.cap = new_cap - new_flow e.rev.cap = new_flow def flow(self, s, t, flow_limit=0xFFFFFFFFFFFFFFF): g = self.g flow = 0 es = [[] for _ in range(self._n)] while flow < flow_limit: level = [-1] * self._n level[s] = 0 que = [None] * self._n ql = 0 qr = 1 que[0] = s unreached = s != t lvl = 1 for p in es: p.clear() while unreached and ql < qr: nqr = qr while ql < qr: v = que[ql] ql += 1 for e in g[v]: to = e.to if e.cap and not 0 <= level[to] < lvl: es[to].append(e.rev) if level[to] < 0: level[to] = lvl if to == t: unreached = False que[nqr] = to nqr += 1 qr = nqr lvl += 1 if unreached: return flow stack = [] v = t up = flow_limit - flow res = 0 while True: if v == s or not es[v]: if v == s: res = up while stack: tmp = res e, up, res = stack.pop() e.cap -= tmp e.rev.cap += tmp res += tmp if res < up: v = e.to break else: flow += res break else: e = es[v].pop() stack.append((e.rev, up, res)) v = e.to up = min(up, e.rev.cap) res = 0 return flow def min_cut(self, s): visited = [False] * self._n que = [None] * self._n ql = 0 qr = 1 que[0] = s visited[s] = True while ql < qr: p = que[ql] ql += 1 for e in self.g[p]: if e.cap and not visited[e.to]: visited[e.to] = True que[qr] = e.to qr += 1 return visited class _edge: def __init__(self, to, cap): self.to = to self.cap = cap n, m = map(int, input().split()) s = [input() for _ in range(n)] g = mf_graph(n * m + 2) for i in range(n): for j in range(i % 2, m, 2): if s[i][j] == "#": continue for di, dj in (1, 0), (0, 1), (-1, 0), (0, -1): x, y = i + di, j + dj if 0 <= x < n and 0 <= y < m and s[x][y] == ".": g.add_edge(i * m + j, x * m + y, 1) for i in range(n): for j in range(m): if s[i][j] == "#": continue if (i + j) % 2 == 0: g.add_edge(n * m, i * m + j, 1) else: g.add_edge(i * m + j, n * m + 1, 1) print(g.flow(n * m, n * m + 1)) ans = [list(si) for si in s] for frm, to, cap, flow in g.edges(): if flow and frm < n * m and to < n * m: i, j = frm // m, frm % m x, y = to // m, to % m if j == y: if i > x: i, j, x, y = x, y, i, j ans[i][j], ans[x][y] = "v^" else: if j > y: i, j, x, y = x, y, i, j ans[i][j], ans[x][y] = "><" for a in ans: print("".join(a))
Statement You are given a grid of N rows and M columns. The square at the i-th row and j-th column will be denoted as (i,j). Some of the squares contain an object. All the remaining squares are empty. The state of the grid is represented by strings S_1,S_2,\cdots,S_N. The square (i,j) contains an object if S_{i,j}= `#` and is empty if S_{i,j}= `.`. Consider placing 1 \times 2 tiles on the grid. Tiles can be placed vertically or horizontally to cover two adjacent empty squares. Tiles must not stick out of the grid, and no two different tiles may intersect. Tiles cannot occupy the square with an object. Calculate the maximum number of tiles that can be placed and any configulation that acheives the maximum.
[{"input": "3 3\n #..\n ..#\n ...", "output": "3\n #><\n vv#\n ^^.\n \n\nThe following output is also treated as a correct answer.\n\n \n \n 3\n #><\n v.#\n ^><"}]
On the first line, print the maximum number of tiles that can be placed. On the next N lines, print a configulation that achieves the maximum. Precisely, output the strings t_1,t_2,\cdots,t_N constructed by the following way. * t_i is initialized to S_i. * For each (i,j), if there is a tile that occupies (i,j) and (i+1,j), change t_{i,j}:=`v`, t_{i+1,j}:=`^`. * For each (i,j), if there is a tile that occupies (i,j) and (i,j+1), change t_{i,j}:=`>`, t_{i,j+1}:=`<`. See samples for further information. You may print any configulation that maximizes the number of tiles. * * *
s153021468
Accepted
p02561
Input is given from Standard Input in the following format: N M S_1 S_2 \vdots S_N
code = r""" # distutils: language=c++ # distutils: include_dirs=[/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include, /opt/atcoder-stl] # cython: boundscheck=False # cython: wraparound=False from libcpp.vector cimport vector from libcpp cimport bool cdef extern from "<atcoder/maxflow>" namespace "atcoder": cdef cppclass mf_graph[Cap]: mf_graph(int n) int add_edge(int fr, int to, Cap cap) Cap flow(int s, int t) Cap flow(int s, int t, Cap flow_limit) vector[bool] min_cut(int s) cppclass edge: int frm "from" int to Cap cap Cap flow edge(edge &e) edge get_edge(int i) vector[edge] edges() void change_edge(int i, Cap new_cap, Cap new_flow) cdef class MfGraph: cdef mf_graph[int] *_thisptr def __cinit__(self, int n): self._thisptr = new mf_graph[int](n) cpdef int add_edge(self, int fr, int to, int cap): return self._thisptr.add_edge(fr, to, cap) cpdef int flow(self, int s, int t): return self._thisptr.flow(s, t) cpdef int flow_with_limit(self, int s, int t, int flow_limit): return self._thisptr.flow(s, t, flow_limit) cpdef vector[bool] min_cut(self, int s): return self._thisptr.min_cut(s) cpdef vector[int] get_edge(self, int i): cdef mf_graph[int].edge *e = new mf_graph[int].edge(self._thisptr.get_edge(i)) cdef vector[int] *ret_e = new vector[int]() ret_e.push_back(e.frm) ret_e.push_back(e.to) ret_e.push_back(e.cap) ret_e.push_back(e.flow) return ret_e[0] cpdef vector[vector[int]] edges(self): cdef vector[mf_graph[int].edge] es = self._thisptr.edges() cdef vector[vector[int]] *ret_es = new vector[vector[int]](es.size()) for i in range(es.size()): ret_es.at(i).push_back(es.at(i).frm) ret_es.at(i).push_back(es.at(i).to) ret_es.at(i).push_back(es.at(i).cap) ret_es.at(i).push_back(es.at(i).flow) return ret_es[0] cpdef void change_edge(self, int i, int new_cap, int new_flow): self._thisptr.change_edge(i, new_cap, new_flow) """ import os, sys if sys.argv[-1] == "ONLINE_JUDGE": open("atcoder.pyx", "w").write(code) os.system("cythonize -i -3 -b atcoder.pyx") from atcoder import MfGraph N, M = list(map(int, input().split())) S = [input() for i in range(N)] mg = MfGraph(N * M + 2) s = N * M t = N * M + 1 for i in range(N): for j in range(M): if S[i][j] == "#": continue v = i * M + j if (i + j) % 2 == 0: mg.add_edge(s, v, 1) else: mg.add_edge(v, t, 1) for i in range(N): for j in range(M): if (i + j) % 2 == 1 or S[i][j] == "#": continue v0 = i * M + j if i > 0: if S[i - 1][j] == ".": v1 = (i - 1) * M + j mg.add_edge(v0, v1, 1) if j > 0: if S[i][j - 1] == ".": v1 = i * M + j - 1 mg.add_edge(v0, v1, 1) if i < N - 1: if S[i + 1][j] == ".": v1 = (i + 1) * M + j mg.add_edge(v0, v1, 1) if j < M - 1: if S[i][j + 1] == ".": v1 = i * M + j + 1 mg.add_edge(v0, v1, 1) print(mg.flow(s, t)) edges = mg.edges() T = [list(__) for __ in S] for e in edges: if e[0] == s or e[1] == t or e[3] == 0: continue i0 = e[0] // M j0 = e[0] % M i1 = e[1] // M j1 = e[1] % M if i0 == i1 + 1: T[i1][j1] = "v" T[i0][j0] = "^" elif j0 == j1 + 1: T[i1][j1] = ">" T[i0][j0] = "<" elif i0 == i1 - 1: T[i1][j1] = "^" T[i0][j0] = "v" else: T[i1][j1] = "<" T[i0][j0] = ">" for __ in T: print("".join(__))
Statement You are given a grid of N rows and M columns. The square at the i-th row and j-th column will be denoted as (i,j). Some of the squares contain an object. All the remaining squares are empty. The state of the grid is represented by strings S_1,S_2,\cdots,S_N. The square (i,j) contains an object if S_{i,j}= `#` and is empty if S_{i,j}= `.`. Consider placing 1 \times 2 tiles on the grid. Tiles can be placed vertically or horizontally to cover two adjacent empty squares. Tiles must not stick out of the grid, and no two different tiles may intersect. Tiles cannot occupy the square with an object. Calculate the maximum number of tiles that can be placed and any configulation that acheives the maximum.
[{"input": "3 3\n #..\n ..#\n ...", "output": "3\n #><\n vv#\n ^^.\n \n\nThe following output is also treated as a correct answer.\n\n \n \n 3\n #><\n v.#\n ^><"}]
Print the total number of biscuits produced within T + 0.5 seconds after activation. * * *
s633682714
Wrong Answer
p03059
Input is given from Standard Input in the following format: A B T
A, B, T = map(int, input().split()) a = T + 0.5 b = a // A print(b * B)
Statement A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation. Find the total number of biscuits produced within T + 0.5 seconds after activation.
[{"input": "3 5 7", "output": "10\n \n\n * Five biscuits will be produced three seconds after activation.\n * Another five biscuits will be produced six seconds after activation.\n * Thus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\n* * *"}, {"input": "3 2 9", "output": "6\n \n\n* * *"}, {"input": "20 20 19", "output": "0"}]
Print the total number of biscuits produced within T + 0.5 seconds after activation. * * *
s543193889
Accepted
p03059
Input is given from Standard Input in the following format: A B T
val = [int(i) for i in input().split()] print(int(((val[2] + 0.5) // val[0]) * val[1]))
Statement A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation. Find the total number of biscuits produced within T + 0.5 seconds after activation.
[{"input": "3 5 7", "output": "10\n \n\n * Five biscuits will be produced three seconds after activation.\n * Another five biscuits will be produced six seconds after activation.\n * Thus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\n* * *"}, {"input": "3 2 9", "output": "6\n \n\n* * *"}, {"input": "20 20 19", "output": "0"}]
Print the total number of biscuits produced within T + 0.5 seconds after activation. * * *
s868419470
Runtime Error
p03059
Input is given from Standard Input in the following format: A B T
n = int(input()) A = list(map(int, input().split())) mina = 10**9 minus = 0 sumA = 0 for a in A: if a < 0: minus += 1 a = -a sumA += a mina = min(a, mina) if minus % 2 == 1: sumA -= 2 * mina print(sumA)
Statement A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation. Find the total number of biscuits produced within T + 0.5 seconds after activation.
[{"input": "3 5 7", "output": "10\n \n\n * Five biscuits will be produced three seconds after activation.\n * Another five biscuits will be produced six seconds after activation.\n * Thus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\n* * *"}, {"input": "3 2 9", "output": "6\n \n\n* * *"}, {"input": "20 20 19", "output": "0"}]
Print the total number of biscuits produced within T + 0.5 seconds after activation. * * *
s095163790
Accepted
p03059
Input is given from Standard Input in the following format: A B T
a, b, n = [int(i) for i in input().split(" ")] print(n // a * b)
Statement A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation. Find the total number of biscuits produced within T + 0.5 seconds after activation.
[{"input": "3 5 7", "output": "10\n \n\n * Five biscuits will be produced three seconds after activation.\n * Another five biscuits will be produced six seconds after activation.\n * Thus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\n* * *"}, {"input": "3 2 9", "output": "6\n \n\n* * *"}, {"input": "20 20 19", "output": "0"}]
Print the total number of biscuits produced within T + 0.5 seconds after activation. * * *
s357917354
Runtime Error
p03059
Input is given from Standard Input in the following format: A B T
n = input().strip().split(" ") N = int(n) print(N[1] * N[2] // N[1])
Statement A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation. Find the total number of biscuits produced within T + 0.5 seconds after activation.
[{"input": "3 5 7", "output": "10\n \n\n * Five biscuits will be produced three seconds after activation.\n * Another five biscuits will be produced six seconds after activation.\n * Thus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\n* * *"}, {"input": "3 2 9", "output": "6\n \n\n* * *"}, {"input": "20 20 19", "output": "0"}]
Print the total number of biscuits produced within T + 0.5 seconds after activation. * * *
s096415615
Wrong Answer
p03059
Input is given from Standard Input in the following format: A B T
i = list(map(int, input().split())) a = i[2] + 0.5 b = a // i[0] print(b * i[1])
Statement A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation. Find the total number of biscuits produced within T + 0.5 seconds after activation.
[{"input": "3 5 7", "output": "10\n \n\n * Five biscuits will be produced three seconds after activation.\n * Another five biscuits will be produced six seconds after activation.\n * Thus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\n* * *"}, {"input": "3 2 9", "output": "6\n \n\n* * *"}, {"input": "20 20 19", "output": "0"}]
Print the total number of biscuits produced within T + 0.5 seconds after activation. * * *
s958703157
Runtime Error
p03059
Input is given from Standard Input in the following format: A B T
a = map(int, input().split()) s = a[2] // a[0] print(s * a[1])
Statement A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation. Find the total number of biscuits produced within T + 0.5 seconds after activation.
[{"input": "3 5 7", "output": "10\n \n\n * Five biscuits will be produced three seconds after activation.\n * Another five biscuits will be produced six seconds after activation.\n * Thus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\n* * *"}, {"input": "3 2 9", "output": "6\n \n\n* * *"}, {"input": "20 20 19", "output": "0"}]
Print the total number of biscuits produced within T + 0.5 seconds after activation. * * *
s454739794
Wrong Answer
p03059
Input is given from Standard Input in the following format: A B T
A, B, T = input().split(" ") print(int(int(T) / int(A)) * B)
Statement A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation. Find the total number of biscuits produced within T + 0.5 seconds after activation.
[{"input": "3 5 7", "output": "10\n \n\n * Five biscuits will be produced three seconds after activation.\n * Another five biscuits will be produced six seconds after activation.\n * Thus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\n* * *"}, {"input": "3 2 9", "output": "6\n \n\n* * *"}, {"input": "20 20 19", "output": "0"}]
Print the total number of biscuits produced within T + 0.5 seconds after activation. * * *
s626183789
Accepted
p03059
Input is given from Standard Input in the following format: A B T
line = list(map(int, input().split())) a = (line[2] // line[0]) * line[1] print(a)
Statement A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation. Find the total number of biscuits produced within T + 0.5 seconds after activation.
[{"input": "3 5 7", "output": "10\n \n\n * Five biscuits will be produced three seconds after activation.\n * Another five biscuits will be produced six seconds after activation.\n * Thus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\n* * *"}, {"input": "3 2 9", "output": "6\n \n\n* * *"}, {"input": "20 20 19", "output": "0"}]
Print the total number of biscuits produced within T + 0.5 seconds after activation. * * *
s831958442
Accepted
p03059
Input is given from Standard Input in the following format: A B T
a = list(map(int, input().split())) # input from array of integer like "1 2 3" print((a[2] // a[0]) * a[1])
Statement A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation. Find the total number of biscuits produced within T + 0.5 seconds after activation.
[{"input": "3 5 7", "output": "10\n \n\n * Five biscuits will be produced three seconds after activation.\n * Another five biscuits will be produced six seconds after activation.\n * Thus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\n* * *"}, {"input": "3 2 9", "output": "6\n \n\n* * *"}, {"input": "20 20 19", "output": "0"}]
Print the total number of biscuits produced within T + 0.5 seconds after activation. * * *
s895104349
Accepted
p03059
Input is given from Standard Input in the following format: A B T
ABT = input().split() A = [int(i) for i in ABT] A[2] += 0.5 print(int(A[2] / A[0]) * A[1])
Statement A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation. Find the total number of biscuits produced within T + 0.5 seconds after activation.
[{"input": "3 5 7", "output": "10\n \n\n * Five biscuits will be produced three seconds after activation.\n * Another five biscuits will be produced six seconds after activation.\n * Thus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\n* * *"}, {"input": "3 2 9", "output": "6\n \n\n* * *"}, {"input": "20 20 19", "output": "0"}]
Print the total number of biscuits produced within T + 0.5 seconds after activation. * * *
s759797791
Wrong Answer
p03059
Input is given from Standard Input in the following format: A B T
s = list(map(int, input().split())) z = (s[2] + 0.5) // s[0] w = s[1] * z print(w)
Statement A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation. Find the total number of biscuits produced within T + 0.5 seconds after activation.
[{"input": "3 5 7", "output": "10\n \n\n * Five biscuits will be produced three seconds after activation.\n * Another five biscuits will be produced six seconds after activation.\n * Thus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\n* * *"}, {"input": "3 2 9", "output": "6\n \n\n* * *"}, {"input": "20 20 19", "output": "0"}]
Print the total number of biscuits produced within T + 0.5 seconds after activation. * * *
s291820673
Wrong Answer
p03059
Input is given from Standard Input in the following format: A B T
ABC = input().rstrip().split(" ") A = int(ABC[0]) B = int(ABC[1]) C = int(ABC[2]) count = (C + 0.5) // A print(count * B)
Statement A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation. Find the total number of biscuits produced within T + 0.5 seconds after activation.
[{"input": "3 5 7", "output": "10\n \n\n * Five biscuits will be produced three seconds after activation.\n * Another five biscuits will be produced six seconds after activation.\n * Thus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\n* * *"}, {"input": "3 2 9", "output": "6\n \n\n* * *"}, {"input": "20 20 19", "output": "0"}]
Print the total number of biscuits produced within T + 0.5 seconds after activation. * * *
s253877390
Accepted
p03059
Input is given from Standard Input in the following format: A B T
line = input() numbers = [int(n) for n in line.split()] time = numbers[2] * 10 + 5 biscuits = numbers[1] time_taken = numbers[0] * 10 predicted_value = 0 while time >= 0: if time - time_taken >= 0: predicted_value += biscuits time -= time_taken print(predicted_value)
Statement A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation. Find the total number of biscuits produced within T + 0.5 seconds after activation.
[{"input": "3 5 7", "output": "10\n \n\n * Five biscuits will be produced three seconds after activation.\n * Another five biscuits will be produced six seconds after activation.\n * Thus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\n* * *"}, {"input": "3 2 9", "output": "6\n \n\n* * *"}, {"input": "20 20 19", "output": "0"}]
Print the total number of biscuits produced within T + 0.5 seconds after activation. * * *
s985234173
Accepted
p03059
Input is given from Standard Input in the following format: A B T
a, b, t = input().split() a, b, t = int(a), int(b), int(t) # doubleをintで割ってもdoubleになってしまう(暗黙的) # print((t+0.5)//a) print((int((t + 0.5) / a)) * b)
Statement A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation. Find the total number of biscuits produced within T + 0.5 seconds after activation.
[{"input": "3 5 7", "output": "10\n \n\n * Five biscuits will be produced three seconds after activation.\n * Another five biscuits will be produced six seconds after activation.\n * Thus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\n* * *"}, {"input": "3 2 9", "output": "6\n \n\n* * *"}, {"input": "20 20 19", "output": "0"}]
Print the total number of biscuits produced within T + 0.5 seconds after activation. * * *
s963295832
Wrong Answer
p03059
Input is given from Standard Input in the following format: A B T
def main(A, B, T): return print(B * (T // A))
Statement A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation. Find the total number of biscuits produced within T + 0.5 seconds after activation.
[{"input": "3 5 7", "output": "10\n \n\n * Five biscuits will be produced three seconds after activation.\n * Another five biscuits will be produced six seconds after activation.\n * Thus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\n* * *"}, {"input": "3 2 9", "output": "6\n \n\n* * *"}, {"input": "20 20 19", "output": "0"}]
Print the total number of biscuits produced within T + 0.5 seconds after activation. * * *
s163960039
Wrong Answer
p03059
Input is given from Standard Input in the following format: A B T
n = input() print(n)
Statement A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation. Find the total number of biscuits produced within T + 0.5 seconds after activation.
[{"input": "3 5 7", "output": "10\n \n\n * Five biscuits will be produced three seconds after activation.\n * Another five biscuits will be produced six seconds after activation.\n * Thus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\n* * *"}, {"input": "3 2 9", "output": "6\n \n\n* * *"}, {"input": "20 20 19", "output": "0"}]
Print the total number of biscuits produced within T + 0.5 seconds after activation. * * *
s379238313
Accepted
p03059
Input is given from Standard Input in the following format: A B T
# coding:utf-8 import sys # from collections import Counter, defaultdict INF = float("inf") MOD = 10**9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def II(): return int(sys.stdin.readline()) def SI(): return input() def main(): a, b, t = LI() res = 0 for i in range(a, 21, a): if i < t + 0.5: res += b return res print(main())
Statement A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation. Find the total number of biscuits produced within T + 0.5 seconds after activation.
[{"input": "3 5 7", "output": "10\n \n\n * Five biscuits will be produced three seconds after activation.\n * Another five biscuits will be produced six seconds after activation.\n * Thus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\n* * *"}, {"input": "3 2 9", "output": "6\n \n\n* * *"}, {"input": "20 20 19", "output": "0"}]
Print the total number of biscuits produced within T + 0.5 seconds after activation. * * *
s039733773
Accepted
p03059
Input is given from Standard Input in the following format: A B T
a = input().split() t = int(a[2]) + 0.5 print(int(t // int(a[0]) * int(a[1])))
Statement A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation. Find the total number of biscuits produced within T + 0.5 seconds after activation.
[{"input": "3 5 7", "output": "10\n \n\n * Five biscuits will be produced three seconds after activation.\n * Another five biscuits will be produced six seconds after activation.\n * Thus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\n* * *"}, {"input": "3 2 9", "output": "6\n \n\n* * *"}, {"input": "20 20 19", "output": "0"}]
Print the total number of biscuits produced within T + 0.5 seconds after activation. * * *
s619453167
Accepted
p03059
Input is given from Standard Input in the following format: A B T
A = list(map(int, input().split())) print((A[2] // A[0]) * A[1])
Statement A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation. Find the total number of biscuits produced within T + 0.5 seconds after activation.
[{"input": "3 5 7", "output": "10\n \n\n * Five biscuits will be produced three seconds after activation.\n * Another five biscuits will be produced six seconds after activation.\n * Thus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\n* * *"}, {"input": "3 2 9", "output": "6\n \n\n* * *"}, {"input": "20 20 19", "output": "0"}]
Print the total number of biscuits produced within T + 0.5 seconds after activation. * * *
s092302376
Wrong Answer
p03059
Input is given from Standard Input in the following format: A B T
a, b, c = [int(i) for i in input().split()] d = a // c print(b * d)
Statement A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation. Find the total number of biscuits produced within T + 0.5 seconds after activation.
[{"input": "3 5 7", "output": "10\n \n\n * Five biscuits will be produced three seconds after activation.\n * Another five biscuits will be produced six seconds after activation.\n * Thus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\n* * *"}, {"input": "3 2 9", "output": "6\n \n\n* * *"}, {"input": "20 20 19", "output": "0"}]
Print the total number of biscuits produced within T + 0.5 seconds after activation. * * *
s636296169
Accepted
p03059
Input is given from Standard Input in the following format: A B T
abt = [int(s) for s in input().split(" ")] print(str(int(abt[2] / abt[0]) * abt[1]))
Statement A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation. Find the total number of biscuits produced within T + 0.5 seconds after activation.
[{"input": "3 5 7", "output": "10\n \n\n * Five biscuits will be produced three seconds after activation.\n * Another five biscuits will be produced six seconds after activation.\n * Thus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\n* * *"}, {"input": "3 2 9", "output": "6\n \n\n* * *"}, {"input": "20 20 19", "output": "0"}]
Print the total number of biscuits produced within T + 0.5 seconds after activation. * * *
s014185654
Wrong Answer
p03059
Input is given from Standard Input in the following format: A B T
a, b, t = map(int, "20 20 19".split()) print(sum([b for _ in range(a, t + 1, a)]))
Statement A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation. Find the total number of biscuits produced within T + 0.5 seconds after activation.
[{"input": "3 5 7", "output": "10\n \n\n * Five biscuits will be produced three seconds after activation.\n * Another five biscuits will be produced six seconds after activation.\n * Thus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\n* * *"}, {"input": "3 2 9", "output": "6\n \n\n* * *"}, {"input": "20 20 19", "output": "0"}]