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 minimum number of operations required when Ringo can freely decide how Snuke walks. * * *
s299255092
Accepted
p03132
Input is given from Standard Input in the following format: L A_1 : A_L
N = int(input()) A = [] for i in range(N): A.append(int(input())) dat = [A[i] for i in range(N)] for i in range(1, N): dat[i] += dat[i - 1] evenf = [0] * N evenf[0] = A[0] % 2 for i in range(1, N): t = A[i] % 2 if A[i] == 0: t = 2 evenf[i] = min(evenf[i - 1] + t, dat[i]) evenb = [0] * N evenb[N - 1] = A[-1] % 2 for i in range(N - 2, -1, -1): t = A[i] % 2 if A[i] == 0: t = 2 if i != 0: evenb[i] = min(evenb[i + 1] + t, dat[-1] - dat[i - 1]) else: evenb[i] = min(evenb[i + 1] + t, dat[-1]) oddf = [0 for i in range(N)] for i in range(1, N): t = (1 + A[i]) % 2 oddf[i] = min(oddf[i - 1] + t, evenf[i]) ans = oddf[-1] for i in range(N - 1): ans = min(ans, evenb[i + 1] + oddf[i]) print(ans)
Statement Snuke stands on a number line. He has L ears, and he will walk along the line continuously under the following conditions: * He never visits a point with coordinate less than 0, or a point with coordinate greater than L. * He starts walking at a point with integer coordinate, and also finishes walking at a point with integer coordinate. * He only changes direction at a point with integer coordinate. Each time when Snuke passes a point with coordinate i-0.5, where i is an integer, he put a stone in his i-th ear. After Snuke finishes walking, Ringo will repeat the following operations in some order so that, for each i, Snuke's i-th ear contains A_i stones: * Put a stone in one of Snuke's ears. * Remove a stone from one of Snuke's ears. Find the minimum number of operations required when Ringo can freely decide how Snuke walks.
[{"input": "4\n 1\n 0\n 2\n 3", "output": "1\n \n\nAssume that Snuke walks as follows:\n\n * He starts walking at coordinate 3 and finishes walking at coordinate 4, visiting coordinates 3,4,3,2,3,4 in this order.\n\nThen, Snuke's four ears will contain 0,0,2,3 stones, respectively. Ringo can\nsatisfy the requirement by putting one stone in the first ear.\n\n* * *"}, {"input": "8\n 2\n 0\n 0\n 2\n 1\n 3\n 4\n 1", "output": "3\n \n\n* * *"}, {"input": "7\n 314159265\n 358979323\n 846264338\n 327950288\n 419716939\n 937510582\n 0", "output": "1"}]
Print the minimum number of operations required when Ringo can freely decide how Snuke walks. * * *
s660148785
Accepted
p03132
Input is given from Standard Input in the following format: L A_1 : A_L
import sys def calc(itr): dp = [0] turn, no_turn, no_visit = 0, 0, 0 for a in itr: b = a % 2 new_turn = min(turn, no_visit) + (2 if a == 0 else b) new_no_turn = min(turn, no_turn, no_visit) + (b ^ 1) new_no_visit = no_visit + a dp.append(min(new_turn, new_no_turn, new_no_visit)) turn, no_turn, no_visit = new_turn, new_no_turn, new_no_visit return dp l = int(input()) aaa = list(map(int, sys.stdin)) dp_f = calc(aaa) dp_b = calc(reversed(aaa)) dp_b.reverse() print(min(map(sum, zip(dp_f, dp_b))))
Statement Snuke stands on a number line. He has L ears, and he will walk along the line continuously under the following conditions: * He never visits a point with coordinate less than 0, or a point with coordinate greater than L. * He starts walking at a point with integer coordinate, and also finishes walking at a point with integer coordinate. * He only changes direction at a point with integer coordinate. Each time when Snuke passes a point with coordinate i-0.5, where i is an integer, he put a stone in his i-th ear. After Snuke finishes walking, Ringo will repeat the following operations in some order so that, for each i, Snuke's i-th ear contains A_i stones: * Put a stone in one of Snuke's ears. * Remove a stone from one of Snuke's ears. Find the minimum number of operations required when Ringo can freely decide how Snuke walks.
[{"input": "4\n 1\n 0\n 2\n 3", "output": "1\n \n\nAssume that Snuke walks as follows:\n\n * He starts walking at coordinate 3 and finishes walking at coordinate 4, visiting coordinates 3,4,3,2,3,4 in this order.\n\nThen, Snuke's four ears will contain 0,0,2,3 stones, respectively. Ringo can\nsatisfy the requirement by putting one stone in the first ear.\n\n* * *"}, {"input": "8\n 2\n 0\n 0\n 2\n 1\n 3\n 4\n 1", "output": "3\n \n\n* * *"}, {"input": "7\n 314159265\n 358979323\n 846264338\n 327950288\n 419716939\n 937510582\n 0", "output": "1"}]
Print the minimum number of operations required when Ringo can freely decide how Snuke walks. * * *
s277430730
Wrong Answer
p03132
Input is given from Standard Input in the following format: L A_1 : A_L
def calc(A): tmp = [not (a % 2) for a in A] tl = 0 max_tl = 0 for tf in tmp: if tf: tl += 1 else: max_tl = max(max_tl, tl) tl = 0 return sum(tmp), max_tl L = int(input()) A = [0 for i in range(L)] ans = 0 max_tl = 0 zs, ze, zl = 0, 0, 0 for i in range(L): Ai = int(input()) A[i] = Ai if Ai == 0: A[i] = 1 if zl == 0: zs = i zl += 1 continue elif zl != 0: sub_sum = sum(A[ze:zs]) if sub_sum > zl: tmp_sum, tl = calc(A[ze:zs]) max_tl = max(max_tl, tl) ans += tmp_sum else: ans += zl ze = i zl = 0 tmp_sum, tl = calc(A[ze:]) max_tl = max(max_tl, tl) ans += tmp_sum print(ans - max_tl)
Statement Snuke stands on a number line. He has L ears, and he will walk along the line continuously under the following conditions: * He never visits a point with coordinate less than 0, or a point with coordinate greater than L. * He starts walking at a point with integer coordinate, and also finishes walking at a point with integer coordinate. * He only changes direction at a point with integer coordinate. Each time when Snuke passes a point with coordinate i-0.5, where i is an integer, he put a stone in his i-th ear. After Snuke finishes walking, Ringo will repeat the following operations in some order so that, for each i, Snuke's i-th ear contains A_i stones: * Put a stone in one of Snuke's ears. * Remove a stone from one of Snuke's ears. Find the minimum number of operations required when Ringo can freely decide how Snuke walks.
[{"input": "4\n 1\n 0\n 2\n 3", "output": "1\n \n\nAssume that Snuke walks as follows:\n\n * He starts walking at coordinate 3 and finishes walking at coordinate 4, visiting coordinates 3,4,3,2,3,4 in this order.\n\nThen, Snuke's four ears will contain 0,0,2,3 stones, respectively. Ringo can\nsatisfy the requirement by putting one stone in the first ear.\n\n* * *"}, {"input": "8\n 2\n 0\n 0\n 2\n 1\n 3\n 4\n 1", "output": "3\n \n\n* * *"}, {"input": "7\n 314159265\n 358979323\n 846264338\n 327950288\n 419716939\n 937510582\n 0", "output": "1"}]
Print the minimum number of operations required when Ringo can freely decide how Snuke walks. * * *
s261030407
Wrong Answer
p03132
Input is given from Standard Input in the following format: L A_1 : A_L
n = int(input()) A = [int(input()) for i in range(n)] s = 0 Z = [] R = [] z = 0 r = 0 for a in A: if a == 0: z += 1 r += a Z.append(z) R.append(r) for i in range(n - 1, -1, -1): if Z[i] >= R[i]: s += sum(A[: i + 1]) A = A[i + 1 :] break if A == []: print(s) exit() Z = [] R = [] z = 0 r = 0 for a in A[::-1]: if a == 0: z += 1 r += a Z.append(z) R.append(r) Z = Z[::-1] R = R[::-1] for i in range(len(A)): if Z[i] >= R[i]: s += sum(A[i:]) A = A[:i] break if A == []: print(s) exit() for i in range(len(A)): if A[i] == 0: s += 1 A[i] = 1 s0 = s O = [] E = [] o = 0 e = 0 for a in A: if a % 2 == 0: e += 1 else: o += 1 E.append(e) O.append(o) l = 0 f = 0 for i in range(len(A) - 1, -1, -1): if E[i] > O[i] and f == 1: s += O[i] A = A[i + 1 :] break if A[i] == 1: f = 1 O = [] E = [] o = 0 e = 0 for a in A[::-1]: if a % 2 == 0: e += 1 else: o += 1 E.append(e) O.append(o) l = 0 f = 0 E = E[::-1] O = O[::-1] for i in range(len(A)): if E[i] > O[i]: s += O[i] A = A[i + 1 :] break O = [] E = [] o = 0 e = 0 for a in A[::-1]: if a % 2 == 0: e += 1 else: o += 1 E.append(e) O.append(o) l = 0 f = 0 E = E[::-1] O = O[::-1] for i in range(len(A)): if E[i] > O[i]: s0 += O[i] A = A[i + 1 :] break O = [] E = [] o = 0 e = 0 for a in A: if a % 2 == 0: e += 1 else: o += 1 E.append(e) O.append(o) l = 0 f = 0 for i in range(len(A) - 1, -1, -1): if E[i] > O[i]: s0 += O[i] A = A[i + 1 :] break print(min(s, s0))
Statement Snuke stands on a number line. He has L ears, and he will walk along the line continuously under the following conditions: * He never visits a point with coordinate less than 0, or a point with coordinate greater than L. * He starts walking at a point with integer coordinate, and also finishes walking at a point with integer coordinate. * He only changes direction at a point with integer coordinate. Each time when Snuke passes a point with coordinate i-0.5, where i is an integer, he put a stone in his i-th ear. After Snuke finishes walking, Ringo will repeat the following operations in some order so that, for each i, Snuke's i-th ear contains A_i stones: * Put a stone in one of Snuke's ears. * Remove a stone from one of Snuke's ears. Find the minimum number of operations required when Ringo can freely decide how Snuke walks.
[{"input": "4\n 1\n 0\n 2\n 3", "output": "1\n \n\nAssume that Snuke walks as follows:\n\n * He starts walking at coordinate 3 and finishes walking at coordinate 4, visiting coordinates 3,4,3,2,3,4 in this order.\n\nThen, Snuke's four ears will contain 0,0,2,3 stones, respectively. Ringo can\nsatisfy the requirement by putting one stone in the first ear.\n\n* * *"}, {"input": "8\n 2\n 0\n 0\n 2\n 1\n 3\n 4\n 1", "output": "3\n \n\n* * *"}, {"input": "7\n 314159265\n 358979323\n 846264338\n 327950288\n 419716939\n 937510582\n 0", "output": "1"}]
Print the minimum number of operations required when Ringo can freely decide how Snuke walks. * * *
s175335728
Accepted
p03132
Input is given from Standard Input in the following format: L A_1 : A_L
# coding: utf-8 # Your code here! # k,a,b = [int(i) for i in input().split()] l = int(input()) a = [int(input()) for i in [0] * l] asum = [0] * (l + 1) for i in range(1, l + 1): asum[i] = asum[i - 1] + a[i - 1] reven = [0] * (l + 1) leven = [0] * (l + 1) rodd = [0] * (l + 1) lodd = [0] * (l + 1) for i in range(1, l + 1): if a[i - 1] != 0: leven[i] = leven[i - 1] + a[i - 1] % 2 else: leven[i] = min(2 + leven[i - 1], asum[i]) for i in range(l - 1, -1, -1): if a[i] != 0: reven[i] = reven[i + 1] + a[i] % 2 else: reven[i] = min(2 + reven[i + 1], asum[l] - asum[i]) for i in range(1, l + 1): lodd[i] = min(leven[i], lodd[i - 1] + (a[i - 1] + 1) % 2, asum[i]) for i in range(l - 1, -1, -1): rodd[i] = min(reven[i], rodd[i + 1] + (a[i] + 1) % 2, asum[l] - asum[i]) # print(asum) # print(reven) # print(leven) # print(rodd) # print(lodd) ans = 5 * (l + 2) for i in range(l + 1): ans = min(ans, leven[i] + rodd[i], lodd[i] + reven[i]) print(ans)
Statement Snuke stands on a number line. He has L ears, and he will walk along the line continuously under the following conditions: * He never visits a point with coordinate less than 0, or a point with coordinate greater than L. * He starts walking at a point with integer coordinate, and also finishes walking at a point with integer coordinate. * He only changes direction at a point with integer coordinate. Each time when Snuke passes a point with coordinate i-0.5, where i is an integer, he put a stone in his i-th ear. After Snuke finishes walking, Ringo will repeat the following operations in some order so that, for each i, Snuke's i-th ear contains A_i stones: * Put a stone in one of Snuke's ears. * Remove a stone from one of Snuke's ears. Find the minimum number of operations required when Ringo can freely decide how Snuke walks.
[{"input": "4\n 1\n 0\n 2\n 3", "output": "1\n \n\nAssume that Snuke walks as follows:\n\n * He starts walking at coordinate 3 and finishes walking at coordinate 4, visiting coordinates 3,4,3,2,3,4 in this order.\n\nThen, Snuke's four ears will contain 0,0,2,3 stones, respectively. Ringo can\nsatisfy the requirement by putting one stone in the first ear.\n\n* * *"}, {"input": "8\n 2\n 0\n 0\n 2\n 1\n 3\n 4\n 1", "output": "3\n \n\n* * *"}, {"input": "7\n 314159265\n 358979323\n 846264338\n 327950288\n 419716939\n 937510582\n 0", "output": "1"}]
Print the maximum total number of monsters the heroes can defeat. * * *
s797726412
Accepted
p02959
Input is given from Standard Input in the following format: N A_1 A_2 ... A_{N+1} B_1 B_2 ... B_N
N = int(input()) monsters = list(map(int, input().split())) powers = list(map(int, input().split())) # dp[i] = i番目の街のモンスターを最も多く倒せる数 dp = [0 for _ in range(N + 1)] # 初期条件 # 勇者パワーの方が少ない場合その数しか倒せない # モンスター数の方が少ない場合もその数しか倒せない # print(f"powers: {powers}") dp[N] = min(monsters[N], powers[N - 1]) # 勇者の火力を減らしておく powers[N - 1] -= dp[N] # Nから-1ずつ下がって0まで処理する for i in range(N - 1, 0, -1): # print(f"powers: {powers}") # i番目の倒せる最大数を求める # i番目の勇者がi+1番目のモンスターを倒して残った火力 + i-1番目の勇者の火力と # i番目のモンスター数の内、少ない方が倒せる最大数になる dp[i] = min(powers[i] + powers[i - 1], monsters[i]) # i-1番目の勇者の火力を減らしておく # ただしi番目の勇者で十分倒せる火力の場合何も減らさない powers[i - 1] -= max(dp[i] - powers[i], 0) # print(f"powers: {powers}") # 0番目の勇者の倒せる最大数を求める dp[0] = min(powers[0], monsters[0]) print(sum(dp))
Statement There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
[{"input": "2\n 3 5 2\n 4 5", "output": "9\n \n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine\nmonsters in total, which is the maximum result.\n\n * The first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n * The second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\n* * *"}, {"input": "3\n 5 6 3 8\n 5 100 8", "output": "22\n \n\n* * *"}, {"input": "2\n 100 1 1\n 1 100", "output": "3"}]
Print the maximum total number of monsters the heroes can defeat. * * *
s436572793
Wrong Answer
p02959
Input is given from Standard Input in the following format: N A_1 A_2 ... A_{N+1} B_1 B_2 ... B_N
N = int(input()) inputsA = input().split() inputsB = input().split() A = [int(n) for n in inputsA] B = [int(n) for n in inputsB] enemy = 0 attack = 0 dif = 0 enemy += A[0] temp = A[0] - B[0] if temp > 0: dif += temp for i in range(1, N): enemy += A[i] attack += B[i - 1] temp = A[i] - B[i - 1] - B[i] if temp > 0: dif += temp enemy += A[N] attack += B[N - 1] temp = A[N] - B[N - 1] if temp > 0: dif += temp result = enemy - dif if result > attack: result = attack print(result)
Statement There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
[{"input": "2\n 3 5 2\n 4 5", "output": "9\n \n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine\nmonsters in total, which is the maximum result.\n\n * The first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n * The second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\n* * *"}, {"input": "3\n 5 6 3 8\n 5 100 8", "output": "22\n \n\n* * *"}, {"input": "2\n 100 1 1\n 1 100", "output": "3"}]
Print the maximum total number of monsters the heroes can defeat. * * *
s635053537
Accepted
p02959
Input is given from Standard Input in the following format: N A_1 A_2 ... A_{N+1} B_1 B_2 ... B_N
n = int(input()) aaa = list(map(int, input().split())) sa = sum(aaa) bbb = list(map(int, input().split())) for i, b in enumerate(bbb): c = min(aaa[i], b) aaa[i] -= c aaa[i + 1] -= min(aaa[i + 1], b - c) print(sa - sum(aaa))
Statement There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
[{"input": "2\n 3 5 2\n 4 5", "output": "9\n \n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine\nmonsters in total, which is the maximum result.\n\n * The first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n * The second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\n* * *"}, {"input": "3\n 5 6 3 8\n 5 100 8", "output": "22\n \n\n* * *"}, {"input": "2\n 100 1 1\n 1 100", "output": "3"}]
Print the maximum total number of monsters the heroes can defeat. * * *
s906442978
Wrong Answer
p02959
Input is given from Standard Input in the following format: N A_1 A_2 ... A_{N+1} B_1 B_2 ... B_N
# -*- coding: utf-8 -*- N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) reverse_A = list(reversed(A)) reverse_B = list(reversed(B)) sum = 0 if (B[N - 1] - A[N]) >= (B[0] - A[0]): for n in range(len(reverse_A)): if n == 0: if (reverse_B[n] - reverse_A[n]) >= 0: sum += reverse_A[n] temp = reverse_B[n] - reverse_A[n] else: sum += reverse_B[n] temp = 0 elif n >= 1 and n <= (N - 1): if (temp + reverse_B[n] - reverse_A[n]) >= 0: sum += reverse_A[n] if (temp - reverse_A[n]) >= 0: temp = reverse_B[n] else: temp = temp + reverse_B[n] - reverse_A[n] else: sum += reverse_B[n] temp = 0 elif n == N: if (temp - reverse_A[n]) >= 0: sum += reverse_A[n] else: sum += temp else: for n in range(len(A)): if n == 0: if (B[n] - A[n]) >= 0: sum += A[n] temp = B[n] - A[n] else: sum += B[n] temp = 0 elif n >= 1 and n <= (N - 1): if (temp + B[n] - A[n]) >= 0: sum += A[n] if (temp - A[n]) >= 0: temp = B[n] else: temp = temp + B[n] - A[n] else: sum += B[n] temp = 0 elif n == N: if (temp - A[n]) >= 0: sum += A[n] else: sum += temp print(sum)
Statement There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
[{"input": "2\n 3 5 2\n 4 5", "output": "9\n \n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine\nmonsters in total, which is the maximum result.\n\n * The first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n * The second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\n* * *"}, {"input": "3\n 5 6 3 8\n 5 100 8", "output": "22\n \n\n* * *"}, {"input": "2\n 100 1 1\n 1 100", "output": "3"}]
Print the maximum total number of monsters the heroes can defeat. * * *
s797141728
Accepted
p02959
Input is given from Standard Input in the following format: N A_1 A_2 ... A_{N+1} B_1 B_2 ... B_N
sentence = input() N = int(sentence) sentence = input() a_str = sentence.split() a_list = [int(a) for a in a_str] sentence = input() b_str = sentence.split() b_list = [int(b) for b in b_str] a_list.reverse() b_list.reverse() remain = a_list.pop(0) total_number = 0 for i, b in enumerate(b_list): if remain >= b: total_number += b remain = a_list[i] else: total_number += remain b_remain = b - remain monster_a = a_list[i] if monster_a >= b_remain: total_number += b_remain remain = monster_a - b_remain else: total_number += monster_a remain = 0 print(total_number)
Statement There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
[{"input": "2\n 3 5 2\n 4 5", "output": "9\n \n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine\nmonsters in total, which is the maximum result.\n\n * The first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n * The second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\n* * *"}, {"input": "3\n 5 6 3 8\n 5 100 8", "output": "22\n \n\n* * *"}, {"input": "2\n 100 1 1\n 1 100", "output": "3"}]
Print the maximum total number of monsters the heroes can defeat. * * *
s268575278
Wrong Answer
p02959
Input is given from Standard Input in the following format: N A_1 A_2 ... A_{N+1} B_1 B_2 ... B_N
f = lambda: map(int, input().split()) input() p, *A = f() B = f() s = 0 for a, b in zip(A, B): t = min(b, a + p) p = a - max(0, t - b) s += t print(s)
Statement There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
[{"input": "2\n 3 5 2\n 4 5", "output": "9\n \n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine\nmonsters in total, which is the maximum result.\n\n * The first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n * The second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\n* * *"}, {"input": "3\n 5 6 3 8\n 5 100 8", "output": "22\n \n\n* * *"}, {"input": "2\n 100 1 1\n 1 100", "output": "3"}]
Print the maximum total number of monsters the heroes can defeat. * * *
s527836720
Wrong Answer
p02959
Input is given from Standard Input in the following format: N A_1 A_2 ... A_{N+1} B_1 B_2 ... B_N
import glob # 問題ごとのディレクトリのトップからの相対パス REL_PATH = "ABC\\135\\C" # テスト用ファイル置き場のトップ TOP_PATH = "C:\\AtCoder" class Common: problem = [] index = 0 def __init__(self, rel_path): self.rel_path = rel_path def initialize(self, path): file = open(path) self.problem = file.readlines() self.index = 0 return def input_data(self): try: IS_TEST self.index += 1 return self.problem[self.index - 1] except NameError: return input() def resolve(self): pass def exec_resolve(self): try: IS_TEST for path in glob.glob(TOP_PATH + "\\" + self.rel_path + "/*.txt"): print("Test: " + path) self.initialize(path) self.resolve() print("\n\n") except NameError: self.resolve() class C(Common): def resolve(self): N = int(self.input_data()) monster = [int(i) for i in self.input_data().split()] saver = [int(i) for i in self.input_data().split()] result = 0 remaining = 0 for i in range(N): if saver[i] + remaining > monster[i]: result += monster[i] remaining = saver[i] + remaining - monster[i] else: result += saver[i] + remaining remaining = 0 if remaining > monster[N]: result += monster[N] else: result += remaining print(str(result)) solver = C(REL_PATH) solver.exec_resolve()
Statement There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
[{"input": "2\n 3 5 2\n 4 5", "output": "9\n \n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine\nmonsters in total, which is the maximum result.\n\n * The first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n * The second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\n* * *"}, {"input": "3\n 5 6 3 8\n 5 100 8", "output": "22\n \n\n* * *"}, {"input": "2\n 100 1 1\n 1 100", "output": "3"}]
Print the maximum total number of monsters the heroes can defeat. * * *
s820840800
Accepted
p02959
Input is given from Standard Input in the following format: N A_1 A_2 ... A_{N+1} B_1 B_2 ... B_N
LARGE = 10**9 + 7 def solve_a(test=False, a=2, b=16): if not test: a, b = map(int, input().split()) if (b - a) % 2 == 0: print((a + b) // 2) else: print("IMPOSSIBLE") def solve_b(test=False, n=5, p_list=[5, 2, 3, 4, 1]): if not test: n = int(input()) p_list = list(map(int, input().split())) r = 0 for i in range(n): if p_list[i] != i + 1: r += 1 if r == 0 or r == 2: print("YES") else: print("NO") def solve_c(test=False, n=2, a_list=[3, 5, 2], b_list=[4, 5]): if not test: n = int(input()) a_list = list(map(int, input().split())) b_list = list(map(int, input().split())) res = 0 for i in range(n): if b_list[i] <= a_list[i]: res += b_list[i] a_list[i] -= b_list[i] elif b_list[i] < a_list[i] + a_list[i + 1]: res += b_list[i] a_list[i + 1] -= b_list[i] - a_list[i] a_list[i] = 0 else: res += a_list[i] + a_list[i + 1] a_list[i] = 0 a_list[i + 1] = 0 print(res) def solve_d(test=False, s="??2??5"): if not test: s = input() l = len(s) res_list_new = [0] * 13 res_list_old = [0] * 13 zero_mod = int(s.replace("?", "0")) % 13 res_list_new[zero_mod] += 1 for i in range(1, l + 1): if s[-i] == "?": for k in range(13): res_list_old[k] = res_list_new[k] % LARGE base_mod = pow(10, i - 1, 13) for j in range(1, 10): for k in range(13): res_list_new[(k + base_mod * j) % 13] += res_list_old[k] print(res_list_new[5] % LARGE) # solve_a(test=True, a=2, b=16) # solve_a(test=True, a=0, b=3) # solve_a(test=True, a=998244353, b=99824435) # solve_b(test=True, n=5, p_list=[5, 2, 3, 4, 1]) # solve_b(test=True, n=5, p_list=[2, 4, 3, 5, 1]) # solve_b(test=True, n=7, p_list=[1, 2, 3, 4, 5, 6, 7]) # solve_c(test=True, n=2, a_list=[3, 5, 2], b_list=[4, 5]) # solve_c(test=True, n=3, a_list=[5, 6, 3, 8], b_list=[5, 100, 8]) # solve_c(test=True, n=2, a_list=[100, 1, 1], b_list=[1, 100]) # solve_d(test=True, s='??2??5') # solve_d(test=True, s='?44') # solve_d(test=True, s='7?4') # solve_d(test=True, s='?6?42???8??2??06243????9??3???7258??5??7???????774????4?1??17???9?5?70???76???') solve_c()
Statement There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
[{"input": "2\n 3 5 2\n 4 5", "output": "9\n \n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine\nmonsters in total, which is the maximum result.\n\n * The first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n * The second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\n* * *"}, {"input": "3\n 5 6 3 8\n 5 100 8", "output": "22\n \n\n* * *"}, {"input": "2\n 100 1 1\n 1 100", "output": "3"}]
Print the maximum total number of monsters the heroes can defeat. * * *
s490736587
Wrong Answer
p02959
Input is given from Standard Input in the following format: N A_1 A_2 ... A_{N+1} B_1 B_2 ... B_N
i1 = int(input()) i2 = input().split(" ") i3 = input().split(" ") w = -1 s = 0 for i in range(i1): ii2 = int(i2[i]) ii3 = int(i3[i]) # print(ii2) # print(ii3) if ii2 > ii3: # 引ききれた場合 s += ii3 else: s += ii2 w = ii3 - ii2 iii2 = int(i2[i + 1]) if iii2 > w: s += w w = iii2 - w else: s += iii2 w = 0 print(s)
Statement There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
[{"input": "2\n 3 5 2\n 4 5", "output": "9\n \n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine\nmonsters in total, which is the maximum result.\n\n * The first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n * The second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\n* * *"}, {"input": "3\n 5 6 3 8\n 5 100 8", "output": "22\n \n\n* * *"}, {"input": "2\n 100 1 1\n 1 100", "output": "3"}]
Print the maximum total number of monsters the heroes can defeat. * * *
s707840944
Accepted
p02959
Input is given from Standard Input in the following format: N A_1 A_2 ... A_{N+1} B_1 B_2 ... B_N
from collections import deque N = int(input()) Monsters = deque(map(int, input().split())) Fighters = deque(map(int, input().split())) Knockouts = 0 prev_ftr = 0 while len(Monsters) > 0: mon = Monsters.popleft() ko1 = min(mon, prev_ftr) # print(mon, prev_ftr, ko1) Knockouts += ko1 mon -= ko1 if len(Fighters) > 0: ftr = Fighters.popleft() ko2 = min(mon, ftr) # print(mon, ftr, ko2) Knockouts += ko2 mon -= ko2 prev_ftr = ftr - ko2 print(Knockouts)
Statement There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
[{"input": "2\n 3 5 2\n 4 5", "output": "9\n \n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine\nmonsters in total, which is the maximum result.\n\n * The first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n * The second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\n* * *"}, {"input": "3\n 5 6 3 8\n 5 100 8", "output": "22\n \n\n* * *"}, {"input": "2\n 100 1 1\n 1 100", "output": "3"}]
Print the maximum total number of monsters the heroes can defeat. * * *
s821048453
Accepted
p02959
Input is given from Standard Input in the following format: N A_1 A_2 ... A_{N+1} B_1 B_2 ... B_N
n = int(input()) a = [0] * (n + 1) b = [0] * n a[:] = map(int, input().split()) b[:] = map(int, input().split()) r = sum(a) minab = min(a[0], b[0]) a[0] -= minab b[0] -= minab for ii in range(n): minab = min(a[ii + 1], b[ii]) a[ii + 1] -= minab b[ii] -= minab if ii + 1 < n: minab = min(a[ii + 1], b[ii + 1]) a[ii + 1] -= minab b[ii + 1] -= minab print(r - sum(a))
Statement There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
[{"input": "2\n 3 5 2\n 4 5", "output": "9\n \n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine\nmonsters in total, which is the maximum result.\n\n * The first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n * The second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\n* * *"}, {"input": "3\n 5 6 3 8\n 5 100 8", "output": "22\n \n\n* * *"}, {"input": "2\n 100 1 1\n 1 100", "output": "3"}]
Print the maximum total number of monsters the heroes can defeat. * * *
s790100707
Accepted
p02959
Input is given from Standard Input in the following format: N A_1 A_2 ... A_{N+1} B_1 B_2 ... B_N
N = int(input()) mon = [int(x) for x in input().split()] her = [int(x) for x in input().split()] n = 0 for i in range(len(her)): z = min(mon[i], her[i]) mon[i] -= z her[i] -= z n += z z = min(mon[i + 1], her[i]) mon[i + 1] -= z her[i] -= z n += z print(n)
Statement There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
[{"input": "2\n 3 5 2\n 4 5", "output": "9\n \n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine\nmonsters in total, which is the maximum result.\n\n * The first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n * The second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\n* * *"}, {"input": "3\n 5 6 3 8\n 5 100 8", "output": "22\n \n\n* * *"}, {"input": "2\n 100 1 1\n 1 100", "output": "3"}]
Print the maximum total number of monsters the heroes can defeat. * * *
s492165013
Accepted
p02959
Input is given from Standard Input in the following format: N A_1 A_2 ... A_{N+1} B_1 B_2 ... B_N
n = int(input()) a = list(map(int, input().split())) # 初期のモンスターの数 b = list(map(int, input().split())) # 各勇者が倒せるモンスターの数 num = 0 for i in range(n): # 倒したモンスターの数をnumに追加 num += min(a[i], b[i]) if b[i] - a[i] > 0: # モンスターが残っていないとき # 隣町の勇者が倒せるモンスターの数か,隣町のモンスター全てか. num += min(b[i] - a[i], a[i + 1]) # 隣町のモンスター数は残っているか,全滅しているか. a[i + 1] = max(a[i + 1] - (b[i] - a[i]), 0) print(num)
Statement There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
[{"input": "2\n 3 5 2\n 4 5", "output": "9\n \n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine\nmonsters in total, which is the maximum result.\n\n * The first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n * The second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\n* * *"}, {"input": "3\n 5 6 3 8\n 5 100 8", "output": "22\n \n\n* * *"}, {"input": "2\n 100 1 1\n 1 100", "output": "3"}]
Print the maximum total number of monsters the heroes can defeat. * * *
s918494435
Wrong Answer
p02959
Input is given from Standard Input in the following format: N A_1 A_2 ... A_{N+1} B_1 B_2 ... B_N
S = int(input()) alist = input().split() blist = input().split() for i, a in enumerate(alist): alist[i] = int(a) for i, a in enumerate(blist): blist[i] = int(a) alist.sort() blist.sort() tlist = [] for i, a in enumerate(blist): for b, d in enumerate(alist): if d <= a: tlist.append(alist.pop(b)) print(sum(tlist))
Statement There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
[{"input": "2\n 3 5 2\n 4 5", "output": "9\n \n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine\nmonsters in total, which is the maximum result.\n\n * The first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n * The second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\n* * *"}, {"input": "3\n 5 6 3 8\n 5 100 8", "output": "22\n \n\n* * *"}, {"input": "2\n 100 1 1\n 1 100", "output": "3"}]
Print the maximum total number of monsters the heroes can defeat. * * *
s485842292
Accepted
p02959
Input is given from Standard Input in the following format: N A_1 A_2 ... A_{N+1} B_1 B_2 ... B_N
n = int(input()) a = list(map(int, input().split())) asum = sum(a) b = list(map(int, input().split())) for i in range(n): if ( a[n - i] <= b[n - i - 1] ): # 勇者の次の街にいるモンスターが勇者が倒せる数より少ない場合 b[n - i - 1] -= a[n - i] a[n - i] = 0 if ( a[n - i - 1] <= b[n - i - 1] ): # 勇者の街にいるモンスターが勇者が倒せる数ののこりより少ない場合 b[n - i - 1] -= a[n - i - 1] a[n - i - 1] = 0 else: a[n - i - 1] -= b[n - i - 1] b[n - i - 1] = 0 else: a[n - i] -= b[n - i - 1] b[n - i - 1] = 0 answer = asum - sum(a) print(answer)
Statement There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
[{"input": "2\n 3 5 2\n 4 5", "output": "9\n \n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine\nmonsters in total, which is the maximum result.\n\n * The first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n * The second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\n* * *"}, {"input": "3\n 5 6 3 8\n 5 100 8", "output": "22\n \n\n* * *"}, {"input": "2\n 100 1 1\n 1 100", "output": "3"}]
Print a line containing N integers separated with space. The i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i. If there are multiple possible solutions, you may print any of them. * * *
s591158791
Accepted
p02631
Input is given from Standard Input in the following format: N a_1 a_2 \ldots a_N
#!/usr/bin/env python3 def main() -> None: N = ri() a = rmi() assert len(a) == N result = [] all_xor = 0 for item in a: all_xor ^= item for item in a: result.append(item ^ all_xor) w(" ".join(map(str, result))) def r() -> str: return input().strip() def ri() -> int: return int(r()) def rmi(delim: str = " ") -> tuple: return tuple(map(int, input().split(delim))) def w(data) -> None: print(data) def wm(*data, delim: str = " ") -> None: print(delim.join(map(str, data))) if __name__ == "__main__": import sys sys.setrecursionlimit(10**9) main()
Statement There are N Snuke Cats numbered 1, 2, \ldots, N, where N is **even**. Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written. Recently, they learned the operation called xor (exclusive OR). What is xor? For n non-negative integers x_1, x_2, \ldots, x_n, their xor, x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is defined as follows: * When x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. For example, 3~\textrm{xor}~5 = 6. They wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf. We know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i. Using this information, restore the integer written on the scarf of each Snuke Cat.
[{"input": "4\n 20 11 9 24", "output": "26 5 7 22\n \n\n * 5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n * 26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n * 26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n * 26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information."}]
Print a line containing N integers separated with space. The i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i. If there are multiple possible solutions, you may print any of them. * * *
s871267756
Wrong Answer
p02631
Input is given from Standard Input in the following format: N a_1 a_2 \ldots a_N
input() print(input())
Statement There are N Snuke Cats numbered 1, 2, \ldots, N, where N is **even**. Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written. Recently, they learned the operation called xor (exclusive OR). What is xor? For n non-negative integers x_1, x_2, \ldots, x_n, their xor, x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is defined as follows: * When x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. For example, 3~\textrm{xor}~5 = 6. They wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf. We know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i. Using this information, restore the integer written on the scarf of each Snuke Cat.
[{"input": "4\n 20 11 9 24", "output": "26 5 7 22\n \n\n * 5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n * 26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n * 26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n * 26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information."}]
Print a line containing N integers separated with space. The i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i. If there are multiple possible solutions, you may print any of them. * * *
s353272350
Accepted
p02631
Input is given from Standard Input in the following format: N a_1 a_2 \ldots a_N
n = int(input()) x = [int(x) for x in input().split()] s = x[0] for i in range(1, len(x)): s = s ^ x[i] z = [] for i in range(len(x)): z.append(s ^ x[i]) print(*z)
Statement There are N Snuke Cats numbered 1, 2, \ldots, N, where N is **even**. Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written. Recently, they learned the operation called xor (exclusive OR). What is xor? For n non-negative integers x_1, x_2, \ldots, x_n, their xor, x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is defined as follows: * When x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. For example, 3~\textrm{xor}~5 = 6. They wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf. We know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i. Using this information, restore the integer written on the scarf of each Snuke Cat.
[{"input": "4\n 20 11 9 24", "output": "26 5 7 22\n \n\n * 5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n * 26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n * 26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n * 26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information."}]
Print a line containing N integers separated with space. The i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i. If there are multiple possible solutions, you may print any of them. * * *
s758961156
Accepted
p02631
Input is given from Standard Input in the following format: N a_1 a_2 \ldots a_N
N, *D = map(int, open(0).read().split()) ALL = 0 for d in D: ALL ^= d D = map(lambda x: x ^ ALL, D) print(*D, sep=" ")
Statement There are N Snuke Cats numbered 1, 2, \ldots, N, where N is **even**. Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written. Recently, they learned the operation called xor (exclusive OR). What is xor? For n non-negative integers x_1, x_2, \ldots, x_n, their xor, x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is defined as follows: * When x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. For example, 3~\textrm{xor}~5 = 6. They wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf. We know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i. Using this information, restore the integer written on the scarf of each Snuke Cat.
[{"input": "4\n 20 11 9 24", "output": "26 5 7 22\n \n\n * 5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n * 26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n * 26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n * 26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information."}]
Print a line containing N integers separated with space. The i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i. If there are multiple possible solutions, you may print any of them. * * *
s503793018
Accepted
p02631
Input is given from Standard Input in the following format: N a_1 a_2 \ldots a_N
N = int(input()) A = list(map(int, input().split())) maxA = max(A) maxl = len(bin(maxA)[2:]) binary_c = [0 for _ in range(maxl)] A_binary = [bin(a)[2:].zfill(maxl) for a in A] for a in A_binary: for i, n in enumerate(a): if n == "1": binary_c[i] += 1 is_inv = [] for bc in binary_c: if bc % 2 == 0: is_inv.append(False) else: is_inv.append(True) for a in A_binary: l = [] for i, n in enumerate(a): if is_inv[i]: if n == "0": l.append("1") else: l.append("0") else: l.append(n) print(int("".join(l), 2))
Statement There are N Snuke Cats numbered 1, 2, \ldots, N, where N is **even**. Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written. Recently, they learned the operation called xor (exclusive OR). What is xor? For n non-negative integers x_1, x_2, \ldots, x_n, their xor, x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is defined as follows: * When x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. For example, 3~\textrm{xor}~5 = 6. They wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf. We know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i. Using this information, restore the integer written on the scarf of each Snuke Cat.
[{"input": "4\n 20 11 9 24", "output": "26 5 7 22\n \n\n * 5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n * 26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n * 26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n * 26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information."}]
Print a line containing N integers separated with space. The i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i. If there are multiple possible solutions, you may print any of them. * * *
s153319168
Accepted
p02631
Input is given from Standard Input in the following format: N a_1 a_2 \ldots a_N
n = int(input()) l = list(map(int, input().split())) ret = [0] * n now = 1 for i in range(max(l).bit_length()): z = 0 for j in range(n): if l[j] % 2: z += 1 for j in range(n): ret[j] += (l[j] % 2 + z) % 2 * now l[j] //= 2 now *= 2 print(*ret, sep=" ")
Statement There are N Snuke Cats numbered 1, 2, \ldots, N, where N is **even**. Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written. Recently, they learned the operation called xor (exclusive OR). What is xor? For n non-negative integers x_1, x_2, \ldots, x_n, their xor, x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is defined as follows: * When x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. For example, 3~\textrm{xor}~5 = 6. They wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf. We know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i. Using this information, restore the integer written on the scarf of each Snuke Cat.
[{"input": "4\n 20 11 9 24", "output": "26 5 7 22\n \n\n * 5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n * 26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n * 26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n * 26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information."}]
Print a line containing N integers separated with space. The i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i. If there are multiple possible solutions, you may print any of them. * * *
s823951384
Wrong Answer
p02631
Input is given from Standard Input in the following format: N a_1 a_2 \ldots a_N
n = int(input()) a = list(map(int, input().split())) b = [[] for _ in range(n)] c = [0] * 30 d = [] for i in range(n): m = a[i] while m > 0: b[i].append(m % 2) m //= 2 for i in range(n): for j in range(len(b[i])): c[j] += b[i][j] for i in range(30): c[i] = c[i] % 2 for i in range(n): e = 0 for j in range(len(b[i])): if b[i][j] + c[j] == 1: e += 2**j d.append(e) print(*d)
Statement There are N Snuke Cats numbered 1, 2, \ldots, N, where N is **even**. Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written. Recently, they learned the operation called xor (exclusive OR). What is xor? For n non-negative integers x_1, x_2, \ldots, x_n, their xor, x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is defined as follows: * When x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. For example, 3~\textrm{xor}~5 = 6. They wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf. We know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i. Using this information, restore the integer written on the scarf of each Snuke Cat.
[{"input": "4\n 20 11 9 24", "output": "26 5 7 22\n \n\n * 5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n * 26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n * 26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n * 26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information."}]
Print a line containing N integers separated with space. The i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i. If there are multiple possible solutions, you may print any of them. * * *
s853503108
Wrong Answer
p02631
Input is given from Standard Input in the following format: N a_1 a_2 \ldots a_N
N = int(input()) a = list(map(int, input().split())) b = ["" for i in range(N)] def int_to_2(X): r = "" while X > 0: r = r + str(X % 2) X = int((X - X % 2) / 2) return r for i in range(N): b[i] = int_to_2(a[i]) def xor(aa, bb): rr = "" if len(bb) > len(aa): cc = bb bb = aa aa = cc for i in range(len(aa) - len(bb)): bb = bb + "0" for i in range(len(aa)): if aa[i] != bb[i]: rr = rr + "1" else: rr = rr + "0" return rr def bi_to_int(rr): r = 0 for i in range(len(rr)): r = r + (2**i) * int(rr[i]) return r anss = ["" for i in range(N)] for i in range(N - 1): anss[0] = xor(anss[0], b[i + 1]) for i in range(N - 1): anss[i + 1] = xor(anss[i], xor(b[i], b[i + 1])) writeout = ""
Statement There are N Snuke Cats numbered 1, 2, \ldots, N, where N is **even**. Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written. Recently, they learned the operation called xor (exclusive OR). What is xor? For n non-negative integers x_1, x_2, \ldots, x_n, their xor, x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is defined as follows: * When x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. For example, 3~\textrm{xor}~5 = 6. They wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf. We know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i. Using this information, restore the integer written on the scarf of each Snuke Cat.
[{"input": "4\n 20 11 9 24", "output": "26 5 7 22\n \n\n * 5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n * 26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n * 26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n * 26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information."}]
Print a line containing N integers separated with space. The i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i. If there are multiple possible solutions, you may print any of them. * * *
s903732237
Wrong Answer
p02631
Input is given from Standard Input in the following format: N a_1 a_2 \ldots a_N
N = int(input()) a = list(map(int, input().split())) bina = [] for k in range(N): bina.append(str(bin(a[k]))[2:]) # print(bina) A = 0 b = 1 longest = len(bina[a.index(max(a))]) for k in range(1, longest + 1): foo = 0 for j in range(N): if len(bina[j]) >= k: foo += int(bina[j][-k]) foo = foo % 2 foo = foo * b A += foo b = b * 2 A = str(bin(A))[2:] if longest > len(A): A = "0" * (longest - len(A)) + A # print(A) ans = [0 for k in range(N)] # binans = [] for k in range(N): b = 1 for j in range(1, len(bina[k]) + 1): if bina[k][-j] != A[-j]: ans[k] += b b = b * 2 # binans.append(bin(ans[k])[2:]) ans[k] = str(ans[k]) # print(binans) print(" ".join(ans))
Statement There are N Snuke Cats numbered 1, 2, \ldots, N, where N is **even**. Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written. Recently, they learned the operation called xor (exclusive OR). What is xor? For n non-negative integers x_1, x_2, \ldots, x_n, their xor, x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is defined as follows: * When x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. For example, 3~\textrm{xor}~5 = 6. They wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf. We know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i. Using this information, restore the integer written on the scarf of each Snuke Cat.
[{"input": "4\n 20 11 9 24", "output": "26 5 7 22\n \n\n * 5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n * 26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n * 26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n * 26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information."}]
Print a line containing N integers separated with space. The i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i. If there are multiple possible solutions, you may print any of them. * * *
s315959655
Accepted
p02631
Input is given from Standard Input in the following format: N a_1 a_2 \ldots a_N
# -*- coding: utf-8 -*- def cal_xor(xor_list): ans = None for xi in xor_list: if ans is not None: ans = ans ^ xi else: ans = xi return ans (N,) = map(int, input().split()) a = list(map(int, input().split())) ans_str = "" if N == 2: print("{} {}".format(a[1], a[0])) else: xors = [] for i in range(N // 2): xors.append(a[2 * i] ^ a[2 * i + 1]) sum_xor = cal_xor(xors) for i, ai in enumerate(a): tmp_xor = sum_xor ^ xors[i // 2] if i % 2 == 0: ind = i + 1 else: ind = i - 1 ans = tmp_xor ^ a[ind] ans_str += str(ans) + " " print(ans_str[:-1])
Statement There are N Snuke Cats numbered 1, 2, \ldots, N, where N is **even**. Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written. Recently, they learned the operation called xor (exclusive OR). What is xor? For n non-negative integers x_1, x_2, \ldots, x_n, their xor, x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is defined as follows: * When x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. For example, 3~\textrm{xor}~5 = 6. They wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf. We know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i. Using this information, restore the integer written on the scarf of each Snuke Cat.
[{"input": "4\n 20 11 9 24", "output": "26 5 7 22\n \n\n * 5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n * 26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n * 26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n * 26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information."}]
Print a line containing N integers separated with space. The i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i. If there are multiple possible solutions, you may print any of them. * * *
s815846036
Wrong Answer
p02631
Input is given from Standard Input in the following format: N a_1 a_2 \ldots a_N
N = input() strs = input().split(" ") nums = list(map(int,strs )) all = [] ma = max(nums) ma_l = len(format(ma,"b")) all_nums = [0] * ma_l for num in nums: bins = format(num,"b") bins = bins[::-1] for i,c in enumerate(bins): if c == "1": all_nums[i] += 1 all_nums.reverse() anss = [] for num in nums: s = num bins = format(num,"b") bins = bins[::-1] ans = 0 jo = 1 for i in range(ma_l): if len(bins) - 1 < i: hoge = 0 else: c = bins[i] hoge = int(c ) if (all_nums[i] - hoge) % 2 == 1: ans += jo jo *= 2 anss.append(ans) print(*anss)
Statement There are N Snuke Cats numbered 1, 2, \ldots, N, where N is **even**. Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written. Recently, they learned the operation called xor (exclusive OR). What is xor? For n non-negative integers x_1, x_2, \ldots, x_n, their xor, x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is defined as follows: * When x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. For example, 3~\textrm{xor}~5 = 6. They wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf. We know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i. Using this information, restore the integer written on the scarf of each Snuke Cat.
[{"input": "4\n 20 11 9 24", "output": "26 5 7 22\n \n\n * 5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n * 26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n * 26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n * 26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information."}]
Print a line containing N integers separated with space. The i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i. If there are multiple possible solutions, you may print any of them. * * *
s906683066
Wrong Answer
p02631
Input is given from Standard Input in the following format: N a_1 a_2 \ldots a_N
n = int(input()) a = list(map(int, input().split())) nl = [] for i in a: s = str(format(i, "b")) for c in range(len(s)): if len(nl) > c: if s[len(s) - (c + 1)] == "1": nl[c] += 1 else: if s[len(s) - (c + 1)] == "1": nl.append(1) else: nl.append(0) ansl = [] for i in a: s = str(format(i, "b")) ans = nl.copy() for c in range(len(s)): ans[len(s) - (c + 1)] -= int(s[c]) if ans[len(s) - (c + 1)] % 2 == 0: ans[len(s) - (c + 1)] = 0 else: ans[len(s) - (c + 1)] = 1 p = 0 for i in range(len(s)): p += ans[i] * 2**i ansl.append(p) for i in range(len(ansl) - 1): print(ansl[i], end=" ") print(ansl[len(ansl) - 1])
Statement There are N Snuke Cats numbered 1, 2, \ldots, N, where N is **even**. Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written. Recently, they learned the operation called xor (exclusive OR). What is xor? For n non-negative integers x_1, x_2, \ldots, x_n, their xor, x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is defined as follows: * When x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. For example, 3~\textrm{xor}~5 = 6. They wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf. We know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i. Using this information, restore the integer written on the scarf of each Snuke Cat.
[{"input": "4\n 20 11 9 24", "output": "26 5 7 22\n \n\n * 5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n * 26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n * 26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n * 26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information."}]
Print the shortest time needed to produce at least N cookies not yet eaten. * * *
s057181625
Wrong Answer
p03923
The input is given from Standard Input in the following format: N A
n, a = map(int, input().split()) ans = 10**18 for k in range(2): l = 0 r = n while r - l != 1: m = (r + l) // 2 if m ** (k + 1) >= n: r = m else: l = m for m in range(k + 2): if (l**m) * (r ** ((k + 1) - m)) >= n: ans = min(ans, k * a + l * m + r * ((k + 1) - m)) print(ans)
Statement Rng is baking cookies. Initially, he can bake one cookie per second. He can also eat the cookies baked by himself. When there are x cookies not yet eaten, he can choose to eat all those cookies. After he finishes eating those cookies, the number of cookies he can bake per second becomes x. Note that a cookie always needs to be baked for 1 second, that is, he cannot bake a cookie in 1/x seconds when x > 1. When he choose to eat the cookies, he must eat all of them; he cannot choose to eat only part of them. It takes him A seconds to eat the cookies regardless of how many, during which no cookies can be baked. He wants to give N cookies to Grandma. Find the shortest time needed to produce at least N cookies not yet eaten.
[{"input": "8 1", "output": "7\n \n\nIt is possible to produce 8 cookies in 7 seconds, as follows:\n\n * After 1 second: 1 cookie is done.\n * After 2 seconds: 1 more cookie is done, totaling 2. Now, Rng starts eating those 2 cookies.\n * After 3 seconds: He finishes eating the cookies, and he can now bake 2 cookies per second.\n * After 4 seconds: 2 cookies are done.\n * After 5 seconds: 2 more cookies are done, totaling 4.\n * After 6 seconds: 2 more cookies are done, totaling 6.\n * After 7 seconds: 2 more cookies are done, totaling 8.\n\n* * *"}, {"input": "1000000000000 1000000000000", "output": "1000000000000"}]
Print the shortest time needed to produce at least N cookies not yet eaten. * * *
s978216334
Runtime Error
p03923
The input is given from Standard Input in the following format: N A
n, a = map(int, input().split()) costs = [10**18] * (n + 1) costs[1] = 0 times = [0] * (n + 1) for i in range(1, n + 1): times[i] = costs[i] + (n + i - 1) // i for j in range(2, n // i + 1): costs[i * j] = min(costs[i * j], costs[i] + j + a) print(min(times[1:]))
Statement Rng is baking cookies. Initially, he can bake one cookie per second. He can also eat the cookies baked by himself. When there are x cookies not yet eaten, he can choose to eat all those cookies. After he finishes eating those cookies, the number of cookies he can bake per second becomes x. Note that a cookie always needs to be baked for 1 second, that is, he cannot bake a cookie in 1/x seconds when x > 1. When he choose to eat the cookies, he must eat all of them; he cannot choose to eat only part of them. It takes him A seconds to eat the cookies regardless of how many, during which no cookies can be baked. He wants to give N cookies to Grandma. Find the shortest time needed to produce at least N cookies not yet eaten.
[{"input": "8 1", "output": "7\n \n\nIt is possible to produce 8 cookies in 7 seconds, as follows:\n\n * After 1 second: 1 cookie is done.\n * After 2 seconds: 1 more cookie is done, totaling 2. Now, Rng starts eating those 2 cookies.\n * After 3 seconds: He finishes eating the cookies, and he can now bake 2 cookies per second.\n * After 4 seconds: 2 cookies are done.\n * After 5 seconds: 2 more cookies are done, totaling 4.\n * After 6 seconds: 2 more cookies are done, totaling 6.\n * After 7 seconds: 2 more cookies are done, totaling 8.\n\n* * *"}, {"input": "1000000000000 1000000000000", "output": "1000000000000"}]
If S is a mirror string, print `Yes`. Otherwise, print `No`. * * *
s139026984
Accepted
p03889
The input is given from Standard Input in the following format: S
t = "bpdq" s = list(input()) print("Yes" * (s[::-1] == [t[t.index(i) - 2] for i in s]) or "No")
Statement You are given a string S consisting of letters `b`, `d`, `p` and `q`. Determine whether S is a _mirror string_. Here, a mirror string is a string S such that the following sequence of operations on S results in the same string S: 1. Reverse the order of the characters in S. 2. Replace each occurrence of `b` by `d`, `d` by `b`, `p` by `q`, and `q` by `p`, simultaneously.
[{"input": "pdbq", "output": "Yes\n \n\n* * *"}, {"input": "ppqb", "output": "No"}]
If S is a mirror string, print `Yes`. Otherwise, print `No`. * * *
s111725544
Accepted
p03889
The input is given from Standard Input in the following format: S
mp = {"b": "d", "d": "b", "p": "q", "q": "p"} a = list(input()) b = list(a[::-1]) b = [mp[x] for x in b] print("Yes" if a == b else "No")
Statement You are given a string S consisting of letters `b`, `d`, `p` and `q`. Determine whether S is a _mirror string_. Here, a mirror string is a string S such that the following sequence of operations on S results in the same string S: 1. Reverse the order of the characters in S. 2. Replace each occurrence of `b` by `d`, `d` by `b`, `p` by `q`, and `q` by `p`, simultaneously.
[{"input": "pdbq", "output": "Yes\n \n\n* * *"}, {"input": "ppqb", "output": "No"}]
If S is a mirror string, print `Yes`. Otherwise, print `No`. * * *
s279398259
Runtime Error
p03889
The input is given from Standard Input in the following format: S
import sys dct = {"b": "d", "d", "b", "p": "q", "q": "p"} S = sys.stdin.readline().strip() rev = "" for s in S[::-1]: rev += dct[s] if rev == S: print("Yes") else: print("No")
Statement You are given a string S consisting of letters `b`, `d`, `p` and `q`. Determine whether S is a _mirror string_. Here, a mirror string is a string S such that the following sequence of operations on S results in the same string S: 1. Reverse the order of the characters in S. 2. Replace each occurrence of `b` by `d`, `d` by `b`, `p` by `q`, and `q` by `p`, simultaneously.
[{"input": "pdbq", "output": "Yes\n \n\n* * *"}, {"input": "ppqb", "output": "No"}]
If S is a mirror string, print `Yes`. Otherwise, print `No`. * * *
s181799081
Wrong Answer
p03889
The input is given from Standard Input in the following format: S
s = input().split() if s[0] == "d" and s[3] == "b": if s[1] == "p" and s[2] == "q": print("Yes") elif s[1] == "q" and s[2] == "p": print("Yes") else: print("No") elif s[0] == "b" and s[3] == "d": if s[1] == "p" and s[2] == "q": print("Yes") elif s[1] == "q" and s[2] == "p": print("Yes") else: print("No") elif s[0] == "p" and s[3] == "q": if s[1] == "d" and s[2] == "b": print("Yes") elif s[1] == "b" and s[2] == "d": print("Yes") else: print("No") elif s[0] == "q" and s[3] == "p": if s[1] == "d" and s[2] == "b": print("Yes") elif s[1] == "b" and s[2] == "d": print("Yes") else: print("No") else: print("No")
Statement You are given a string S consisting of letters `b`, `d`, `p` and `q`. Determine whether S is a _mirror string_. Here, a mirror string is a string S such that the following sequence of operations on S results in the same string S: 1. Reverse the order of the characters in S. 2. Replace each occurrence of `b` by `d`, `d` by `b`, `p` by `q`, and `q` by `p`, simultaneously.
[{"input": "pdbq", "output": "Yes\n \n\n* * *"}, {"input": "ppqb", "output": "No"}]
If S is a mirror string, print `Yes`. Otherwise, print `No`. * * *
s300750344
Runtime Error
p03889
The input is given from Standard Input in the following format: S
s = input() is s[::-1].translate(str.maketrans("bdpq","dbqp")) == s: print("Yes") else: print("No")
Statement You are given a string S consisting of letters `b`, `d`, `p` and `q`. Determine whether S is a _mirror string_. Here, a mirror string is a string S such that the following sequence of operations on S results in the same string S: 1. Reverse the order of the characters in S. 2. Replace each occurrence of `b` by `d`, `d` by `b`, `p` by `q`, and `q` by `p`, simultaneously.
[{"input": "pdbq", "output": "Yes\n \n\n* * *"}, {"input": "ppqb", "output": "No"}]
If S is a mirror string, print `Yes`. Otherwise, print `No`. * * *
s160309915
Wrong Answer
p03889
The input is given from Standard Input in the following format: S
b = "b" d = "d" p = "p" q = "q" m = [(b, d), (p, q), (d, b), (q, p)] ans = "Yes" s = input() if len(s) % 2 == 1: ans = "No" else: A = s[: len(s) // 2] B = s[len(s) // 2 :] B = B[::-1] for i in range(len(s) // 2): if (A[i], B[i]) in m: continue else: ans = "NO" print(ans)
Statement You are given a string S consisting of letters `b`, `d`, `p` and `q`. Determine whether S is a _mirror string_. Here, a mirror string is a string S such that the following sequence of operations on S results in the same string S: 1. Reverse the order of the characters in S. 2. Replace each occurrence of `b` by `d`, `d` by `b`, `p` by `q`, and `q` by `p`, simultaneously.
[{"input": "pdbq", "output": "Yes\n \n\n* * *"}, {"input": "ppqb", "output": "No"}]
In the first line, print the arranged cards provided by the Bubble Sort algorithm. Two consecutive cards should be separated by a space character. In the second line, print the stability ("Stable" or "Not stable") of this output. In the third line, print the arranged cards provided by the Selection Sort algorithm. Two consecutive cards should be separated by a space character. In the fourth line, print the stability ("Stable" or "Not stable") of this output.
s328886059
Accepted
p02261
The first line contains an integer _N_ , the number of cards. _N_ cards are given in the following line. Each card is represented by two characters. Two consecutive cards are separated by a space character.
def selectionSort(arr): icnt = 0 for i in range(0, len(arr)): imin = i for j in range(i + 1, len(arr)): if arr[j][1] < arr[imin][1]: # if arr[j] < arr[imin]: imin = j if imin != i: arr[i], arr[imin] = arr[imin], arr[i] icnt = icnt + 1 def bubbleSort(arr): flg = True cnt = 0 while flg: flg = False for i in range(len(arr) - 1, 0, -1): if arr[i][1] < arr[i - 1][1]: # if arr[i] < arr[i - 1]: arr[i - 1], arr[i] = arr[i], arr[i - 1] cnt = cnt + 1 flg = True def combine(arr): result = "" for i in arr: result = result + i[0] + str(i[1]) + " " return result.rstrip(" ") n = int(input()) a = list(input().split()) # [H4, C9, S4, D2, C3] # a = list(map(int, input().split())) b = [] # [[H,4], [C,9], [S,4], [D,2], [C,3]] for i in range(0, len(a)): b.append([a[i][0], int(a[i][1])]) c = b.copy() # c = b bubbleSort(b) result_b = combine(b) selectionSort(c) result_s = combine(c) print(result_b) print("Stable") print(result_s) if result_s == result_b: print("Stable") else: print("Not stable")
Stable Sort Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).
[{"input": "5\n H4 C9 S4 D2 C3", "output": "D2 C3 H4 S4 C9\n Stable\n D2 C3 S4 H4 C9\n Not stable"}, {"input": "2\n S1 H1", "output": "S1 H1\n Stable\n S1 H1\n Stable"}]
In the first line, print the arranged cards provided by the Bubble Sort algorithm. Two consecutive cards should be separated by a space character. In the second line, print the stability ("Stable" or "Not stable") of this output. In the third line, print the arranged cards provided by the Selection Sort algorithm. Two consecutive cards should be separated by a space character. In the fourth line, print the stability ("Stable" or "Not stable") of this output.
s531413753
Accepted
p02261
The first line contains an integer _N_ , the number of cards. _N_ cards are given in the following line. Each card is represented by two characters. Two consecutive cards are separated by a space character.
n = int(input()) l = input().split(" ") L = l[:] for k in range(n - 1): for j in range(n - 1, 0, -1): if L[j][1:] < L[j - 1][1:]: L[j], L[j - 1] = L[j - 1], L[j] m = l[k:].index(min(l[k:], key=lambda x: x[1])) if m != 0: l[k], l[m + k] = l[m + k], l[k] print(*L) print("Stable") print(*l) print(["Not s", "S"][l == L] + "table")
Stable Sort Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).
[{"input": "5\n H4 C9 S4 D2 C3", "output": "D2 C3 H4 S4 C9\n Stable\n D2 C3 S4 H4 C9\n Not stable"}, {"input": "2\n S1 H1", "output": "S1 H1\n Stable\n S1 H1\n Stable"}]
In the first line, print the arranged cards provided by the Bubble Sort algorithm. Two consecutive cards should be separated by a space character. In the second line, print the stability ("Stable" or "Not stable") of this output. In the third line, print the arranged cards provided by the Selection Sort algorithm. Two consecutive cards should be separated by a space character. In the fourth line, print the stability ("Stable" or "Not stable") of this output.
s714498213
Wrong Answer
p02261
The first line contains an integer _N_ , the number of cards. _N_ cards are given in the following line. Each card is represented by two characters. Two consecutive cards are separated by a space character.
# -*- coding: utf-8 -*- def bubble_sort(cards, num): for left in range(num - 1): for right in range(left + 1, num): if cards[right][1] < cards[left][1]: cards[left], cards[right] = cards[right], cards[left] print(list_to_str(cards)) def selection_sort(cards, num): for head in range(num): min_i = head for target in range(head + 1, num): if cards[target][1] < cards[min_i][1]: min_i = target cards[head], cards[min_i] = cards[min_i], cards[head] print(list_to_str(cards)) def is_stable(before, after, num): for i in range(num): for j in range(i + 1, num): for a in range(num): for b in range(a + 1, num): if ( before[i][1] == before[j][1] and before[i] == after[b] and before[j] == after[a] ): return "Not stable" return "Stable" def list_to_str(l, delimiter=" "): # The default delimiter is one space. return delimiter.join([str(v) for v in l]) if __name__ == "__main__": num = int(input()) cards = input().split() cards_for_bubble = cards.copy() cards_for_selection = cards.copy() bubble_sort(cards_for_bubble, num) print(is_stable(cards, cards_for_bubble, num)) selection_sort(cards_for_selection, num) print(is_stable(cards, cards_for_selection, num))
Stable Sort Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).
[{"input": "5\n H4 C9 S4 D2 C3", "output": "D2 C3 H4 S4 C9\n Stable\n D2 C3 S4 H4 C9\n Not stable"}, {"input": "2\n S1 H1", "output": "S1 H1\n Stable\n S1 H1\n Stable"}]
In the first line, print the arranged cards provided by the Bubble Sort algorithm. Two consecutive cards should be separated by a space character. In the second line, print the stability ("Stable" or "Not stable") of this output. In the third line, print the arranged cards provided by the Selection Sort algorithm. Two consecutive cards should be separated by a space character. In the fourth line, print the stability ("Stable" or "Not stable") of this output.
s925104801
Wrong Answer
p02261
The first line contains an integer _N_ , the number of cards. _N_ cards are given in the following line. Each card is represented by two characters. Two consecutive cards are separated by a space character.
def stable(c, c_b): for i in range(N - 1): for j in range(i, N - 1): if c_b[i][1] == c_b[j + 1][1]: index1_cb = c_b.index(c_b[i]) index2_cb = c_b.index(c_b[j + 1]) index1_c = c.index(c_b[i]) index2_c = c.index(c_b[j + 1]) if index1_c < index2_c and index1_cb < index2_cb: print("Stable") else: print("Not stable") def print_list(list): for i in range(N): if i == N - 1: print(list[i]) else: print(list[i], end=" ") N = int(input()) c = input().split() c_b = [s for s in c] for i in range(N): for j in range(N - 1, i, -1): if c_b[j][1] < c_b[j - 1][1]: t = c_b[j] c_b[j] = c_b[j - 1] c_b[j - 1] = t print_list(c_b) stable(c, c_b) c_s = [s for s in c] change = "no" for i in range(N): cs_min = int(c_s[i][1]) for j in range(i + 1, N): if cs_min > int(c_s[j][1]): cs_min = int(c_s[j][1]) index = c_s.index(c_s[j]) change = "ok" if change == "ok": t = c_s[index] c_s[index] = c_s[i] c_s[i] = t change = "no" print_list(c_s) stable(c, c_s)
Stable Sort Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).
[{"input": "5\n H4 C9 S4 D2 C3", "output": "D2 C3 H4 S4 C9\n Stable\n D2 C3 S4 H4 C9\n Not stable"}, {"input": "2\n S1 H1", "output": "S1 H1\n Stable\n S1 H1\n Stable"}]
Print the maximum possible sum of the scores of the pairs. * * *
s748505006
Runtime Error
p03020
Input is given from Standard Input in the following format: N RX_1 RY_1 RC_1 RX_2 RY_2 RC_2 \vdots RX_N RY_N RC_N BX_1 BY_1 BC_1 BX_2 BY_2 BC_2 \vdots BX_N BY_N BC_N
import sys input = sys.stdin.readline from heapq import heappush, heappop def min_cost_flow_dijkstra(E, s, t, f): INF = 1 << 100 NN = N LN = NN.bit_length() G = [[] for _ in range(NN)] for a, b, cap, c in E: G[a].append([b, cap, c, len(G[b])]) G[b].append([a, 0, -c, len(G[a]) - 1]) prevv = [-1] * NN preve = [-1] * NN res = 0 while f > 0: h = [0] * NN dist = [INF] * NN dist[s] = 0 Q = [] heappush(Q, s) while len(Q): x = heappop(Q) d, v = (x >> LN), x % (1 << LN) if dist[v] < d: continue for i, (w, _cap, c, r) in enumerate(G[v]): if _cap > 0 and dist[w] > dist[v] + c + h[v] - h[w]: dist[w] = dist[v] + c + h[v] - h[w] prevv[w] = v preve[w] = i heappush(Q, (dist[w] << LN) + w) if dist[t] == INF: return -1 for v in range(N): h[v] += dist[v] d = f v = t while v != s: d = min(d, G[prevv[v]][preve[v]][1]) v = prevv[v] f -= d res += d * dist[t] v = t while v != s: G[prevv[v]][preve[v]][1] -= d G[v][G[prevv[v]][preve[v]][3]][1] += d v = prevv[v] return res E = [] N = int(input()) su = 0 inf = 1 << 31 for i in range(N): x, y, cnt = map(int, input().split()) E.append((2 * N + 4, i, cnt, 0)) E.append((i, 2 * N, cnt, x + y + inf)) E.append((i, 2 * N + 1, cnt, x - y + inf)) E.append((i, 2 * N + 2, cnt, -x + y + inf)) E.append((i, 2 * N + 3, cnt, -x - y + inf)) su += cnt for i in range(N): x, y, cnt = map(int, input().split()) E.append((i + N, 2 * N + 5, cnt, 0)) E.append((2 * N, i + N, cnt, -x - y + inf)) E.append((2 * N + 1, i + N, cnt, -x + y + inf)) E.append((2 * N + 2, i + N, cnt, x - y + inf)) E.append((2 * N + 3, i + N, cnt, x + y + inf)) print(su * inf * 2 - min_cost_flow_dijkstra(E, 2 * N + 4, 2 * N + 5, su))
Statement Snuke is playing with red and blue balls, placing them on a two-dimensional plane. First, he performed N operations to place red balls. In the i-th of these operations, he placed RC_i red balls at coordinates (RX_i,RY_i). Then, he performed another N operations to place blue balls. In the i-th of these operations, he placed BC_i blue balls at coordinates (BX_i,BY_i). The total number of red balls placed and the total number of blue balls placed are equal, that is, \sum_{i=1}^{N} RC_i = \sum_{i=1}^{N} BC_i. Let this value be S. Snuke will now form S pairs of red and blue balls so that every ball belongs to exactly one pair. Let us define the _score_ of a pair of a red ball at coordinates (rx, ry) and a blue ball at coordinates (bx, by) as |rx-bx| + |ry- by|. Snuke wants to maximize the sum of the scores of the pairs. Help him by finding the maximum possible sum of the scores of the pairs.
[{"input": "2\n 0 0 1\n 3 2 1\n 2 2 1\n 5 0 1", "output": "8\n \n\nIf we pair the red ball at coordinates (0,0) and the blue ball at coordinates\n(2,2), the score of this pair is |0-2| + |0-2|=4. Then, if we pair the red\nball at coordinates (3,2) and the blue ball at coordinates (5,0), the score of\nthis pair is |3-5| + |2-0|=4. Making these two pairs results in the total\nscore of 8, which is the maximum result.\n\n* * *"}, {"input": "3\n 0 0 1\n 2 2 1\n 0 0 2\n 1 1 1\n 1 1 1\n 3 3 2", "output": "16\n \n\nSnuke may have performed multiple operations at the same coordinates.\n\n* * *"}, {"input": "10\n 582463373 690528069 8\n 621230322 318051944 4\n 356524296 974059503 6\n 372751381 111542460 9\n 392867214 581476334 6\n 606955458 513028121 5\n 882201596 791660614 9\n 250465517 91918758 3\n 618624774 406956634 6\n 426294747 736401096 5\n 974896051 888765942 5\n 726682138 336960821 3\n 715144179 82444709 6\n 599055841 501257806 6\n 390484433 962747856 4\n 912334580 219343832 8\n 570458984 648862300 6\n 638017635 572157978 10\n 435958984 585073520 7\n 445612658 234265014 6", "output": "45152033546"}]
Print the maximum possible sum of the scores of the pairs. * * *
s892784998
Runtime Error
p03020
Input is given from Standard Input in the following format: N RX_1 RY_1 RC_1 RX_2 RY_2 RC_2 \vdots RX_N RY_N RC_N BX_1 BY_1 BC_1 BX_2 BY_2 BC_2 \vdots BX_N BY_N BC_N
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np N = int(readline()) S = np.frombuffer(b"-" + readline().rstrip(), "S1") Q = int(readline()) query = map(int, read().split()) isD = S == b"D" isM = S == b"M" isC = S == b"C" cumD = isD.cumsum(dtype=np.int64) cumM = isM.cumsum(dtype=np.int64) def F(K): x = cumD.copy() x[K:] -= cumD[:-K] x *= isM x[K + 1 :] -= isD[1:-K] * (cumM[K:-1] - cumM[: -K - 1]) return (x.cumsum() * isC).sum() print("\n".join(str(F(K)) for K in query))
Statement Snuke is playing with red and blue balls, placing them on a two-dimensional plane. First, he performed N operations to place red balls. In the i-th of these operations, he placed RC_i red balls at coordinates (RX_i,RY_i). Then, he performed another N operations to place blue balls. In the i-th of these operations, he placed BC_i blue balls at coordinates (BX_i,BY_i). The total number of red balls placed and the total number of blue balls placed are equal, that is, \sum_{i=1}^{N} RC_i = \sum_{i=1}^{N} BC_i. Let this value be S. Snuke will now form S pairs of red and blue balls so that every ball belongs to exactly one pair. Let us define the _score_ of a pair of a red ball at coordinates (rx, ry) and a blue ball at coordinates (bx, by) as |rx-bx| + |ry- by|. Snuke wants to maximize the sum of the scores of the pairs. Help him by finding the maximum possible sum of the scores of the pairs.
[{"input": "2\n 0 0 1\n 3 2 1\n 2 2 1\n 5 0 1", "output": "8\n \n\nIf we pair the red ball at coordinates (0,0) and the blue ball at coordinates\n(2,2), the score of this pair is |0-2| + |0-2|=4. Then, if we pair the red\nball at coordinates (3,2) and the blue ball at coordinates (5,0), the score of\nthis pair is |3-5| + |2-0|=4. Making these two pairs results in the total\nscore of 8, which is the maximum result.\n\n* * *"}, {"input": "3\n 0 0 1\n 2 2 1\n 0 0 2\n 1 1 1\n 1 1 1\n 3 3 2", "output": "16\n \n\nSnuke may have performed multiple operations at the same coordinates.\n\n* * *"}, {"input": "10\n 582463373 690528069 8\n 621230322 318051944 4\n 356524296 974059503 6\n 372751381 111542460 9\n 392867214 581476334 6\n 606955458 513028121 5\n 882201596 791660614 9\n 250465517 91918758 3\n 618624774 406956634 6\n 426294747 736401096 5\n 974896051 888765942 5\n 726682138 336960821 3\n 715144179 82444709 6\n 599055841 501257806 6\n 390484433 962747856 4\n 912334580 219343832 8\n 570458984 648862300 6\n 638017635 572157978 10\n 435958984 585073520 7\n 445612658 234265014 6", "output": "45152033546"}]
Print the maximum possible sum of the scores of the pairs. * * *
s098432551
Runtime Error
p03020
Input is given from Standard Input in the following format: N RX_1 RY_1 RC_1 RX_2 RY_2 RC_2 \vdots RX_N RY_N RC_N BX_1 BY_1 BC_1 BX_2 BY_2 BC_2 \vdots BX_N BY_N BC_N
import math N, X = map(int, input().split()) B = [] L = [] U = [] for i in range(N): b, l, u = map(int, input().split()) B += [b] L += [l] U += [u] behind = 0 for i in range(N): behind += L[i] * B[i] gain_max = [(max(X * U[i] - B[i] * (U[i] - L[i]), X * L[i]), i) for i in range(N)] studied = [0 for i in range(N)] ans = 0 gain_max.sort() takahashi_score = 0 while takahashi_score < behind: if takahashi_score + gain_max[-1][0] < behind: ans += X gain = gain_max.pop(-1) takahashi_score += gain[0] studied[gain[1]] = 1 else: # 残り1科目で勝てる! curr = X for i in range(N): if studied[i] == 0: curr = min( curr, min( (behind - takahashi_score - B[i] * L[i]) / U[i] + B[i], (behind - takahashi_score - B[i] * L[i]) / L[i] + B[i], ), ) ans += math.ceil(curr) break print(ans)
Statement Snuke is playing with red and blue balls, placing them on a two-dimensional plane. First, he performed N operations to place red balls. In the i-th of these operations, he placed RC_i red balls at coordinates (RX_i,RY_i). Then, he performed another N operations to place blue balls. In the i-th of these operations, he placed BC_i blue balls at coordinates (BX_i,BY_i). The total number of red balls placed and the total number of blue balls placed are equal, that is, \sum_{i=1}^{N} RC_i = \sum_{i=1}^{N} BC_i. Let this value be S. Snuke will now form S pairs of red and blue balls so that every ball belongs to exactly one pair. Let us define the _score_ of a pair of a red ball at coordinates (rx, ry) and a blue ball at coordinates (bx, by) as |rx-bx| + |ry- by|. Snuke wants to maximize the sum of the scores of the pairs. Help him by finding the maximum possible sum of the scores of the pairs.
[{"input": "2\n 0 0 1\n 3 2 1\n 2 2 1\n 5 0 1", "output": "8\n \n\nIf we pair the red ball at coordinates (0,0) and the blue ball at coordinates\n(2,2), the score of this pair is |0-2| + |0-2|=4. Then, if we pair the red\nball at coordinates (3,2) and the blue ball at coordinates (5,0), the score of\nthis pair is |3-5| + |2-0|=4. Making these two pairs results in the total\nscore of 8, which is the maximum result.\n\n* * *"}, {"input": "3\n 0 0 1\n 2 2 1\n 0 0 2\n 1 1 1\n 1 1 1\n 3 3 2", "output": "16\n \n\nSnuke may have performed multiple operations at the same coordinates.\n\n* * *"}, {"input": "10\n 582463373 690528069 8\n 621230322 318051944 4\n 356524296 974059503 6\n 372751381 111542460 9\n 392867214 581476334 6\n 606955458 513028121 5\n 882201596 791660614 9\n 250465517 91918758 3\n 618624774 406956634 6\n 426294747 736401096 5\n 974896051 888765942 5\n 726682138 336960821 3\n 715144179 82444709 6\n 599055841 501257806 6\n 390484433 962747856 4\n 912334580 219343832 8\n 570458984 648862300 6\n 638017635 572157978 10\n 435958984 585073520 7\n 445612658 234265014 6", "output": "45152033546"}]
Print the maximum possible sum of the scores of the pairs. * * *
s586299590
Accepted
p03020
Input is given from Standard Input in the following format: N RX_1 RY_1 RC_1 RX_2 RY_2 RC_2 \vdots RX_N RY_N RC_N BX_1 BY_1 BC_1 BX_2 BY_2 BC_2 \vdots BX_N BY_N BC_N
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from heapq import heappop, heappush N = int(readline()) m = map(int, read().split()) data = list(zip(m, m, m)) R = data[:N] B = data[N:] class MinCostFlow: """ 最小費用流。負辺がないと仮定して、BellmanFordを省略している。 """ def __init__(self, N, source, sink): self.N = N self.G = [[] for _ in range(N)] self.source = source self.sink = sink def add_edge(self, fr, to, cap, cost): n1 = len(self.G[fr]) n2 = len(self.G[to]) self.G[fr].append([to, cap, cost, n2]) self.G[to].append([fr, 0, -cost, n1]) def MinCost(self, flow, negative_edge=False): if negative_edge: raise ValueError N = self.N G = self.G source = self.source sink = self.sink INF = 10**18 prev_v = [0] * N prev_e = [0] * N # 経路復元用 H = [0] * N # potential mincost = 0 while flow: dist = [INF] * N dist[source] = 0 q = [source] mask = (1 << 20) - 1 while q: x = heappop(q) dv = x >> 20 v = x & mask if dist[v] < dv: continue if v == sink: break for i, (w, cap, cost, rev) in enumerate(G[v]): dw = dist[v] + cost + H[v] - H[w] if (not cap) or (dist[w] <= dw): continue dist[w] = dw prev_v[w] = v prev_e[w] = i heappush(q, (dw << 20) + w) # if dist[sink] == INF: # raise Exception('No Flow Exists') # ポテンシャルの更新 for v, d in enumerate(dist): H[v] += d # 流せる量を取得する d = flow v = sink while v != source: pv = prev_v[v] pe = prev_e[v] cap = G[pv][pe][1] if d > cap: d = cap v = pv # 流す mincost += d * H[sink] flow -= d v = sink while v != source: pv = prev_v[v] pe = prev_e[v] G[pv][pe][1] -= d rev = G[pv][pe][3] G[v][rev][1] += d v = pv return mincost source = N + N sink = N + N + 1 V1 = N + N + 2 V2 = N + N + 3 V3 = N + N + 4 V4 = N + N + 5 G = MinCostFlow(N + N + 6, source=source, sink=sink) base = 10**9 * 2 # 各辺に上乗せしておく -> 最後に引く INF = 10**18 flow = 0 for i, (x, y, c) in enumerate(R): flow += c G.add_edge(fr=source, to=i, cap=c, cost=0) G.add_edge(i, V1, INF, base - x - y) G.add_edge(i, V2, INF, base - x + y) G.add_edge(i, V3, INF, base + x - y) G.add_edge(i, V4, INF, base + x + y) for i, (x, y, c) in enumerate(B, N): G.add_edge(fr=i, to=sink, cap=c, cost=0) G.add_edge(V1, i, INF, base + x + y) G.add_edge(V2, i, INF, base + x - y) G.add_edge(V3, i, INF, base - x + y) G.add_edge(V4, i, INF, base - x - y) cost = G.MinCost(flow) answer = base * (2 * flow) - cost print(answer)
Statement Snuke is playing with red and blue balls, placing them on a two-dimensional plane. First, he performed N operations to place red balls. In the i-th of these operations, he placed RC_i red balls at coordinates (RX_i,RY_i). Then, he performed another N operations to place blue balls. In the i-th of these operations, he placed BC_i blue balls at coordinates (BX_i,BY_i). The total number of red balls placed and the total number of blue balls placed are equal, that is, \sum_{i=1}^{N} RC_i = \sum_{i=1}^{N} BC_i. Let this value be S. Snuke will now form S pairs of red and blue balls so that every ball belongs to exactly one pair. Let us define the _score_ of a pair of a red ball at coordinates (rx, ry) and a blue ball at coordinates (bx, by) as |rx-bx| + |ry- by|. Snuke wants to maximize the sum of the scores of the pairs. Help him by finding the maximum possible sum of the scores of the pairs.
[{"input": "2\n 0 0 1\n 3 2 1\n 2 2 1\n 5 0 1", "output": "8\n \n\nIf we pair the red ball at coordinates (0,0) and the blue ball at coordinates\n(2,2), the score of this pair is |0-2| + |0-2|=4. Then, if we pair the red\nball at coordinates (3,2) and the blue ball at coordinates (5,0), the score of\nthis pair is |3-5| + |2-0|=4. Making these two pairs results in the total\nscore of 8, which is the maximum result.\n\n* * *"}, {"input": "3\n 0 0 1\n 2 2 1\n 0 0 2\n 1 1 1\n 1 1 1\n 3 3 2", "output": "16\n \n\nSnuke may have performed multiple operations at the same coordinates.\n\n* * *"}, {"input": "10\n 582463373 690528069 8\n 621230322 318051944 4\n 356524296 974059503 6\n 372751381 111542460 9\n 392867214 581476334 6\n 606955458 513028121 5\n 882201596 791660614 9\n 250465517 91918758 3\n 618624774 406956634 6\n 426294747 736401096 5\n 974896051 888765942 5\n 726682138 336960821 3\n 715144179 82444709 6\n 599055841 501257806 6\n 390484433 962747856 4\n 912334580 219343832 8\n 570458984 648862300 6\n 638017635 572157978 10\n 435958984 585073520 7\n 445612658 234265014 6", "output": "45152033546"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s032355888
Accepted
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
# coding=utf-8 i = int(input()) rrr = [] for d in range(i): r = [int(input())] rrr += r s = len(set(rrr)) print(s)
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s221322866
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
n = int(input()) List=[int(input()) for i in range(n)] ans = 0 while True for i,j in range(n): if i == j: ans +=1 print(n-ans)
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s989967520
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
N=int(input()) A=[input() i in range(N)] B=[] while len(A)!=0: if A[0] not in B: B.append(A[0]) A.popleft() print(len(B))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s979610225
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
N = int(input()) list_a = [int(input()) for i in range(N)] s = [] for i in list_a: if s.count(i) == 0 s.append(i) print(len(s))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s998558135
Wrong Answer
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
N = int(input()) ls = [int(input()) for i in range(N)] ls = sorted(ls, reverse=True) A = 0 i = 0 while i < N: if ls[i - 1] == ls[i]: A = A + 1 i = i + 1 print(N - A)
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s736929003
Accepted
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
# -*- coding: utf-8 -*- ############# # Libraries # ############# import sys input = sys.stdin.readline import math # from math import gcd import bisect from collections import defaultdict from collections import deque from functools import lru_cache ############# # Constants # ############# MOD = 10**9 + 7 INF = float("inf") ############# # Functions # ############# ######INPUT###### def inputI(): return int(input().strip()) def inputS(): return input().strip() def inputIL(): return list(map(int, input().split())) def inputSL(): return list(map(str, input().split())) def inputILs(n): return list(int(input()) for _ in range(n)) def inputSLs(n): return list(input().strip() for _ in range(n)) def inputILL(n): return [list(map(int, input().split())) for _ in range(n)] def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)] ######OUTPUT###### def Yes(): print("Yes") return def No(): print("No") return #####Inverse##### def inv(n): return pow(n, MOD - 2, MOD) ######Combination###### kaijo_memo = [] def kaijo(n): if len(kaijo_memo) > n: return kaijo_memo[n] if len(kaijo_memo) == 0: kaijo_memo.append(1) while len(kaijo_memo) <= n: kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD) return kaijo_memo[n] gyaku_kaijo_memo = [] def gyaku_kaijo(n): if len(gyaku_kaijo_memo) > n: return gyaku_kaijo_memo[n] if len(gyaku_kaijo_memo) == 0: gyaku_kaijo_memo.append(1) while len(gyaku_kaijo_memo) <= n: gyaku_kaijo_memo.append( gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo), MOD - 2, MOD) % MOD ) return gyaku_kaijo_memo[n] def nCr(n, r): if n == r: return 1 if n < r or r < 0: return 0 ret = 1 ret = ret * kaijo(n) % MOD ret = ret * gyaku_kaijo(r) % MOD ret = ret * gyaku_kaijo(n - r) % MOD return ret ######Factorization###### def factorization(n): arr = [] temp = n for i in range(2, int(-(-(n**0.5) // 1)) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i arr.append([i, cnt]) if temp != 1: arr.append([temp, 1]) if arr == []: arr.append([n, 1]) return arr #####MakeDivisors###### def make_divisors(n): divisors = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n // i) return divisors #####LCM##### def lcm(a, b): return a * b // gcd(a, b) #####BitCount##### def count_bit(n): count = 0 while n: n &= n - 1 count += 1 return count #####ChangeBase##### def Base_10_to_n(X, n): if X // n: return Base_10_to_n(X // n, n) + [X % n] return [X % n] def Base_n_to_10(X, n): return sum(int(str(X)[-i]) * n**i for i in range(len(str(X)))) #####IntLog##### def int_log(n, a): count = 0 while n >= a: n //= a count += 1 return count ############# # Main Code # ############# N = inputI() d = inputILs(N) print(len(set(d)))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s449873619
Accepted
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
import sys from random import randint # from typing import TypeVar, Tuple, List finput = sys.stdin.readline # K = TypeVar("K") class ListNode: def __init__(self, key, next_=None): self.key, self.next = key, next_ class HashSetLinkedList: def __init__(self): self.__head = ListNode(None) self.__tail = self.__head def __repr__(self): keys = [str(key) if type(key) != str else "'" + key + "'" for key in self] return "->" + " -> ".join(keys) def find(self, key): cur_node = self.__head.next while cur_node: if cur_node.key == key: return True cur_node = cur_node.next return False def insert(self, key): if not self.find(key): self.__tail.next = ListNode(key) self.__tail = self.__tail.next return 1 return 0 def delete(self, key): cur_node = self.__head while cur_node.next: if cur_node.next.key == key: cur_node.next = cur_node.next.next return cur_node = cur_node.next def __iter__(self): self._cur_node = self.__head.next return self def __next__(self): if not self._cur_node: raise StopIteration() key = self._cur_node.key self._cur_node = self._cur_node.next return key class HashSet: SCALE_FACTOR = 2 SHRINKAGE_THRESHOLD = 4 PRIME_NUMBER = (1 << 31) - 1 def __init__(self, capacity=16): self.__arr = [HashSetLinkedList() for _ in range(capacity)] self.__capacity = capacity self.__num_items = 0 self.__param1, self.__param2 = randint(0, self.PRIME_NUMBER - 1), randint( 0, self.PRIME_NUMBER - 1 ) def __repr__(self): return ( "{" + ", ".join( (str(key) if type(key) != str else "'" + key + "'") for linked_list in self.__arr for key in linked_list ) + "}" ) def __len__(self): return self.__num_items def _range_hash(self, prehashed_key): return (self.__param1 * prehashed_key + self.__param2) % self.__capacity def _resize(self, enlarge=True): if enlarge: self.__capacity *= self.SCALE_FACTOR else: self.__capacity //= self.SCALE_FACTOR new_arr = [HashSetLinkedList() for _ in range(self.__capacity)] for linked_list in self.__arr: for key in linked_list: new_idx = self._range_hash(hash(key)) new_arr[new_idx].insert(key) self.__arr = new_arr def add(self, key): idx = self._range_hash(hash(key)) self.__num_items += self.__arr[idx].insert(key) # Double the capacity. if self.__num_items == self.__capacity: self._resize(enlarge=True) def find(self, key): idx = self._range_hash(hash(key)) return self.__arr[idx].find(key) def __contains__(self, key): return self.find(key) def discard(self, key): idx = self._range_hash(hash(key)) self.__arr[idx].delete(key) self.__num_items -= 1 # Halve the capacity when #items is less than or equal to # the capacity / SHRINKAGE_THRESHOLD. if self.__num_items * self.SHRINKAGE_THRESHOLD <= self.__capacity: self._resize(enlarge=False) N = int(finput()) d_list = [int(finput()) for _ in range(N)] d_set = HashSet() for d in d_list: d_set.add(d) # d_set = set(d_list) print(len(d_set))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s264397381
Wrong Answer
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
moti_total = int(input()) moti = [] for n in range(moti_total): moti.append(int(input())) moti.sort() tower = 1 for n in range(moti_total - 1): if moti[n] is not moti[n + 1]: print("n " + str(moti[n]) + " n2 " + str(moti[n + 1])) tower += 1 print(tower)
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s512620072
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
n = int(input()) s = set() for i in range(n): s.add(int(input()) print(min(3,len(s)))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s275883386
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
n = int(input()) cake = [input() for i range(n)] print(len(set(cake)))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s918130478
Accepted
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
print(len(set([input() for i in range(int(input()))])))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s344131135
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
N = int(input()) A = sorted[input() for _ in range(N)] print(len(set(A)))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s152481947
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
n = int(input()) cake = input() for i range(n) print(len(set(cake)))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s162555935
Wrong Answer
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
print(len(set(input for i in range(int(input())))))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s305897843
Accepted
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
N = int(input()) d = [int(input()) for i in range(1, N + 1)] d = sorted(d) moti = 0 x = [] for i in d: if i > moti: x.append(i) moti = i print(len(x))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s047042277
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
n=int(input()) list=[input() for i in range(n)] a = [] for i in range(n): a.append(list.count(i)) print(len(set((a)))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s146841769
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
N = int(input()) M = list() for i in range(N): M.append(int(input()) M = list(set(M)) ans = len(M)
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s664863122
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
n = int(input()) m = [int(input()) for i in range(n)] mso = sorted(m) count = 0 for s in range(1,n): if mso[s] == mso[s-1] count += 1 print(n-count)
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s522813265
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
N= int(input()) d = list() for i in range(N): d.append(int(input()) d_set = set(d) d_list = list(d_set) d_list.sort() print(len(d_list))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s087639096
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
n = int(input()) num = {} for i in range(n): a = input() num[a]=True print(num.keys().count())
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s781760787
Wrong Answer
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
b = int(input()) nums = [int(input()) for i in range(b)] print(len(set(nums)) if not len(set(nums)) == 1 else "0")
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s921353164
Accepted
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
# Author: cr4zjh0bp # Created: Thu Mar 12 19:59:40 UTC 2020 import sys stdin = sys.stdin inf = 1 << 60 mod = 1000000007 ni = lambda: int(ns()) nin = lambda y: [ni() for _ in range(y)] na = lambda: list(map(int, stdin.readline().split())) nan = lambda y: [na() for _ in range(y)] nf = lambda: float(ns()) nfn = lambda y: [nf() for _ in range(y)] nfa = lambda: list(map(float, stdin.readline().split())) nfan = lambda y: [nfa() for _ in range(y)] ns = lambda: stdin.readline().rstrip() nsn = lambda y: [ns() for _ in range(y)] ncl = lambda y: [list(ns()) for _ in range(y)] nas = lambda: stdin.readline().split() N = ni() D = nin(N) D.sort() ans = 1 for i in range(N - 1): if D[i] < D[i + 1]: ans += 1 print(ans)
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s810603258
Accepted
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
n = int(input()) num_list = [int(input()) for i in range(n)] result_list = [] for num in num_list: if num not in result_list: result_list.append(num) print(len(result_list))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s890292567
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
import sys dList = list() for i, d in sys.stdin: if i <> 0: # 1行目の行数情報はいらないので読み飛ばす dList.append(d) print(len(set(dList)))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s518270650
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
a, b = map(int, input().split()) for s in range(b // 10000 + 1): try: for t in range(b // 5000 + 1): r = b - s - t if 10000 * s + 5000 * t + 1000 * r == b and s + t + r == a: print(s, t, r) exit() except ZeroDivisionError: continue print(-1, -1, -1)
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s276961915
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
#枚数 paper = int(input()) #餅リスト moti_list = [] li_uniq = [] #取得 for w in range(paper): paper = int(input()) moti_list.append(paper) print(len(moti_list))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s602721353
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
N = int(input()) l = list(map(int,input().split() for i in range(N)) l = set(l) print(len(l))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s210007189
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
n = int(input()) a = [] for i in range(n): x = int(input()) a.append(x) print(len(set(a))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s714254042
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
N = int(input()) list_d = [int(input()) for i int range(n)] print(len(set(lst)))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s191382302
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
times = int(input()) num = list(map(int,[input() for _ in range(times)])) print(len(set(num))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s361759908
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
N = input() d = [] for i in range(N): a.append(input()) print(len(list(set(li)))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s006050554
Wrong Answer
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
s = input() s = int(s) input_data = [int(input()) for _ in range(s)] print(len(list(input_data)))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s370768460
Accepted
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
rows = int(input()) x = [input() for i in range(rows)] print(len(set(x)))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s116030064
Accepted
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
print(len(set(input() for i in range(int(input())))))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s388021952
Wrong Answer
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
print(len(set(open(0).readlines()[1:])) - 1)
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s410176335
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
n=int(input()) d={input();1for i in range(n)} print(sum(d.values()))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s240367558
Wrong Answer
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
print(set([int(input()) for i in range(int(input()))]))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s413298119
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
print(len(set([int(input()) for _ in range(input())])))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s803397691
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
len(set([int(input()) for _ in range(input())]))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s863563134
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
N = int(input()) d = [input() for i in range(N)] print(len((set(d)))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s773247496
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
print(len(set(input() for i in range(int(input()))))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s696807867
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
n = int(input()) S = set([int(input()) for in range(n)]) print(len(S))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s155311983
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
N = input() d = [input() for i in range(N)] print(len(set(d))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s303832282
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
n = int(input()) print(len(set(int(input) for _ in range(n)))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s128421624
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
print(len(set(int(input()) for _ in range(int(input()))))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s488749496
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
A, B = input().split() print("YNeos"[int(A + B) ** 0.5 % 1 != 0 :: 2])
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s628617671
Runtime Error
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
n = input() S = set([int(input()) for in range(n)]) print(len(S))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s748564931
Accepted
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
print(len(set([int(input()) for i in range(int(input()))])))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s062481027
Accepted
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
times = int(input()) num = list(map(int, [input() for _ in range(times)])) print(len(set(num)))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s306313545
Accepted
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
a, *b = open(0) print(len(set(b)))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print the maximum number of layers in a kagami mochi that can be made. * * *
s604322139
Accepted
p03470
Input is given from Standard Input in the following format: N d_1 : d_N
print(len(sorted(set([int(input()) for _ in [0] * int(input())]))))
Statement An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
[{"input": "4\n 10\n 8\n 8\n 6", "output": "3\n \n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to\ntop in this order, we have a 3-layered kagami mochi, which is the maximum\nnumber of layers.\n\n* * *"}, {"input": "3\n 15\n 15\n 15", "output": "1\n \n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami\nmochi.\n\n* * *"}, {"input": "7\n 50\n 30\n 50\n 100\n 50\n 80\n 30", "output": "4"}]
Print one longest string that is a subsequence of both s and t. If there are multiple such strings, any of them will be accepted. * * *
s731828258
Accepted
p03165
Input is given from Standard Input in the following format: s t
# -*- coding: utf-8 -*- ############# # Libraries # ############# import sys input = sys.stdin.readline import math # from math import gcd import bisect import heapq from collections import defaultdict from collections import deque from collections import Counter from functools import lru_cache ############# # Constants # ############# MOD = 10**9 + 7 INF = float("inf") AZ = "abcdefghijklmnopqrstuvwxyz" ############# # Functions # ############# ######INPUT###### def I(): return int(input().strip()) def S(): return input().strip() def IL(): return list(map(int, input().split())) def SL(): return list(map(str, input().split())) def ILs(n): return list(int(input()) for _ in range(n)) def SLs(n): return list(input().strip() for _ in range(n)) def ILL(n): return [list(map(int, input().split())) for _ in range(n)] def SLL(n): return [list(map(str, input().split())) for _ in range(n)] ######OUTPUT###### def P(arg): print(arg) return def Y(): print("Yes") return def N(): print("No") return def E(): exit() def PE(arg): print(arg) exit() def YE(): print("Yes") exit() def NE(): print("No") exit() #####Shorten##### def DD(arg): return defaultdict(arg) #####Inverse##### def inv(n): return pow(n, MOD - 2, MOD) ######Combination###### kaijo_memo = [] def kaijo(n): if len(kaijo_memo) > n: return kaijo_memo[n] if len(kaijo_memo) == 0: kaijo_memo.append(1) while len(kaijo_memo) <= n: kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD) return kaijo_memo[n] gyaku_kaijo_memo = [] def gyaku_kaijo(n): if len(gyaku_kaijo_memo) > n: return gyaku_kaijo_memo[n] if len(gyaku_kaijo_memo) == 0: gyaku_kaijo_memo.append(1) while len(gyaku_kaijo_memo) <= n: gyaku_kaijo_memo.append( gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo), MOD - 2, MOD) % MOD ) return gyaku_kaijo_memo[n] def nCr(n, r): if n == r: return 1 if n < r or r < 0: return 0 ret = 1 ret = ret * kaijo(n) % MOD ret = ret * gyaku_kaijo(r) % MOD ret = ret * gyaku_kaijo(n - r) % MOD return ret ######Factorization###### def factorization(n): arr = [] temp = n for i in range(2, int(-(-(n**0.5) // 1)) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i arr.append([i, cnt]) if temp != 1: arr.append([temp, 1]) if arr == []: arr.append([n, 1]) return arr #####MakeDivisors###### def make_divisors(n): divisors = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n // i) return divisors #####MakePrimes###### def make_primes(N): max = int(math.sqrt(N)) seachList = [i for i in range(2, N + 1)] primeNum = [] while seachList[0] <= max: primeNum.append(seachList[0]) tmp = seachList[0] seachList = [i for i in seachList if i % tmp != 0] primeNum.extend(seachList) return primeNum #####GCD##### def gcd(a, b): while b: a, b = b, a % b return a #####LCM##### def lcm(a, b): return a * b // gcd(a, b) #####BitCount##### def count_bit(n): count = 0 while n: n &= n - 1 count += 1 return count #####ChangeBase##### def base_10_to_n(X, n): if X // n: return base_10_to_n(X // n, n) + [X % n] return [X % n] def base_n_to_10(X, n): return sum(int(str(X)[-i - 1]) * n**i for i in range(len(str(X)))) def base_10_to_n_without_0(X, n): X -= 1 if X // n: return base_10_to_n_without_0(X // n, n) + [X % n] return [X % n] #####IntLog##### def int_log(n, a): count = 0 while n >= a: n //= a count += 1 return count ############# # Main Code # ############# A = S() B = S() def lcs(S, T): L1 = len(S) L2 = len(T) dp = [[0] * (L2 + 1) for i in range(L1 + 1)] for i in range(L1 - 1, -1, -1): for j in range(L2 - 1, -1, -1): r = max(dp[i + 1][j], dp[i][j + 1]) if S[i] == T[j]: r = max(r, dp[i + 1][j + 1] + 1) dp[i][j] = r # return dp[0][0] # dp[0][0] が長さの解 # ここからは復元処理 res = [] i = 0 j = 0 while i < L1 and j < L2: if S[i] == T[j]: res.append(S[i]) i += 1 j += 1 elif dp[i][j] == dp[i + 1][j]: i += 1 elif dp[i][j] == dp[i][j + 1]: j += 1 return "".join(res) print(lcs(A, B))
Statement You are given strings s and t. Find one longest string that is a subsequence of both s and t.
[{"input": "axyb\n abyxb", "output": "axb\n \n\nThe answer is `axb` or `ayb`; either will be accepted.\n\n* * *"}, {"input": "aa\n xayaz", "output": "aa\n \n\n* * *"}, {"input": "a\n z", "output": "The answer is `` (an empty string).\n\n* * *"}, {"input": "abracadabra\n avadakedavra", "output": "aaadara"}]