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 maximum possible total value of the selected items. * * *
s867292839
Accepted
p03734
Input is given from Standard Input in the following format: N W w_1 v_1 w_2 v_2 : w_N v_N
from sys import stdin, setrecursionlimit n, w = [int(x) for x in stdin.readline().rstrip().split()] li = [list(map(int, stdin.readline().rstrip().split())) for _ in range(n)] jw = li[0][0] omosa = [[] for _ in range(4)] for i in li: omosa[i[0] - jw].append(i[1]) for i in range(len(omosa)): omosa[i].sort(reverse=True) saidai = n ma = 0 for i in range(len(omosa[0]) + 1): for j in range(len(omosa[1]) + 1): for k in range(len(omosa[2]) + 1): for l in range(len(omosa[3]) + 1): to_ka = omosa[0][:i] + omosa[1][:j] + omosa[2][:k] + omosa[3][:l] if i * jw + j * (jw + 1) + k * (jw + 2) + l * (jw + 3) > w: continue ma = max(ma, sum(to_ka)) print(ma)
Statement You have N items and a bag of strength W. The i-th item has a weight of w_i and a value of v_i. You will select some of the items and put them in the bag. Here, the total weight of the selected items needs to be at most W. Your objective is to maximize the total value of the selected items.
[{"input": "4 6\n 2 1\n 3 4\n 4 10\n 3 4", "output": "11\n \n\nThe first and third items should be selected.\n\n* * *"}, {"input": "4 6\n 2 1\n 3 7\n 4 10\n 3 6", "output": "13\n \n\nThe second and fourth items should be selected.\n\n* * *"}, {"input": "4 10\n 1 100\n 1 100\n 1 100\n 1 100", "output": "400\n \n\nYou can take everything.\n\n* * *"}, {"input": "4 1\n 10 100\n 10 100\n 10 100\n 10 100", "output": "0\n \n\nYou can take nothing."}]
Print the maximum possible total value of the selected items. * * *
s996355539
Wrong Answer
p03734
Input is given from Standard Input in the following format: N W w_1 v_1 w_2 v_2 : w_N v_N
# 誤答(たくさん取れる) # 12:11 n, u = map(int, input().split()) w0, v0 = map(int, input().split()) vn = [v0, 0, 0, 0] wn = [w0, w0 + 1, w0 + 2, w0 + 3] for _ in range(n - 1): w, v = map(int, input().split()) vn[w - w0] = max(vn[w - w0], v) # print(wn) # print(vn) can = [] from itertools import permutations as perm for per in perm(range(4)): # print(per) utmp = int(u) vtmp = vn[:] wtmp = wn[:] now = 0 for d in range(4): wtmpd = wtmp[d] tmp = utmp // wtmpd vtmpd = vtmp[per[d]] if vtmpd <= 0 or wtmpd == 0: continue now += tmp * vtmpd utmp -= tmp * wtmpd # print(tmp,d) for di in range(4): if wtmp[di] >= wtmpd: vtmp[di] -= vtmpd wtmp[di] -= wtmpd # print(now) can.append(now) print(max(can))
Statement You have N items and a bag of strength W. The i-th item has a weight of w_i and a value of v_i. You will select some of the items and put them in the bag. Here, the total weight of the selected items needs to be at most W. Your objective is to maximize the total value of the selected items.
[{"input": "4 6\n 2 1\n 3 4\n 4 10\n 3 4", "output": "11\n \n\nThe first and third items should be selected.\n\n* * *"}, {"input": "4 6\n 2 1\n 3 7\n 4 10\n 3 6", "output": "13\n \n\nThe second and fourth items should be selected.\n\n* * *"}, {"input": "4 10\n 1 100\n 1 100\n 1 100\n 1 100", "output": "400\n \n\nYou can take everything.\n\n* * *"}, {"input": "4 1\n 10 100\n 10 100\n 10 100\n 10 100", "output": "0\n \n\nYou can take nothing."}]
Print the maximum possible total value of the selected items. * * *
s279767174
Runtime Error
p03734
Input is given from Standard Input in the following format: N W w_1 v_1 w_2 v_2 : w_N v_N
N, W = (int(i) for i in input().split()) w = [0]*N v = [0]*N for i in range(N): w[i], v[i] = (int(j) for j in input().split()) w0 = w[0] wh = [a - w0 for a in w] dp = [[[-1]*(N+1) for i in range(3*N+1)] for j in range(N+1)] dp[0][0][0] = 0 for i in range(N): for j in range(3*N+1): for k in range(N+1): if dp[i][j][k] != -1: dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j][k]) if j - wh[i] >=0 and k-1 >=0 and dp[i][j-wh[i]][k-1] != -1: dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j-wh[i]][k-1]+v[i]) res = 0 for j in range(3*N+1): for k in range(N+1) if j + w0*k <= W: res = max(dp[N][j][k], res) print(res)
Statement You have N items and a bag of strength W. The i-th item has a weight of w_i and a value of v_i. You will select some of the items and put them in the bag. Here, the total weight of the selected items needs to be at most W. Your objective is to maximize the total value of the selected items.
[{"input": "4 6\n 2 1\n 3 4\n 4 10\n 3 4", "output": "11\n \n\nThe first and third items should be selected.\n\n* * *"}, {"input": "4 6\n 2 1\n 3 7\n 4 10\n 3 6", "output": "13\n \n\nThe second and fourth items should be selected.\n\n* * *"}, {"input": "4 10\n 1 100\n 1 100\n 1 100\n 1 100", "output": "400\n \n\nYou can take everything.\n\n* * *"}, {"input": "4 1\n 10 100\n 10 100\n 10 100\n 10 100", "output": "0\n \n\nYou can take nothing."}]
Print the maximum possible total value of the selected items. * * *
s880140714
Wrong Answer
p03734
Input is given from Standard Input in the following format: N W w_1 v_1 w_2 v_2 : w_N v_N
a = list(map(int, input().split())) N, W = a[0], a[1] tup = zip(a[2::2], a[3::2]) dic = {} for val in tup: if val[0] in dic.keys(): if val[1] >= dic[val[1]]: dic.update({val[0]: val[1]}) else: dic.update({val[0]: val[1]}) v = 0 i = 0 for i in range(len(dic.keys())): for element in itertools.combinations(dic.keys(), i): if sum(element) <= W: sm = sum(map(lambda x: dic[x], element)) i = max(i, sm)
Statement You have N items and a bag of strength W. The i-th item has a weight of w_i and a value of v_i. You will select some of the items and put them in the bag. Here, the total weight of the selected items needs to be at most W. Your objective is to maximize the total value of the selected items.
[{"input": "4 6\n 2 1\n 3 4\n 4 10\n 3 4", "output": "11\n \n\nThe first and third items should be selected.\n\n* * *"}, {"input": "4 6\n 2 1\n 3 7\n 4 10\n 3 6", "output": "13\n \n\nThe second and fourth items should be selected.\n\n* * *"}, {"input": "4 10\n 1 100\n 1 100\n 1 100\n 1 100", "output": "400\n \n\nYou can take everything.\n\n* * *"}, {"input": "4 1\n 10 100\n 10 100\n 10 100\n 10 100", "output": "0\n \n\nYou can take nothing."}]
Print the maximum possible total value of the selected items. * * *
s195383836
Runtime Error
p03734
Input is given from Standard Input in the following format: N W w_1 v_1 w_2 v_2 : w_N v_N
N, W = (int(i) for i in input().split()) w = [0]*N w0 = w[0] wh = [a - w0 for a in W] v = [0]*N for i in range(N): w[i], v[i] = (int(i) for i in input().split()) dp = [[[0]*(N+1) for i in range(3N+1)] for j in range(N+1)] for i in range(N): for j in range(3N+1): for k in range(N+1): dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j][k]) if j - wh[i] >=0 and k-1 >=0: dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j-wh[i]][k-1]+v[i]) res = 0 for k in range(N+1): if w0*k <= W <= (w0+3)*k: Wk = W - w0*k ans = 0 for j in range(Wk+1): ans = max(dp[N][j][k], ans) res = max(res, ans) print(res)
Statement You have N items and a bag of strength W. The i-th item has a weight of w_i and a value of v_i. You will select some of the items and put them in the bag. Here, the total weight of the selected items needs to be at most W. Your objective is to maximize the total value of the selected items.
[{"input": "4 6\n 2 1\n 3 4\n 4 10\n 3 4", "output": "11\n \n\nThe first and third items should be selected.\n\n* * *"}, {"input": "4 6\n 2 1\n 3 7\n 4 10\n 3 6", "output": "13\n \n\nThe second and fourth items should be selected.\n\n* * *"}, {"input": "4 10\n 1 100\n 1 100\n 1 100\n 1 100", "output": "400\n \n\nYou can take everything.\n\n* * *"}, {"input": "4 1\n 10 100\n 10 100\n 10 100\n 10 100", "output": "0\n \n\nYou can take nothing."}]
Print the maximum possible total value of the selected items. * * *
s068109093
Accepted
p03734
Input is given from Standard Input in the following format: N W w_1 v_1 w_2 v_2 : w_N v_N
from itertools import accumulate, product # 入力 N, W = map(int, input().split()) w, v = zip(*(map(int, input().split()) for _ in range(N))) if N else ((), ()) # 各重さの物のリスト(価値について降順) u = [ [0] + list(accumulate(sorted((y for x, y in zip(w, v) if x == i), reverse=True))) for i in range(w[0], w[0] + 4) ] # 重さが w_1, w_1 + 1, w_1 + 2 の物をa, b, c 個選んだとき、 # 重さが w_1 + 3 の物の選び方は一意に定まることを用いて最適値を求める ans = max( sum(u[i][k] for i, k in enumerate(t)) + u[3][ min( len(u[3]) - 1, (W - sum(k * (w[0] + i) for i, k in enumerate(t))) // (w[0] + 3), ) ] for t in product(*map(range, map(len, u[:3]))) if sum(k * (w[0] + i) for i, k in enumerate(t)) <= W ) # 出力 print(ans)
Statement You have N items and a bag of strength W. The i-th item has a weight of w_i and a value of v_i. You will select some of the items and put them in the bag. Here, the total weight of the selected items needs to be at most W. Your objective is to maximize the total value of the selected items.
[{"input": "4 6\n 2 1\n 3 4\n 4 10\n 3 4", "output": "11\n \n\nThe first and third items should be selected.\n\n* * *"}, {"input": "4 6\n 2 1\n 3 7\n 4 10\n 3 6", "output": "13\n \n\nThe second and fourth items should be selected.\n\n* * *"}, {"input": "4 10\n 1 100\n 1 100\n 1 100\n 1 100", "output": "400\n \n\nYou can take everything.\n\n* * *"}, {"input": "4 1\n 10 100\n 10 100\n 10 100\n 10 100", "output": "0\n \n\nYou can take nothing."}]
Print the maximum possible total value of the selected items. * * *
s331772730
Accepted
p03734
Input is given from Standard Input in the following format: N W w_1 v_1 w_2 v_2 : w_N v_N
import math # import sys # input = sys.stdin.readline 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) # divisors.sort() return divisors def ValueToBits(x, digit): res = [0 for i in range(digit)] now = x for i in range(digit): res[i] = now % 2 now = now >> 1 return res def BitsToValue(arr): n = len(arr) ans = 0 for i in range(n): ans += arr[i] * 2**i return ans def ZipArray(a): aa = [[a[i], i] for i in range(n)] aa.sort(key=lambda x: x[0]) for i in range(n): aa[i][0] = i + 1 aa.sort(key=lambda x: x[1]) b = [aa[i][0] for i in range(len(a))] return b def ValueToArray10(x, digit): ans = [0 for i in range(digit)] now = x for i in range(digit): ans[digit - i - 1] = now % 10 now = now // 10 return ans def Zeros(a, b): if b <= -1: return [0 for i in range(a)] else: return [[0 for i in range(b)] for i in range(a)] def AddV2(v, w): return [v[0] + w[0], v[1] + w[1]] dir4 = [[1, 0], [0, 1], [-1, 0], [0, -1]] def clamp(x, y, z): return max(y, min(z, x)) class Bit: def __init__(self, n): self.size = n self.tree = [0] * (n + 1) def sum(self, i): s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def add(self, i, x): while i <= self.size: self.tree[i] += x i += i & -i # def Zaatsu(a): a.sort() now = a[0][0] od = 0 for i in range(n): if now == a[i][0]: a[i][0] = od else: now = a[i][0] od += 1 a[i][0] = od a.sort(key=lambda x: x[1]) return a class UnionFind: def __init__(self, n): self.par = [i for i in range(n + 1)] self.rank = [0] * (n + 1) # 検索 def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] # 併合 def union(self, x, y): x = self.find(x) y = self.find(y) if self.rank[x] < self.rank[y]: self.par[x] = y else: self.par[y] = x if self.rank[x] == self.rank[y]: self.rank[x] += 1 # 同じ集合に属するか判定 def same_check(self, x, y): return self.find(x) == self.find(y) """ def cmb(n, r, p): if (r < 0) or (n < r): return 0 r = min(r, n - r) return fact[n] * factinv[r] * factinv[n-r] % p p = 2 N = 10 ** 6 + 2 fact = [1, 1] # fact[n] = (n! mod p) factinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p) inv = [0, 1] # factinv 計算用 for i in range(2, N + 1): fact.append((fact[-1] * i) % p) inv.append((-inv[p % i] * (p // i)) % p) factinv.append((factinv[-1] * inv[-1]) % p) """ def rl(x): return range(len(x)) # a = list(map(int, input().split())) ################################################# ################################################# ################################################# ################################################# # 22- n, w = list(map(int, input().split())) item = [[] for i in range(4)] ww = 0 for i in range(n): temp = list(map(int, input().split())) if i == 0: ww = temp[0] item[temp[0] - ww].append(temp[1]) for i in range(4): item[i].sort() item[i].reverse() # print(item) ans = 0 sums = [[0], [0], [0], [0]] for i in range(4): for j in rl(item[i]): sums[i].append(sums[i][-1] + item[i][j]) # print(sums) for i1 in range(len(item[0]) + 1): for i2 in range(len(item[1]) + 1): for i3 in range(len(item[2]) + 1): for i4 in range(len(item[3]) + 1): wei = (i1 + i2 + i3 + i4) * ww + i2 + i3 * 2 + i4 * 3 if wei <= w: val = sums[0][i1] + sums[1][i2] + sums[2][i3] + sums[3][i4] ans = max(ans, val) print(ans)
Statement You have N items and a bag of strength W. The i-th item has a weight of w_i and a value of v_i. You will select some of the items and put them in the bag. Here, the total weight of the selected items needs to be at most W. Your objective is to maximize the total value of the selected items.
[{"input": "4 6\n 2 1\n 3 4\n 4 10\n 3 4", "output": "11\n \n\nThe first and third items should be selected.\n\n* * *"}, {"input": "4 6\n 2 1\n 3 7\n 4 10\n 3 6", "output": "13\n \n\nThe second and fourth items should be selected.\n\n* * *"}, {"input": "4 10\n 1 100\n 1 100\n 1 100\n 1 100", "output": "400\n \n\nYou can take everything.\n\n* * *"}, {"input": "4 1\n 10 100\n 10 100\n 10 100\n 10 100", "output": "0\n \n\nYou can take nothing."}]
Print the maximum possible total value of the selected items. * * *
s758210456
Wrong Answer
p03734
Input is given from Standard Input in the following format: N W w_1 v_1 w_2 v_2 : w_N v_N
N, W = map(int, input().split()) WV = [list(map(int, input().split())) for _ in range(N)] Wdic = {} for w in WV: if w[0] not in Wdic: Wdic[w[0]] = [w] else: Wdic[w[0]].append(w) Wcount = [[0 for _ in range(2)] for _ in range(4)] idx = 0 for k in Wdic.keys(): Wcount[idx] = [k, len(Wdic[k])] idx += 1 # print(Wcount) Wsum = {} for k, v in Wdic.items(): v.sort(key=lambda x: x[1], reverse=True) Wsum[k] = [v[0][1]] for i in range(1, len(v)): Wsum[k].append(Wsum[k][-1] + v[i][1]) # print(Wsum) def check(i, j, k, l): ret = 0 w = 0 if i > 0 and Wcount[0][0] > 0: ret += Wsum[Wcount[0][0]][i - 1] w += Wcount[0][0] * i if j > 0 and Wcount[1][0] > 0: ret += Wsum[Wcount[1][0]][j - 1] w += Wcount[1][0] * j if k > 0 and Wcount[2][0] > 0: ret += Wsum[Wcount[2][0]][k - 1] w += Wcount[2][0] * j if l > 0 and Wcount[3][0] > 0: ret += Wsum[Wcount[3][0]][l - 1] w += Wcount[3][0] * l if w > W: ret = 0 return ret value = 0 for i in range(Wcount[0][1] + 1): for j in range(Wcount[1][1] + 1): for k in range(Wcount[2][1] + 1): for l in range(Wcount[3][1] + 1): value = max(value, check(i, j, k, l)) print(value)
Statement You have N items and a bag of strength W. The i-th item has a weight of w_i and a value of v_i. You will select some of the items and put them in the bag. Here, the total weight of the selected items needs to be at most W. Your objective is to maximize the total value of the selected items.
[{"input": "4 6\n 2 1\n 3 4\n 4 10\n 3 4", "output": "11\n \n\nThe first and third items should be selected.\n\n* * *"}, {"input": "4 6\n 2 1\n 3 7\n 4 10\n 3 6", "output": "13\n \n\nThe second and fourth items should be selected.\n\n* * *"}, {"input": "4 10\n 1 100\n 1 100\n 1 100\n 1 100", "output": "400\n \n\nYou can take everything.\n\n* * *"}, {"input": "4 1\n 10 100\n 10 100\n 10 100\n 10 100", "output": "0\n \n\nYou can take nothing."}]
Print the maximum possible total value of the selected items. * * *
s055542037
Wrong Answer
p03734
Input is given from Standard Input in the following format: N W w_1 v_1 w_2 v_2 : w_N v_N
ins = input().split(" ") N = int(ins[0]) Wmax = int(ins[1]) A = [[0, 0]] B = [[0, 0]] C = [[0, 0]] D = [[0, 0]] thing = input().split(" ") A.append([int(thing[0]), int(thing[1])]) for i in range(1, N): thing = input().split(" ") w = int(thing[0]) v = int(thing[1]) if w == A[1][0]: A.append([w, v]) elif w == A[1][0] + 1: B.append([w, v]) elif w == A[1][0] + 2: C.append([w, v]) else: D.append([w, v]) A.sort(key=lambda x: x[1]) B.sort(key=lambda x: x[1]) C.sort(key=lambda x: x[1]) D.sort(key=lambda x: x[1]) sumA = [[0, 0]] sumB = [[0, 0]] sumC = [[0, 0]] sumD = [[0, 0]] for i in range(1, len(A)): sumA.append([sumA[i - 1][0] + A[i][0], sumA[i - 1][1] + A[i][1]]) for i in range(1, len(B)): sumB.append([sumB[i - 1][0] + B[i][0], sumB[i - 1][1] + B[i][1]]) for i in range(1, len(C)): sumC.append([sumC[i - 1][0] + C[i][0], sumC[i - 1][1] + C[i][1]]) for i in range(1, len(D)): sumD.append([sumD[i - 1][0] + D[i][0], sumD[i - 1][1] + D[i][1]]) sumv = 0 ans = 0 for i in range(0, len(A)): for j in range(0, len(B)): for k in range(0, len(C)): for l in range(0, len(D)): sumw = sumA[i][0] + sumB[j][0] + sumC[k][0] + sumD[l][0] if sumw <= Wmax: ans = max(ans, sumA[i][1] + sumB[j][1] + sumC[k][1] + sumD[l][1]) print(ans)
Statement You have N items and a bag of strength W. The i-th item has a weight of w_i and a value of v_i. You will select some of the items and put them in the bag. Here, the total weight of the selected items needs to be at most W. Your objective is to maximize the total value of the selected items.
[{"input": "4 6\n 2 1\n 3 4\n 4 10\n 3 4", "output": "11\n \n\nThe first and third items should be selected.\n\n* * *"}, {"input": "4 6\n 2 1\n 3 7\n 4 10\n 3 6", "output": "13\n \n\nThe second and fourth items should be selected.\n\n* * *"}, {"input": "4 10\n 1 100\n 1 100\n 1 100\n 1 100", "output": "400\n \n\nYou can take everything.\n\n* * *"}, {"input": "4 1\n 10 100\n 10 100\n 10 100\n 10 100", "output": "0\n \n\nYou can take nothing."}]
Print the maximum possible total value of the selected items. * * *
s494026720
Accepted
p03734
Input is given from Standard Input in the following format: N W w_1 v_1 w_2 v_2 : w_N v_N
import sys sys.setrecursionlimit(10**7) input = sys.stdin.readline f_inf = float("inf") mod = 10**9 + 7 def resolve(): N, W = map(int, input().split()) V = [[0] for _ in range(4)] for i in range(N): w, v = map(int, input().split()) if i == 0: init = w V[w - init].append(v) for i in range(4): V[i].sort(reverse=True) res = 0 for i in range(len(V[0]) + 1): a = sum(V[0][:i]) for j in range(len(V[1]) + 1): b = sum(V[1][:j]) for k in range(len(V[2]) + 1): c = sum(V[2][:k]) for l in range(len(V[3]) + 1): d = sum(V[3][:l]) total_w = ( init * i + (init + 1) * j + (init + 2) * k + (init + 3) * l ) if total_w <= W: res = max(res, a + b + c + d) print(res) if __name__ == "__main__": resolve()
Statement You have N items and a bag of strength W. The i-th item has a weight of w_i and a value of v_i. You will select some of the items and put them in the bag. Here, the total weight of the selected items needs to be at most W. Your objective is to maximize the total value of the selected items.
[{"input": "4 6\n 2 1\n 3 4\n 4 10\n 3 4", "output": "11\n \n\nThe first and third items should be selected.\n\n* * *"}, {"input": "4 6\n 2 1\n 3 7\n 4 10\n 3 6", "output": "13\n \n\nThe second and fourth items should be selected.\n\n* * *"}, {"input": "4 10\n 1 100\n 1 100\n 1 100\n 1 100", "output": "400\n \n\nYou can take everything.\n\n* * *"}, {"input": "4 1\n 10 100\n 10 100\n 10 100\n 10 100", "output": "0\n \n\nYou can take nothing."}]
Print the number of ways to assign scores to the problems, modulo M. * * *
s112354850
Wrong Answer
p02826
Input is given from Standard Input in the following format: N M
def main(): n, m = map(int, input().split()) from itertools import accumulate dp = [[0] * (n + 1)] * n # print(dp) dp[0][-n] = 1 for i in range(n - 1): dp[i] = list(accumulate(dp[i])) for j in range(1, n + 1): dp[i + 1][j] = dp[i][j] cnt = 0 for i in range(n): cnt += dp[i][-1] cnt %= m print(cnt) if __name__ == "__main__": main()
Statement N problems have been chosen by the judges, now it's time to assign scores to them! Problem i must get an integer score A_i between 1 and N, inclusive. The problems have already been sorted by difficulty: A_1 \le A_2 \le \ldots \le A_N must hold. Different problems can have the same score, though. Being an ICPC fan, you want contestants who solve more problems to be ranked higher. That's why, for any k (1 \le k \le N-1), you want the sum of scores of any k problems to be strictly less than the sum of scores of any k+1 problems. How many ways to assign scores do you have? Find this number modulo the given prime M.
[{"input": "2 998244353", "output": "3\n \n\nThe possible assignments are (1, 1), (1, 2), (2, 2).\n\n* * *"}, {"input": "3 998244353", "output": "7\n \n\nThe possible assignments are (1, 1, 1), (1, 2, 2), (1, 3, 3), (2, 2, 2), (2,\n2, 3), (2, 3, 3), (3, 3, 3).\n\n* * *"}, {"input": "6 966666661", "output": "66\n \n\n* * *"}, {"input": "96 925309799", "output": "83779"}]
Print the number of ways to assign scores to the problems, modulo M. * * *
s593121485
Wrong Answer
p02826
Input is given from Standard Input in the following format: N M
N, M = map(int, input().split()) ans = 0 for a in range(1, N + 1): for b in range(a, N + 1): ans = ans + ((min(N, a + b - 1) - b + 1) ** (N - 2)) % M print(ans)
Statement N problems have been chosen by the judges, now it's time to assign scores to them! Problem i must get an integer score A_i between 1 and N, inclusive. The problems have already been sorted by difficulty: A_1 \le A_2 \le \ldots \le A_N must hold. Different problems can have the same score, though. Being an ICPC fan, you want contestants who solve more problems to be ranked higher. That's why, for any k (1 \le k \le N-1), you want the sum of scores of any k problems to be strictly less than the sum of scores of any k+1 problems. How many ways to assign scores do you have? Find this number modulo the given prime M.
[{"input": "2 998244353", "output": "3\n \n\nThe possible assignments are (1, 1), (1, 2), (2, 2).\n\n* * *"}, {"input": "3 998244353", "output": "7\n \n\nThe possible assignments are (1, 1, 1), (1, 2, 2), (1, 3, 3), (2, 2, 2), (2,\n2, 3), (2, 3, 3), (3, 3, 3).\n\n* * *"}, {"input": "6 966666661", "output": "66\n \n\n* * *"}, {"input": "96 925309799", "output": "83779"}]
Print the number of ways to assign scores to the problems, modulo M. * * *
s309337926
Wrong Answer
p02826
Input is given from Standard Input in the following format: N M
import numpy as np n, m = map(int, input().split()) coef = np.minimum(np.arange(n, 1, -1), np.arange(1, n)) dp = np.zeros(n, dtype=np.int64) dp[0] = 1 for c in coef: ndp = dp.copy() for i in range(0, n, c): ndp[i:] += dp[: n - i] dp = ndp % m # 更新する print((dp * np.arange(n, 0, -1) % m).sum() % m)
Statement N problems have been chosen by the judges, now it's time to assign scores to them! Problem i must get an integer score A_i between 1 and N, inclusive. The problems have already been sorted by difficulty: A_1 \le A_2 \le \ldots \le A_N must hold. Different problems can have the same score, though. Being an ICPC fan, you want contestants who solve more problems to be ranked higher. That's why, for any k (1 \le k \le N-1), you want the sum of scores of any k problems to be strictly less than the sum of scores of any k+1 problems. How many ways to assign scores do you have? Find this number modulo the given prime M.
[{"input": "2 998244353", "output": "3\n \n\nThe possible assignments are (1, 1), (1, 2), (2, 2).\n\n* * *"}, {"input": "3 998244353", "output": "7\n \n\nThe possible assignments are (1, 1, 1), (1, 2, 2), (1, 3, 3), (2, 2, 2), (2,\n2, 3), (2, 3, 3), (3, 3, 3).\n\n* * *"}, {"input": "6 966666661", "output": "66\n \n\n* * *"}, {"input": "96 925309799", "output": "83779"}]
Print the number of ways to assign scores to the problems, modulo M. * * *
s416543953
Runtime Error
p02826
Input is given from Standard Input in the following format: N M
n, m = map(int, input().split()) n_l = [i for i in range(1, n + 1)] ans = 0 import itertools l1 = list(itertools.combinations(n_l)) for i in range(len(l1)): for j in range(2**n): l2 = [0] * n for k in range(n // 2): if (j >> k) & 1: l2[k] = 1 flag = True cnt1 = 0 cnt2 = 0 for l in range(n): if l2[l]: cnt1 += l1[l] else: cnt2 += l1[l] if cnt2 > cnt1: ans += 1 print(ans)
Statement N problems have been chosen by the judges, now it's time to assign scores to them! Problem i must get an integer score A_i between 1 and N, inclusive. The problems have already been sorted by difficulty: A_1 \le A_2 \le \ldots \le A_N must hold. Different problems can have the same score, though. Being an ICPC fan, you want contestants who solve more problems to be ranked higher. That's why, for any k (1 \le k \le N-1), you want the sum of scores of any k problems to be strictly less than the sum of scores of any k+1 problems. How many ways to assign scores do you have? Find this number modulo the given prime M.
[{"input": "2 998244353", "output": "3\n \n\nThe possible assignments are (1, 1), (1, 2), (2, 2).\n\n* * *"}, {"input": "3 998244353", "output": "7\n \n\nThe possible assignments are (1, 1, 1), (1, 2, 2), (1, 3, 3), (2, 2, 2), (2,\n2, 3), (2, 3, 3), (3, 3, 3).\n\n* * *"}, {"input": "6 966666661", "output": "66\n \n\n* * *"}, {"input": "96 925309799", "output": "83779"}]
Print the number of ways to assign scores to the problems, modulo M. * * *
s370100721
Runtime Error
p02826
Input is given from Standard Input in the following format: N M
n, a, b = map(int, input().split()) c = abs(a - b) if c % 2 == 0: print(int(c / 2)) else: d = (a + b + 1) / 2 e = (2 * n + 2 - a - b + 1) / 2 f = min(d, e) print(int(f))
Statement N problems have been chosen by the judges, now it's time to assign scores to them! Problem i must get an integer score A_i between 1 and N, inclusive. The problems have already been sorted by difficulty: A_1 \le A_2 \le \ldots \le A_N must hold. Different problems can have the same score, though. Being an ICPC fan, you want contestants who solve more problems to be ranked higher. That's why, for any k (1 \le k \le N-1), you want the sum of scores of any k problems to be strictly less than the sum of scores of any k+1 problems. How many ways to assign scores do you have? Find this number modulo the given prime M.
[{"input": "2 998244353", "output": "3\n \n\nThe possible assignments are (1, 1), (1, 2), (2, 2).\n\n* * *"}, {"input": "3 998244353", "output": "7\n \n\nThe possible assignments are (1, 1, 1), (1, 2, 2), (1, 3, 3), (2, 2, 2), (2,\n2, 3), (2, 3, 3), (3, 3, 3).\n\n* * *"}, {"input": "6 966666661", "output": "66\n \n\n* * *"}, {"input": "96 925309799", "output": "83779"}]
Print the number of ways to assign scores to the problems, modulo M. * * *
s657559326
Wrong Answer
p02826
Input is given from Standard Input in the following format: N M
def factorial(n): M = 1000000007 f = 1 for i in range(1, n + 1): f = f * i return f % M
Statement N problems have been chosen by the judges, now it's time to assign scores to them! Problem i must get an integer score A_i between 1 and N, inclusive. The problems have already been sorted by difficulty: A_1 \le A_2 \le \ldots \le A_N must hold. Different problems can have the same score, though. Being an ICPC fan, you want contestants who solve more problems to be ranked higher. That's why, for any k (1 \le k \le N-1), you want the sum of scores of any k problems to be strictly less than the sum of scores of any k+1 problems. How many ways to assign scores do you have? Find this number modulo the given prime M.
[{"input": "2 998244353", "output": "3\n \n\nThe possible assignments are (1, 1), (1, 2), (2, 2).\n\n* * *"}, {"input": "3 998244353", "output": "7\n \n\nThe possible assignments are (1, 1, 1), (1, 2, 2), (1, 3, 3), (2, 2, 2), (2,\n2, 3), (2, 3, 3), (3, 3, 3).\n\n* * *"}, {"input": "6 966666661", "output": "66\n \n\n* * *"}, {"input": "96 925309799", "output": "83779"}]
Print H lines. The i-th line should contain the answer for the case k=i. * * *
s476069978
Accepted
p02575
Input is given from Standard Input in the following format: H W A_1 B_1 A_2 B_2 : A_H B_H
import sys readline = sys.stdin.readline class Lazysegtree: def __init__(self, A, fx, ex, fm, em, fa, initialize=True): # fa(operator, idx)の形にしている、data[idx]の長さに依存する場合などのため self.N = len(A) self.N0 = 2 ** (self.N - 1).bit_length() self.dep = (self.N - 1).bit_length() self.fx = fx """ self.fa = self.fm = fm """ self.ex = ex self.em = em self.lazy = [em] * (2 * self.N0) if initialize: self.data = [self.ex] * self.N0 + A + [self.ex] * (self.N0 - self.N) for i in range(self.N0 - 1, -1, -1): self.data[i] = self.fx(self.data[2 * i], self.data[2 * i + 1]) else: self.data = [self.ex] * (2 * self.N0) def fa(self, ope, idx): if ope[0]: k = idx.bit_length() return (idx - (1 << (k - 1))) * (1 << (self.dep + 1 - k)) + ope[1] return self.data[idx] def fm(self, x, y): if x[0] == 1: return x else: return y def __repr__(self): s = "data" l = "lazy" cnt = 1 for i in range(self.N0.bit_length()): s = "\n".join((s, " ".join(map(str, self.data[cnt : cnt + (1 << i)])))) l = "\n".join((l, " ".join(map(str, self.lazy[cnt : cnt + (1 << i)])))) cnt += 1 << i return "\n".join((s, l)) def _ascend(self, k): k = k >> 1 c = k.bit_length() for j in range(c): idx = k >> j self.data[idx] = self.fx(self.data[2 * idx], self.data[2 * idx + 1]) def _descend(self, k): k = k >> 1 idx = 1 c = k.bit_length() for j in range(1, c + 1): idx = k >> (c - j) if self.lazy[idx] == self.em: continue self.data[2 * idx] = self.fa(self.lazy[idx], 2 * idx) self.data[2 * idx + 1] = self.fa(self.lazy[idx], 2 * idx + 1) self.lazy[2 * idx] = self.fm(self.lazy[idx], self.lazy[2 * idx]) self.lazy[2 * idx + 1] = self.fm(self.lazy[idx], self.lazy[2 * idx + 1]) self.lazy[idx] = self.em def query(self, l, r): L = l + self.N0 R = r + self.N0 self._descend(L // (L & -L)) self._descend(R // (R & -R) - 1) sl = self.ex sr = self.ex while L < R: if R & 1: R -= 1 sr = self.fx(self.data[R], sr) if L & 1: sl = self.fx(sl, self.data[L]) L += 1 L >>= 1 R >>= 1 return self.fx(sl, sr) def operate(self, l, r, x): L = l + self.N0 R = r + self.N0 Li = L // (L & -L) Ri = R // (R & -R) self._descend(Li) self._descend(Ri - 1) while L < R: if R & 1: R -= 1 self.data[R] = self.fa(x, R) self.lazy[R] = self.fm(x, self.lazy[R]) if L & 1: self.data[L] = self.fa(x, L) self.lazy[L] = self.fm(x, self.lazy[L]) L += 1 L >>= 1 R >>= 1 self._ascend(Li) self._ascend(Ri - 1) INF = 10**18 + 3 H, W = map(int, readline().split()) T = Lazysegtree([0] * W, min, INF, None, (0, 0), None, initialize=True) N0 = T.N0 Ans = [None] * H for qu in range(H): a, b = map(int, readline().split()) a -= 1 if a == 0: T.operate(a, b, (1, INF)) else: x = T.query(a - 1, a) T.operate(a, b, (1, x - a + 1)) ans = T.query(0, N0) + qu + 1 if ans >= INF: ans = -1 Ans[qu] = ans print("\n".join(map(str, Ans)))
Statement There is a grid of squares with H+1 horizontal rows and W vertical columns. You will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer i from 1 through H, you cannot move down from the A_i-th, (A_i + 1)-th, \ldots, B_i-th squares from the left in the i-th row from the top. For each integer k from 1 through H, find the minimum number of moves needed to reach one of the squares in the (k+1)-th row from the top. (The starting square can be chosen individually for each case.) If, starting from any square in the top row, none of the squares in the (k+1)-th row can be reached, print `-1` instead.
[{"input": "4 4\n 2 4\n 1 1\n 2 3\n 2 4", "output": "1\n 3\n 6\n -1\n \n\nLet (i,j) denote the square at the i-th row from the top and j-th column from\nthe left.\n\nFor k=1, we need one move such as (1,1) \u2192 (2,1).\n\nFor k=2, we need three moves such as (1,1) \u2192 (2,1) \u2192 (2,2) \u2192 (3,2).\n\nFor k=3, we need six moves such as (1,1) \u2192 (2,1) \u2192 (2,2) \u2192 (3,2) \u2192 (3,3) \u2192\n(3,4) \u2192 (4,4).\n\nFor k=4, it is impossible to reach any square in the fifth row from the top."}]
Print H lines. The i-th line should contain the answer for the case k=i. * * *
s263912741
Accepted
p02575
Input is given from Standard Input in the following format: H W A_1 B_1 A_2 B_2 : A_H B_H
import numpy as np from numba import njit from numba.types import Array, int64 i4 = np.int32 i8 = np.int64 @njit((Array(int64, 1, "C"), Array(int64, 1, "C"), int64, int64), cache=True) def solve(a, b, H, W): ret = np.empty(H, i8) for i in range(H): ret[i] = -1 dp0 = np.arange(W) dp = np.arange(W) arg0 = W - 1 arg = 0 for i in range(H): r1 = np.searchsorted(dp, a[i]) r2 = np.searchsorted(dp, b[i]) if b[i] == W: if r1 == 0: return ret else: dp0 = dp0[:r1] dp = dp[:r1] else: dp[r1:r2] = b[i] if arg0 > -1: if r1 <= arg0 < r2: for j in range(r1 - 1, -1, -1): if dp[j] == dp0[j]: arg0 = j ret[i] = i + 1 break else: arg0 = -1 arg = np.argmin(dp - dp0) ret[i] = dp[arg] - dp0[arg] + i + 1 else: ret[i] = i + 1 else: if r1 <= arg < r2: arg = np.argmin(dp - dp0) ret[i] = dp[arg] - dp0[arg] + i + 1 if i % 1000 == 999: m = 0 prev = dp[0] for k in range(1, dp.shape[0]): if dp[k] > prev: dp0[m] = dp0[k - 1] dp[m] = prev m += 1 prev = dp[k] else: dp0[m] = dp0[dp0.shape[0] - 1] dp[m] = prev m += 1 dp0 = dp0[:m] dp = dp[:m] if arg0 > -1: for j in range(m - 1, -1, -1): if dp[j] == dp0[j]: arg0 = j break else: arg = np.argmin(dp - dp0) return ret def main(in_file): stdin = open(in_file) H, W = [int(x) for x in stdin.readline().split()] ab = np.fromstring(stdin.read(), i8, sep=" ").reshape((-1, 2)).T ans = solve(ab[0] - 1, ab[1].copy(), H, W) p = "\n".join([str(x) for x in ans.tolist()]) print(p) if __name__ == "__main__": main("/dev/stdin")
Statement There is a grid of squares with H+1 horizontal rows and W vertical columns. You will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer i from 1 through H, you cannot move down from the A_i-th, (A_i + 1)-th, \ldots, B_i-th squares from the left in the i-th row from the top. For each integer k from 1 through H, find the minimum number of moves needed to reach one of the squares in the (k+1)-th row from the top. (The starting square can be chosen individually for each case.) If, starting from any square in the top row, none of the squares in the (k+1)-th row can be reached, print `-1` instead.
[{"input": "4 4\n 2 4\n 1 1\n 2 3\n 2 4", "output": "1\n 3\n 6\n -1\n \n\nLet (i,j) denote the square at the i-th row from the top and j-th column from\nthe left.\n\nFor k=1, we need one move such as (1,1) \u2192 (2,1).\n\nFor k=2, we need three moves such as (1,1) \u2192 (2,1) \u2192 (2,2) \u2192 (3,2).\n\nFor k=3, we need six moves such as (1,1) \u2192 (2,1) \u2192 (2,2) \u2192 (3,2) \u2192 (3,3) \u2192\n(3,4) \u2192 (4,4).\n\nFor k=4, it is impossible to reach any square in the fifth row from the top."}]
Print H lines. The i-th line should contain the answer for the case k=i. * * *
s086428983
Accepted
p02575
Input is given from Standard Input in the following format: H W A_1 B_1 A_2 B_2 : A_H B_H
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..) from typing import List from heapq import heappush, heappop, heapify import sys from collections import defaultdict INF = 10**6 def main(H, W, AB): cur = list(range(W)) cur_f = BinaryIndexedTree(initial_values=[1] * W) rt = RemovableHeapq([0] * W) for i, (a, b) in enumerate(AB): a -= 1 mr = -1 while True: j = cur_f.bisect(lambda x: x <= cur_f.query(a - 1)) if j >= W or j > b: break mr = cur[j] cur_f.add(j, -1) rt.remove(j - cur[j]) if mr >= 0 and b < W: cur_f.add(b, 1) cur[b] = mr rt.push(b - mr) ans = -1 if not rt.is_empty(): ans = rt.get_min() + i + 1 print(ans) class RemovableHeapq: def __init__(self, l: List[int]): h = l[:] heapify(h) d = defaultdict(int) for e in l: d[e] += 1 self.h, self.d = l, d def push(self, item: int): heappush(self.h, item) self.d[item] += 1 def remove(self, item: int) -> bool: d = self.d if d[item] > 0: d[item] -= 1 return True return False def get_min(self) -> int: h, d = self.h, self.d while True: m = h[0] if d[m] == 0: heappop(h) else: return m def is_empty(self) -> bool: h, d = self.h, self.d while h: if d[h[0]] == 0: heappop(h) else: break return len(h) == 0 class BinaryIndexedTree: def __init__(self, n=None, f=lambda x, y: x + y, identity=0, initial_values=None): assert n or initial_values ( self.__f, self.__id, ) = ( f, identity, ) self.__n = len(initial_values) if initial_values else n self.__d = [identity] * (self.__n + 1) if initial_values: for i, v in enumerate(initial_values): self.add(i, v) def add(self, i, v): n, f, d = self.__n, self.__f, self.__d i += 1 while i <= n: d[i] = f(d[i], v) i += -i & i def query(self, r): res, f, d = self.__id, self.__f, self.__d r += 1 while r: res = f(res, d[r]) r -= -r & r return res def bisect(self, func): """func()がFalseになるもっとも左のindexを探す""" n, f, d, v = self.__n, self.__f, self.__d, self.__id x, i = 0, 1 << (n.bit_length() - 1) while i > 0: if x + i <= n and func(f(v, d[x + i])): v, x = f(v, d[x + i]), x + i i >>= 1 return x if __name__ == "__main__": input = sys.stdin.readline H, W = map(int, input().split()) AB = [tuple(map(int, input().split())) for _ in range(H)] main(H, W, AB)
Statement There is a grid of squares with H+1 horizontal rows and W vertical columns. You will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer i from 1 through H, you cannot move down from the A_i-th, (A_i + 1)-th, \ldots, B_i-th squares from the left in the i-th row from the top. For each integer k from 1 through H, find the minimum number of moves needed to reach one of the squares in the (k+1)-th row from the top. (The starting square can be chosen individually for each case.) If, starting from any square in the top row, none of the squares in the (k+1)-th row can be reached, print `-1` instead.
[{"input": "4 4\n 2 4\n 1 1\n 2 3\n 2 4", "output": "1\n 3\n 6\n -1\n \n\nLet (i,j) denote the square at the i-th row from the top and j-th column from\nthe left.\n\nFor k=1, we need one move such as (1,1) \u2192 (2,1).\n\nFor k=2, we need three moves such as (1,1) \u2192 (2,1) \u2192 (2,2) \u2192 (3,2).\n\nFor k=3, we need six moves such as (1,1) \u2192 (2,1) \u2192 (2,2) \u2192 (3,2) \u2192 (3,3) \u2192\n(3,4) \u2192 (4,4).\n\nFor k=4, it is impossible to reach any square in the fifth row from the top."}]
Print H lines. The i-th line should contain the answer for the case k=i. * * *
s897278154
Wrong Answer
p02575
Input is given from Standard Input in the following format: H W A_1 B_1 A_2 B_2 : A_H B_H
from sys import stdin readline = stdin.readline H, W = map(int, readline().split()) x = 0 c = 0 result = [] for _ in range(H): A, B = map(lambda x: int(x) - 1, readline().split()) if x == W: result.append(-1) elif x < A or x > B: c += 1 result.append(c) elif A <= x <= B: c += B - x + 2 x = B + 1 if x == W: result.append(-1) else: result.append(c) print(*result, sep="\n")
Statement There is a grid of squares with H+1 horizontal rows and W vertical columns. You will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer i from 1 through H, you cannot move down from the A_i-th, (A_i + 1)-th, \ldots, B_i-th squares from the left in the i-th row from the top. For each integer k from 1 through H, find the minimum number of moves needed to reach one of the squares in the (k+1)-th row from the top. (The starting square can be chosen individually for each case.) If, starting from any square in the top row, none of the squares in the (k+1)-th row can be reached, print `-1` instead.
[{"input": "4 4\n 2 4\n 1 1\n 2 3\n 2 4", "output": "1\n 3\n 6\n -1\n \n\nLet (i,j) denote the square at the i-th row from the top and j-th column from\nthe left.\n\nFor k=1, we need one move such as (1,1) \u2192 (2,1).\n\nFor k=2, we need three moves such as (1,1) \u2192 (2,1) \u2192 (2,2) \u2192 (3,2).\n\nFor k=3, we need six moves such as (1,1) \u2192 (2,1) \u2192 (2,2) \u2192 (3,2) \u2192 (3,3) \u2192\n(3,4) \u2192 (4,4).\n\nFor k=4, it is impossible to reach any square in the fifth row from the top."}]
Print H lines. The i-th line should contain the answer for the case k=i. * * *
s886004429
Runtime Error
p02575
Input is given from Standard Input in the following format: H W A_1 B_1 A_2 B_2 : A_H B_H
def resolve(): #n=int(input()) #a,b=map(int,input().split()) #x=list(map(int,input().split())) #a=[list(map(lambda x:int(x)%2,input().split())) for _ in range(h)] h,w=map(int,input().split()) ab=[list(map(lambda x:int(x)-1,input().split())) for _ in range(h)] ans=[-1]*(h+1) y,x=0,0 cnt=0 while x<=w-1: while ab[y][0]>x or x>ab[y][1]: y+=1 cnt+=1 ans[y]=cnt x+=1 cnt+=1 for i in ans[1:]: print(i) if __name__ == '__main__': resolve()
Statement There is a grid of squares with H+1 horizontal rows and W vertical columns. You will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer i from 1 through H, you cannot move down from the A_i-th, (A_i + 1)-th, \ldots, B_i-th squares from the left in the i-th row from the top. For each integer k from 1 through H, find the minimum number of moves needed to reach one of the squares in the (k+1)-th row from the top. (The starting square can be chosen individually for each case.) If, starting from any square in the top row, none of the squares in the (k+1)-th row can be reached, print `-1` instead.
[{"input": "4 4\n 2 4\n 1 1\n 2 3\n 2 4", "output": "1\n 3\n 6\n -1\n \n\nLet (i,j) denote the square at the i-th row from the top and j-th column from\nthe left.\n\nFor k=1, we need one move such as (1,1) \u2192 (2,1).\n\nFor k=2, we need three moves such as (1,1) \u2192 (2,1) \u2192 (2,2) \u2192 (3,2).\n\nFor k=3, we need six moves such as (1,1) \u2192 (2,1) \u2192 (2,2) \u2192 (3,2) \u2192 (3,3) \u2192\n(3,4) \u2192 (4,4).\n\nFor k=4, it is impossible to reach any square in the fifth row from the top."}]
Print H lines. The i-th line should contain the answer for the case k=i. * * *
s278934404
Runtime Error
p02575
Input is given from Standard Input in the following format: H W A_1 B_1 A_2 B_2 : A_H B_H
# ボツ import sys def input(): return sys.stdin.buffer.readline()[:-1] Q, N = map(int, input().split()) N += 1 INF = 10**12 # N: 処理する区間の長さ LV = (N - 1).bit_length() N0 = 2**LV data = [0] * (2 * N0) lazy = [None] * (2 * N0) def gindex(l, r): L = (l + N0) >> 1 R = (r + N0) >> 1 lc = 0 if l & 1 else (L & -L).bit_length() rc = 0 if r & 1 else (R & -R).bit_length() for i in range(LV): if rc <= i: yield R if L < R and lc <= i: yield L L >>= 1 R >>= 1 # 遅延伝搬処理 def propagates(*ids): for i in reversed(ids): v = lazy[i - 1] if v is None: continue lazy[2 * i - 1] = lazy[2 * i] = data[2 * i - 1] = data[2 * i] = v >> 1 lazy[i - 1] = None # 区間[l, r)をxに更新 def update(l, r, x): (*ids,) = gindex(l, r) propagates(*ids) L = N0 + l R = N0 + r v = x while L < R: if R & 1: R -= 1 lazy[R - 1] = data[R - 1] = v if L & 1: lazy[L - 1] = data[L - 1] = v L += 1 L >>= 1 R >>= 1 v <<= 1 for i in ids: data[i - 1] = data[2 * i - 1] + data[2 * i] # 区間[l, r)内の合計を求める def query(l, r): propagates(*gindex(l, r)) L = N0 + l R = N0 + r s = 0 while L < R: if R & 1: R -= 1 s += data[R - 1] if L & 1: s += data[L - 1] L += 1 L >>= 1 R >>= 1 return s def access(x): return query(x, x + 1) lm = 0 update(0, 1, -INF) update(N, N + 1, INF) for q in range(1, Q + 1): a, b = map(int, input().split()) a, b = a - 1, b - 1 if a == lm: lm = b + 1 update(b + 1, b + 2, access(b + 1) + query(a, b + 1) - (b + 1 - a)) update(a, b + 1, 1) res = min(query(0, lm + 1), query(0, max(a, 1)), query(0, b + 1)) res += INF if res > 10**10: print(-1) else: print(res + q)
Statement There is a grid of squares with H+1 horizontal rows and W vertical columns. You will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer i from 1 through H, you cannot move down from the A_i-th, (A_i + 1)-th, \ldots, B_i-th squares from the left in the i-th row from the top. For each integer k from 1 through H, find the minimum number of moves needed to reach one of the squares in the (k+1)-th row from the top. (The starting square can be chosen individually for each case.) If, starting from any square in the top row, none of the squares in the (k+1)-th row can be reached, print `-1` instead.
[{"input": "4 4\n 2 4\n 1 1\n 2 3\n 2 4", "output": "1\n 3\n 6\n -1\n \n\nLet (i,j) denote the square at the i-th row from the top and j-th column from\nthe left.\n\nFor k=1, we need one move such as (1,1) \u2192 (2,1).\n\nFor k=2, we need three moves such as (1,1) \u2192 (2,1) \u2192 (2,2) \u2192 (3,2).\n\nFor k=3, we need six moves such as (1,1) \u2192 (2,1) \u2192 (2,2) \u2192 (3,2) \u2192 (3,3) \u2192\n(3,4) \u2192 (4,4).\n\nFor k=4, it is impossible to reach any square in the fifth row from the top."}]
Print H lines. The i-th line should contain the answer for the case k=i. * * *
s563019638
Wrong Answer
p02575
Input is given from Standard Input in the following format: H W A_1 B_1 A_2 B_2 : A_H B_H
import sys input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x + "\n") h, w = map(int, input().split()) ab = [tuple(map(int, input().split())) for _ in range(h)] dp = [None] * h v = 1 i = 0 for a, b in ab: if a <= v <= b: v = b + 1 dp[i] = v i += 1 dp2 = [None] * h done = [0] * h for i in range(h - 1, -1, -1): if done[i]: continue v = w l = [] for j in range(i, -1, -1): a, b = ab[j] if v == w: l.append(j) if a <= v <= b: v = a - 1 for ind in l: dp2[ind] = v done[ind] = 1 dp, dp2 ans = [None] * h for i in range(h): if dp[i] > w: ans[i] = -1 else: # if dp[i]>=dp2[i]: ans[i] = (i + 1) + (dp[i] - dp2[i]) write("\n".join(map(str, ans)))
Statement There is a grid of squares with H+1 horizontal rows and W vertical columns. You will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer i from 1 through H, you cannot move down from the A_i-th, (A_i + 1)-th, \ldots, B_i-th squares from the left in the i-th row from the top. For each integer k from 1 through H, find the minimum number of moves needed to reach one of the squares in the (k+1)-th row from the top. (The starting square can be chosen individually for each case.) If, starting from any square in the top row, none of the squares in the (k+1)-th row can be reached, print `-1` instead.
[{"input": "4 4\n 2 4\n 1 1\n 2 3\n 2 4", "output": "1\n 3\n 6\n -1\n \n\nLet (i,j) denote the square at the i-th row from the top and j-th column from\nthe left.\n\nFor k=1, we need one move such as (1,1) \u2192 (2,1).\n\nFor k=2, we need three moves such as (1,1) \u2192 (2,1) \u2192 (2,2) \u2192 (3,2).\n\nFor k=3, we need six moves such as (1,1) \u2192 (2,1) \u2192 (2,2) \u2192 (3,2) \u2192 (3,3) \u2192\n(3,4) \u2192 (4,4).\n\nFor k=4, it is impossible to reach any square in the fifth row from the top."}]
Print H lines. The i-th line should contain the answer for the case k=i. * * *
s399275965
Wrong Answer
p02575
Input is given from Standard Input in the following format: H W A_1 B_1 A_2 B_2 : A_H B_H
import sys input = sys.stdin.readline H, W = map(int, input().split()) D = [tuple(map(int, input().split())) for i in range(H)] # 範囲更新、最大値取得の遅延セグ木と、範囲更新、最小値取得の遅延セグ木 seg_el = 1 << ((W + 3).bit_length()) # Segment treeの台の要素数 SEG = [1 << 30] * ( 2 * seg_el ) # 1-indexedなので、要素数2*seg_el.Segment treeの初期値で初期化 LAZY = [0] * ( 2 * seg_el ) # 1-indexedなので、要素数2*seg_el.Segment treeの初期値で初期化 SEG2 = [0] * ( 2 * seg_el ) # 1-indexedなので、要素数2*seg_el.Segment treeの初期値で初期化 LAZY2 = [0] * ( 2 * seg_el ) # 1-indexedなので、要素数2*seg_el.Segment treeの初期値で初期化 def indexes(L, R): INDLIST = [] R -= 1 L >>= 1 R >>= 1 while L != R: if L > R: INDLIST.append(L) L >>= 1 else: INDLIST.append(R) R >>= 1 while L != 0: INDLIST.append(L) L >>= 1 return INDLIST def updates(l, r, x): # 区間[l,r)をxに更新 L = l + seg_el R = r + seg_el L //= L & (-L) R //= R & (-R) UPIND = indexes(L, R) for ind in UPIND[::-1]: if LAZY[ind] != None: LAZY[ind << 1] = LAZY[1 + (ind << 1)] = SEG[ind << 1] = SEG[ 1 + (ind << 1) ] = LAZY[ind] LAZY[ind] = None while L != R: if L > R: SEG[L] = x LAZY[L] = x L += 1 L //= L & (-L) else: R -= 1 SEG[R] = x LAZY[R] = x R //= R & (-R) for ind in UPIND: SEG[ind] = max(SEG[ind << 1], SEG[1 + (ind << 1)]) def updates2(l, r, x): # 区間[l,r)をxに更新 L = l + seg_el R = r + seg_el L //= L & (-L) R //= R & (-R) UPIND = indexes(L, R) for ind in UPIND[::-1]: if LAZY2[ind] != None: LAZY2[ind << 1] = LAZY2[1 + (ind << 1)] = SEG2[ind << 1] = SEG2[ 1 + (ind << 1) ] = LAZY2[ind] LAZY2[ind] = None while L != R: if L > R: SEG2[L] = x LAZY2[L] = x L += 1 L //= L & (-L) else: R -= 1 SEG2[R] = x LAZY2[R] = x R //= R & (-R) for ind in UPIND: SEG2[ind] = min(SEG2[ind << 1], SEG2[1 + (ind << 1)]) def getvalues(l, r): # 区間[l,r)に関するmaxを調べる L = l + seg_el R = r + seg_el L //= L & (-L) R //= R & (-R) UPIND = indexes(L, R) for ind in UPIND[::-1]: if LAZY[ind] != None: LAZY[ind << 1] = LAZY[1 + (ind << 1)] = SEG[ind << 1] = SEG[ 1 + (ind << 1) ] = LAZY[ind] LAZY[ind] = None ANS = -1 while L != R: if L > R: ANS = max(ANS, SEG[L]) L += 1 L //= L & (-L) else: R -= 1 ANS = max(ANS, SEG[R]) R //= R & (-R) return ANS def getvalues2(l, r): # 区間[l,r)に関するminを調べる L = l + seg_el R = r + seg_el L //= L & (-L) R //= R & (-R) UPIND = indexes(L, R) for ind in UPIND[::-1]: if LAZY2[ind] != None: LAZY2[ind << 1] = LAZY2[1 + (ind << 1)] = SEG2[ind << 1] = SEG2[ 1 + (ind << 1) ] = LAZY2[ind] LAZY2[ind] = None ANS = 1 << 31 while L != R: if L > R: ANS = min(ANS, SEG2[L]) L += 1 L //= L & (-L) else: R -= 1 ANS = min(ANS, SEG2[R]) R //= R & (-R) return ANS for i in range(W + 1): updates(i, i + 1, i) for i in range(H): x, y = D[i] if x == 1: updates(x, y + 1, -1) else: MAX = getvalues(1, x) updates(x, y + 1, MAX) updates2(x, y + 1, 1 << 30) updates2(y + 1, y + 2, y + 1 - getvalues(y + 1, y + 2)) # print(*[getvalues(i,i+1) for i in range(W+1)]) # print(*[getvalues2(i,i+1) for i in range(W+1)]) ANS = getvalues2(1, W + 1) + i + 1 if ANS > 1 << 28: print(-1) else: print(ANS)
Statement There is a grid of squares with H+1 horizontal rows and W vertical columns. You will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer i from 1 through H, you cannot move down from the A_i-th, (A_i + 1)-th, \ldots, B_i-th squares from the left in the i-th row from the top. For each integer k from 1 through H, find the minimum number of moves needed to reach one of the squares in the (k+1)-th row from the top. (The starting square can be chosen individually for each case.) If, starting from any square in the top row, none of the squares in the (k+1)-th row can be reached, print `-1` instead.
[{"input": "4 4\n 2 4\n 1 1\n 2 3\n 2 4", "output": "1\n 3\n 6\n -1\n \n\nLet (i,j) denote the square at the i-th row from the top and j-th column from\nthe left.\n\nFor k=1, we need one move such as (1,1) \u2192 (2,1).\n\nFor k=2, we need three moves such as (1,1) \u2192 (2,1) \u2192 (2,2) \u2192 (3,2).\n\nFor k=3, we need six moves such as (1,1) \u2192 (2,1) \u2192 (2,2) \u2192 (3,2) \u2192 (3,3) \u2192\n(3,4) \u2192 (4,4).\n\nFor k=4, it is impossible to reach any square in the fifth row from the top."}]
Print H lines. The i-th line should contain the answer for the case k=i. * * *
s245556576
Wrong Answer
p02575
Input is given from Standard Input in the following format: H W A_1 B_1 A_2 B_2 : A_H B_H
R, C = map(int, input().split(" ")) g = [[0 for i in range(C)] for j in range(R + 1)] ref = [[0 for i in range(C)] for j in range(R + 1)] INF = 2000000 for i in range(R): a, b = map(int, input().split(" ")) a -= 1 b -= 1 for j in range(a, b + 1): ref[i][j] = 1 for r in range(R + 1): for c in range(C): if r == 0 and c == 0: g[r][c] = INF if ref[r][c] == 1 else 0 elif r == 0: g[r][c] = g[r][c - 1] + 1 elif c == 0: g[r][c] = INF if ref[r - 1][c] == 1 else g[r - 1][c] + 1 else: g[r][c] = min( (INF if ref[r - 1][c] == 1 else g[r - 1][c] + 1), g[r][c - 1] + 1 ) print(g) for i in range(1, R + 1): print(-1 if min(g[i]) >= INF else min(g[i]))
Statement There is a grid of squares with H+1 horizontal rows and W vertical columns. You will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer i from 1 through H, you cannot move down from the A_i-th, (A_i + 1)-th, \ldots, B_i-th squares from the left in the i-th row from the top. For each integer k from 1 through H, find the minimum number of moves needed to reach one of the squares in the (k+1)-th row from the top. (The starting square can be chosen individually for each case.) If, starting from any square in the top row, none of the squares in the (k+1)-th row can be reached, print `-1` instead.
[{"input": "4 4\n 2 4\n 1 1\n 2 3\n 2 4", "output": "1\n 3\n 6\n -1\n \n\nLet (i,j) denote the square at the i-th row from the top and j-th column from\nthe left.\n\nFor k=1, we need one move such as (1,1) \u2192 (2,1).\n\nFor k=2, we need three moves such as (1,1) \u2192 (2,1) \u2192 (2,2) \u2192 (3,2).\n\nFor k=3, we need six moves such as (1,1) \u2192 (2,1) \u2192 (2,2) \u2192 (3,2) \u2192 (3,3) \u2192\n(3,4) \u2192 (4,4).\n\nFor k=4, it is impossible to reach any square in the fifth row from the top."}]
Print H lines. The i-th line should contain the answer for the case k=i. * * *
s278251094
Wrong Answer
p02575
Input is given from Standard Input in the following format: H W A_1 B_1 A_2 B_2 : A_H B_H
-1
Statement There is a grid of squares with H+1 horizontal rows and W vertical columns. You will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer i from 1 through H, you cannot move down from the A_i-th, (A_i + 1)-th, \ldots, B_i-th squares from the left in the i-th row from the top. For each integer k from 1 through H, find the minimum number of moves needed to reach one of the squares in the (k+1)-th row from the top. (The starting square can be chosen individually for each case.) If, starting from any square in the top row, none of the squares in the (k+1)-th row can be reached, print `-1` instead.
[{"input": "4 4\n 2 4\n 1 1\n 2 3\n 2 4", "output": "1\n 3\n 6\n -1\n \n\nLet (i,j) denote the square at the i-th row from the top and j-th column from\nthe left.\n\nFor k=1, we need one move such as (1,1) \u2192 (2,1).\n\nFor k=2, we need three moves such as (1,1) \u2192 (2,1) \u2192 (2,2) \u2192 (3,2).\n\nFor k=3, we need six moves such as (1,1) \u2192 (2,1) \u2192 (2,2) \u2192 (3,2) \u2192 (3,3) \u2192\n(3,4) \u2192 (4,4).\n\nFor k=4, it is impossible to reach any square in the fifth row from the top."}]
Print H lines. The i-th line should contain the answer for the case k=i. * * *
s057567483
Wrong Answer
p02575
Input is given from Standard Input in the following format: H W A_1 B_1 A_2 B_2 : A_H B_H
import sys import time if sys.argv[-1] == "ONLINE_JUDGE": time.sleep(60) exit() print("RE or WA or TLE")
Statement There is a grid of squares with H+1 horizontal rows and W vertical columns. You will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer i from 1 through H, you cannot move down from the A_i-th, (A_i + 1)-th, \ldots, B_i-th squares from the left in the i-th row from the top. For each integer k from 1 through H, find the minimum number of moves needed to reach one of the squares in the (k+1)-th row from the top. (The starting square can be chosen individually for each case.) If, starting from any square in the top row, none of the squares in the (k+1)-th row can be reached, print `-1` instead.
[{"input": "4 4\n 2 4\n 1 1\n 2 3\n 2 4", "output": "1\n 3\n 6\n -1\n \n\nLet (i,j) denote the square at the i-th row from the top and j-th column from\nthe left.\n\nFor k=1, we need one move such as (1,1) \u2192 (2,1).\n\nFor k=2, we need three moves such as (1,1) \u2192 (2,1) \u2192 (2,2) \u2192 (3,2).\n\nFor k=3, we need six moves such as (1,1) \u2192 (2,1) \u2192 (2,2) \u2192 (3,2) \u2192 (3,3) \u2192\n(3,4) \u2192 (4,4).\n\nFor k=4, it is impossible to reach any square in the fifth row from the top."}]
Print H lines. The i-th line should contain the answer for the case k=i. * * *
s837068057
Wrong Answer
p02575
Input is given from Standard Input in the following format: H W A_1 B_1 A_2 B_2 : A_H B_H
import os import sys import numpy as np # Test def solve(inp): def func1(a, b): return a + b def func2(c, d): return func1(c, d) + c + d return func2(inp[0], inp[1]) if sys.argv[-1] == "ONLINE_JUDGE": from numba.pycc import CC cc = CC("my_module") cc.export("solve", "(i8[:],)")(solve) cc.compile() exit() if os.name == "posix" or True: # noinspection PyUnresolvedReferences from my_module import solve else: from numba import njit solve = njit("(i8[:],)", cache=True)(solve) print("compiled!", file=sys.stderr) inp = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=" ") ans = solve(inp) print(ans)
Statement There is a grid of squares with H+1 horizontal rows and W vertical columns. You will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer i from 1 through H, you cannot move down from the A_i-th, (A_i + 1)-th, \ldots, B_i-th squares from the left in the i-th row from the top. For each integer k from 1 through H, find the minimum number of moves needed to reach one of the squares in the (k+1)-th row from the top. (The starting square can be chosen individually for each case.) If, starting from any square in the top row, none of the squares in the (k+1)-th row can be reached, print `-1` instead.
[{"input": "4 4\n 2 4\n 1 1\n 2 3\n 2 4", "output": "1\n 3\n 6\n -1\n \n\nLet (i,j) denote the square at the i-th row from the top and j-th column from\nthe left.\n\nFor k=1, we need one move such as (1,1) \u2192 (2,1).\n\nFor k=2, we need three moves such as (1,1) \u2192 (2,1) \u2192 (2,2) \u2192 (3,2).\n\nFor k=3, we need six moves such as (1,1) \u2192 (2,1) \u2192 (2,2) \u2192 (3,2) \u2192 (3,3) \u2192\n(3,4) \u2192 (4,4).\n\nFor k=4, it is impossible to reach any square in the fifth row from the top."}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s649484912
Accepted
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
import sys # やけくそ def 解(): iN, iM = [int(_) for _ in input().split()] aPM = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()] dC = {} def addCity(d, p, m, i): if p in d: d[p].append((m, i)) else: d[p] = [(m, i)] iIndex = 1 for p, m in aPM: addCity(dC, p, m, iIndex) iIndex += 1 oAns = [] for iCity in dC.keys(): iIndex = 1 for m, i in sorted(list(dC[iCity])): oAns.append((i, "{:06}{:06}".format(iCity, iIndex))) iIndex += 1 oAns.sort() oAns2 = [] for i, s in oAns: oAns2.append(s) print("\n".join(oAns2)) 解()
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s391059349
Runtime Error
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
n,m=map(int,input().split()) py=[] for i in range(m): py.append(list(map(int,input().split()))+[i+1]) py.sort() number_list=[] number_list.append([str(0)]*(6-(len(list(str(py[0][0])))))+list(str(py[0][0]))+[str(0)]*(6-(len(list(str(1)))))+list(str(1))+[str(py[0][-1])]) k=2 for j in range(1,m): if py[j][0]==py[j-1][0]: number_list.append([str(0)]*(6-(len(list(str(py[j][0])))))+list(str(py[j][0]))+[str(0)]*(6-(len(list(str(k)))))+list(str(k))+[str(py[j][-1])]) k+=1 else: k=1 number_list.append([str(0)]*(6-(len(list(str(py[j][0])))))+list(str(py[j][0]))+[str(0)]*(6-(len(list(str(k)))))+list(str(k))+[str(py[j][-1])]) k+=1 number_list_sort=sorted(number_list,key=lambda x:x[-1]) for l in range(m): print(''.join(number_list_sort[l][:-1])
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s100847841
Runtime Error
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
#include<iostream> #include<cmath> #include<algorithm> #include<string> #include<map> #include<utility> #include<vector> using namespace std; typedef long long ll; ll deg(ll n){ ll count = 0; while(n!= 0){ n/=10; count++; } return count; } int main(){ ll n,m; cin >> n >> m; ll y[m],p[m]; for(int i = 0;i < m;i++) cin >> p[i] >> y[i]; vector<pair<ll,ll> > pi(m); for(int i = 0;i < m;i++){ pi[i] = make_pair(p[i],y[i]); } sort(pi.begin(), pi.end()); map<pair<ll,ll>, ll>mp; int cur = 1; for(int i = 0;i < m;i++){ if(i-1 >= 0) if(pi[i-1].first != pi[i].first){ cur = 1; } mp[pi[i]] = cur; cur++; } for(int i = 0;i < m;i++){ int id = mp[make_pair(p[i],y[i])]; printf("%0.6lld ", p[i]); printf("%0.6d\n", id); } }
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s243338661
Runtime Error
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
N, M = map(int, input().split()) db = [] line = 0 while line < M: P, C = map(int, input().split()) line += 1 db.append([line, P, C]) # sort by year db.sort(key=lambda x: x[2]) # sort by prefecture db.sort(key=lambda x: x[1]) # ans list would be list whereby each element is [line, ID] ans = [] cont = 0 P = db[0][1] for idx in range(M): # create ID new_P = db[idx][1] digP = len(str(new_P)) ID = '0' * (6 - digP) + str(new_P) if new_P == P: cont += 1 else: cont = 1 ID += '0' * (6 - len(str(cont))) + str(cont) ans.append([db[idx][0],ID]) P = new_P ans.sort(key=labmda x:x[0]) for row in range(M): print(ans[row][1])
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s610381408
Runtime Error
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
N, M = map(int, input().split()) |N, M = map(int, input().split()) order = [] |order = [] result = {} |result = {} city = {} |city = {} for i in range(M): |for i in range(M): P, Y = map(int, input().split()) | P, Y = map(int, input().split()) order.append(Y) | order.append(Y) if P in city: | if P in city: city[P].append(Y) | city[P].append(Y) else: | else: city[P] = [Y] | city[P] = [Y] | s_city = dict(sorted(city.items())) |s_city = dict(sorted(city.items())) for v in s_city.values(): |for v in s_city.values(): v.sort() | v.sort() | for k, v in city.items(): |for k, v in city.items(): i = 1 | i = 1 for e in v: | for e in v: order[order.index(e)] = str(k).zfill(8) + str(i).zfill(8) | order[order.index(e)] = str(k).zfill(8) + str(i).zfill(8) i += 1 | i += 1 | for r in order: |for r in order: print(r) | print(r)
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s578851420
Runtime Error
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
N, M = map(int, input().split()) PY = [None for _ range(M)] ken_d = {k:[] for k in range(1, N+1)} for i in range(M): p = list(map(int,input().split())) PY[i] = p ken_d[p[0]].append(p[1]) for k in ken_d.keys(): ken_d[k].sort() for p in PY: x = ken_d[p[0]].index(p[1]) + 1 print(str(p[0]).zfill(6) + str(x).zfill(6))
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s944139711
Runtime Error
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
import bisect N, M = (int(i) for i in input().split()) PY = [[int(i) for i in input().split()] for i in range(M)] d = {} for i in range(M): p, y = [int(i) for i in input().split()] if p not in d: d[p] = [y] else: #d[p] = (d[p] + [y]) index = bisect.bisect_left(d[p], y) d[p].insert(index, y) #for x in d: # d[x].sort() for p, y in PY: print('{}{}'.format(str(p).zfill(6), str(d[p].index(y) + 1).zfill(6)))9
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s025124282
Accepted
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
n, m = map(int, input().split()) p = [0] * m V = [[] for i in range(n + 1)] for i in range(m): p[i] = list(map(int, input().split())) + [i] V[p[i][0]].append(p[i][1:]) W = [] for i in range(n + 1): if V[i] == []: pass else: V[i].sort(key=lambda val: val[0]) for j in range(len(V[i])): K = ( ["0"] * (6 - len(str(i))) + list(str(i)) + ["0"] * (6 - len(str(j + 1))) + list(str(j + 1)) ) W.append(["".join(K), V[i][j][1]]) W.sort(key=lambda val: val[1]) for ans in W: print(ans[0])
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s705397502
Wrong Answer
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
from collections import deque a, b = map(int, input().split()) c = [[] for i in range(a)] d = [deque() for i in range(a)] z = [] for _ in range(b): f, g = map(int, input().split()) c[f - 1].append(g) d[f - 1].append(0) for num in range(len(c[f - 1])): if c[f - 1][num] >= g: d[f - 1][num] += 1 z.append([f, g]) x = "" y = "" for j in range(b): x = str(z[j][0]) x = "0" * (6 - len(x)) + x y = str(d[z[j][0] - 1].popleft()) y = "0" * (6 - len(y)) + y print(x + y)
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s916078530
Accepted
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
import sys input = sys.stdin.readline def binary_search(list, item): low = 0 high = len(list) - 1 while low <= high: mid = (low + high) // 2 guess = list[mid] if guess == item: return mid if guess > item: high = mid - 1 else: low = mid + 1 n, m = map(int, input().split()) py = [list(map(int, input().split())) for i in range(m)] check = sorted(py) memo = py[0][0] cnt = [0] * m cnt_memo = 0 for i in range(m): if memo != check[i][0]: memo = check[i][0] cnt_memo = 0 cnt_memo += 1 cnt[i] = cnt_memo for i in range(m): number = str(cnt[binary_search(check, py[i])]) p = str(py[i][0]) print((6 - len(p)) * "0" + p + (6 - len(number)) * "0" + number)
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s969579745
Accepted
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
from copy import deepcopy from sys import exit, setrecursionlimit import math from collections import defaultdict, Counter, deque from fractions import Fraction as frac setrecursionlimit(1000000) def main(): n, m = map(int, input().split()) py = defaultdict(list) si_ban = [] for _ in range(m): x, y = map(int, input().split()) si_ban.append(y) py[x].append(y) ans = {} for k, v in py.items(): v.sort() for i in range(1, len(v) + 1): ans[v[i - 1]] = str(k).zfill(6) + str(i).zfill(6) for i in si_ban: print(ans[i]) def zip(a): mae = a[0] ziparray = [mae] for i in range(1, len(a)): if mae != a[i]: ziparray.append(a[i]) mae = a[i] return ziparray def is_prime(n): if n < 2: return False for k in range(2, int(math.sqrt(n)) + 1): if n % k == 0: return False return True def list_replace(n, f, t): return [t if i == f else i for i in n] def base_10_to_n(X, n): X_dumy = X out = "" while X_dumy > 0: out = str(X_dumy % n) + out X_dumy = int(X_dumy / n) if out == "": return "0" return out def gcd(l): x = l.pop() y = l.pop() while x % y != 0: z = x % y x = y y = z l.append(min(x, y)) return gcd(l) if len(l) > 1 else l[0] class Queue: def __init__(self): self.q = deque([]) def push(self, i): self.q.append(i) def pop(self): return self.q.popleft() def size(self): return len(self.q) def debug(self): return self.q class Stack: def __init__(self): self.q = [] def push(self, i): self.q.append(i) def pop(self): return self.q.pop() def size(self): return len(self.q) def debug(self): return self.q class graph: def __init__(self): self.graph = defaultdict(list) def addnode(self, l): f, t = l[0], l[1] self.graph[f].append(t) self.graph[t].append(f) def rmnode(self, l): f, t = l[0], l[1] self.graph[f].remove(t) self.graph[t].remove(f) def linked(self, f): return self.graph[f] class dgraph: def __init__(self): self.graph = defaultdict(set) def addnode(self, l): f, t = l[0], l[1] self.graph[f].append(t) def rmnode(self, l): f, t = l[0], l[1] self.graph[f].remove(t) def linked(self, f): return self.graph[f] main()
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s622020816
Runtime Error
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
n, p = map(int, input().split()) arr = [] arr1 = [[] for i in range(10000)] for i in range(p): arr.append(list(map(int, input().split()))) arr1[arr[i][0]].append(arr[i][1]) for i in range(10000): arr1[i].sort() for i in range(p): print("%06d%06d" % (arr[i][0], arr1[arr[i][0]].index(arr[i][1]) + 1))
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s008160961
Wrong Answer
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
n, p = map(int, input().split()) lst = [list(map(int, input().split())) for i in range(p)] plst = [] plst = [i[0] for i in lst] ylst = [i[1] for i in lst] dic = {i: sorted([j[1] for j in lst if j[0] == i]) for i in plst} print(dic) for k in range(p): x = str(lst[k][0]).zfill(6) y = str(dic[lst[k][0]].index(lst[k][1]) + 1).zfill(6) print(x + y)
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s191322853
Accepted
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
# -*- coding: utf-8 -*- N, M = map(int, input().split()) answer_list = [0] * M prefectures = [0] * (N + 1) data_set = [0] * M for i in range(M): P, Y = map(int, input().split()) data_set[i] = [P, Y, i] data_set.sort() for i in range(M): answer = "" P, Y, a = data_set[i] prefectures[P] += 1 for j in range(6 - len(list(str(P)))): answer += "0" answer += str(P) for k in range(6 - len(list(str(prefectures[P])))): answer += "0" answer += str(prefectures[P]) answer_list[a] = answer for i in range(M): print(answer_list[i])
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s324247953
Runtime Error
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
n, m = map(int, input().split()) s = [] r = [] for n in range(n): s.append(list(map(int, input().split()))) for i in range(n): rank = 1 for j in range(n): if s[i][0] == s[j][0] and s[i][1] > s[j][1]: rank += 1 prefString = str(s[i][0]) rankString = str(rank) Number1st = "0" * (6 - len(prefString)) + prefString Number2nd = "0" * (6 - len(rankString)) + rankString print(Number1st + Number2nd)
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s794890847
Wrong Answer
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
N, M = [int(i) for i in input().split()] data = list() data_dict = dict() ind = 1 for i in range(M): p, y = [int(i) for i in input().split()] data.append([i, p, y]) data.sort(key=lambda x: (x[1], x[2])) ranked_data = list() for j, (i, p, y) in enumerate(data): if data[j - 1][1] != p and j > 1: ind = 1 ranked_data.append([i, p, y] + [ind]) ind += 1 def num2str(num, len_str=6): return "0" * (len_str - len(str(num))) + str(num) ranked_data.sort(key=lambda x: x[0]) for i, p, y, rank in ranked_data: print(num2str(p) + num2str(rank))
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s195766587
Wrong Answer
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
a, b = map(int, input().split()) L = [] l = [] ll = [] u = 0 for i in range(b): u += 1 c = list(map(int, input().split())) c.append(u) L.append(c) L.sort(key=lambda x: x[0]) for i in range(1, a + 1): lll = [] for j in L: if j[0] == i: lll.append(j) ll.append(lll) for i in ll: e = 0 for j in i: e += 1 j.append(e) q = [] for w in ll: q.extend(w) q.sort(key=lambda x: x[2]) for r in range(b): print( "0" * (6 - len(str(q[r][0]))) + str(q[r][0]) + "0" * (6 - len(str(q[r][3]))) + str(q[r][3]) )
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s965486233
Wrong Answer
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
Data = list(map(int, input().split())) N = Data[0] M = Data[1] del Data Data = [] for i in range(M): Data.append(list(map(int, input().split()))) Data[i].append(i) Data.sort() Cnt = 0 Num = 0 for i in range(M): if Num == Data[i][0]: Cnt += 1 else: Cnt = 1 Num = Data[i][0] Data[i].append(Cnt) Data.sort(key=lambda x: x[2]) for i in range(M): print(format(Data[i][0], "06x") + format(Data[i][3], "06x"))
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s400572219
Runtime Error
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
n, m = map(int, input().split()) A = [list(input().split()) for i in range(m)] for i in range(len(A)): A[i].append(i) A.sort(key=lambda x: x[1]) B = [0 for i in range(n)] for i in range(len(A)): for j in range(1, m + 1): if int(A[i][0]) == j: j -= 1 B[j] += 1 A[i].append(A[i][0].zfill(6) + str(B[j]).zfill(6)) A.sort(key=lambda x: x[2]) for a in A: print(a[3])
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s429350137
Accepted
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
n, m = map(int, input().split()) pyi = [list(map(int, input().split())) + [i] for i in range(m)] ids = [""] * m s = {j + 1: 1 for j in range(n)} for p, y, i in sorted(pyi, key=lambda d: d[1]): ids[i] = "%06d%06d" % (p, s[p]) s[p] += 1 for iid in ids: print(iid)
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s207804811
Accepted
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
n, m = map(int, input().split()) a = [[int(i) for i in input().split()] for i in range(m)] b = sorted(a) id = {} t = 1 for ind, i in enumerate(b): if ind != 0 and b[ind][0] != b[ind - 1][0]: t = 1 x = str(i[0]).zfill(6) y = str(t).zfill(6) t = int(t) t += 1 idd = x + y id[str(i[0]) + str(i[1])] = idd for i in a: ii = str(i[0]) + str(i[1]) print(id[ii])
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s240001298
Accepted
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
N, M = map(int, input().split()) # N,Mを取得 # 初期化 lists = [] # listに要素を追加 後で並び変えるため並び替える前の順番を示すキーを第三要素に挿入しておく for i in range(M): lists.append(list(map(int, input().split())) + [i]) # 第一要素に昇順で並び替えた後、第二要素で昇順に並び替える lists.sort(key=lambda x: x[1]) lists.sort(key=lambda x: x[0]) # befは前回の第一要素 stateは第一要素での順位 bef = 0 state = 0 retstr = "" triple = [] # 第四要素に識別番号を追加したリストの初期化 for i in lists: if i[0] != bef: bef = i[0] state = 1 triple.append( [i[0], i[1], i[2], str(i[0]).rjust(6, "0") + str(state).rjust(6, "0")] ) else: state += 1 triple.append( [i[0], i[1], i[2], str(i[0]).rjust(6, "0") + str(state).rjust(6, "0")] ) triple.sort( key=lambda x: x[2] ) # 第三要素で並び替えて、元の入力に対応した式ベンツ番号の順番に戻す for i in triple: print(i[3]) # 識別番号の出力
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s225133384
Accepted
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
L = list(map(int, input().split())) N = L[0] M = L[1] PY = list() for x in range(0, M): X = list(map(int, input().split())) PY.append((X[0], X[1], x)) sortedPY = sorted(PY, key=lambda x: x[1]) ID = [0 for i in range(N)] for y in range(0, M): n = sortedPY[y][0] n = n - 1 ID[n] = ID[n] + 1 nstr = str(ID[n]) Pstr = str(sortedPY[y][0]) while len(nstr) < 6: nstr = "0" + nstr while len(Pstr) < 6: Pstr = "0" + Pstr PY[sortedPY[y][2]] = Pstr + nstr number = Pstr + nstr for x in range(0, M): print(PY[x])
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s496450722
Accepted
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
import sys array = list(map(int, input().strip().split(" "))) N = array[0] M = array[1] if N < 1: sys.exit() if N > 10**5: sys.exit() if M < 1: sys.exit() if M > 10**5: sys.exit() list_t = [] for i in range(M): array1 = list(map(int, input().strip().split(" "))) P = array1[0] Y = array1[1] if P < 1: sys.exit() if P > N: sys.exit() if Y < 1: sys.exit() if Y > 10**9: sys.exit() list_t.append([i, P, Y]) list_t.sort(key=lambda x: (x[1], x[2])) test_P = list_t[0][1] list_t[0][2] = 1 bango = 1 for j in range(1, M): test_P_next = list_t[j][1] if test_P == test_P_next: bango = bango + 1 list_t[j][2] = bango else: bango = 1 list_t[j][2] = bango test_P = test_P_next list_t.sort(key=lambda x: x[0]) for k in range(M): out1 = str(list_t[k][1]) out_zero1 = out1.zfill(6) print(out_zero1, end="") out2 = str(list_t[k][2]) out_zero2 = out2.zfill(6) print(out_zero2)
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s344075743
Wrong Answer
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
N, M = map(int, input().split()) # 5 7 P = [0] Y = [0] A = [] for i in range(M): p, y = map(int, input().split()) # 5 7 P.append(p) Y.append(y) A.append([i, p, y, p * 1000000 + y]) # print(N,M) # print(*P) # print(*Y) # print(*A) A = sorted(A, key=lambda x: x[3]) # print(*A) p0 = 0 no = 0 for i in range(len(A)): a = A[i] p = a[1] y = a[2] # print(i,a,p,y) if p != p0: no = 0 no += 1 A[i].append(no) p0 = p # print(*A) A = sorted(A, key=lambda x: x[0]) # print(*A) for a in A: p = "000000" + str(a[1]) i = "000000" + str(a[4]) print(p[-6:] + i[-6:])
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s068053787
Wrong Answer
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
n, m = map(int, input().split()) i_p_y_pairs = [tuple(map(int, (("%d " % i) + input()).split())) for i in range(m)] i_p_y_pairs.sort(key=(lambda i_p_y: i_p_y[2])) ret = [] current_p_idx = 0 current_p = i_p_y_pairs[current_p_idx][1] for idx in range(m): p = i_p_y_pairs[idx][1] if p != current_p: current_ipy_pairs = i_p_y_pairs[current_p_idx:idx] current_ipy_pairs.sort(key=lambda ipy: ipy[2]) for _idx_, ipy in enumerate(current_ipy_pairs): ret.append((ipy[0], "%06d" % current_p + "%06d" % (_idx_ + 1))) current_p_idx = idx current_p = i_p_y_pairs[current_p_idx][1] else: current_ipy_pairs = i_p_y_pairs[current_p_idx:] current_ipy_pairs.sort(key=lambda ipy: ipy[2]) for _idx_, ipy in enumerate(current_ipy_pairs): ret.append((ipy[0], ("%06d" % current_p + "%06d" % (_idx_ + 1)))) ret.sort(key=lambda x: x[0]) for r in ret: print(r[1])
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s458853963
Wrong Answer
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
n, m = map(int, input().split()) # i は 通し番号 cities = sorted(([list(map(int, input().split())) + [i] for i in range(m)])) print(cities) pref = cities[0] counter = 1 for city in cities: if pref != city[0]: counter = 1 pref = city[0] rank = counter number = str(pref).zfill(6) + str(rank).zfill(6) city.append(number) counter += 1 for i in sorted(cities, key=lambda x: x[2]): print(i[3])
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s517391503
Wrong Answer
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
N, M = map(int, input().split()) L = [list(map(int, input().split())) for _ in range(M)] Y = sorted([(i, (p, y)) for i, (p, y) in enumerate(L)], key=lambda x: x[1][1]) result = [""] * M x = 0 before_p = 0 for i, (p, y) in Y: if before_p != p: x = 0 before_p = p x += 1 result[i] = "{:06}{:06}".format(p, x) for r in result: print(r)
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s212553881
Accepted
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
ken_shi_list = input().split() ken_num = int(ken_shi_list[0]) shi_num = int(ken_shi_list[1]) shi_list = [] nen_list = [[] for i in range(ken_num)] for i in range(shi_num): shi_list.append(input().split()) nen_list[int(shi_list[i][0]) - 1].append(int(shi_list[i][1])) checker = {} for i in range(ken_num): nen_list[i].sort() for j in range(len(nen_list[i])): checker[nen_list[i][j]] = j + 1 for i in range(shi_num): ken = int(shi_list[i][0]) nen = int(shi_list[i][1]) print(str(ken).zfill(6) + str(checker[nen]).zfill(6))
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s661673489
Wrong Answer
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
#!/usr/bin/env python3 # %% for atcoder uniittest use import sys input = lambda: sys.stdin.readline().rstrip() def pin(type=int): return map(type, input().split()) def tupin(t=int): return tuple(pin(t)) def lispin(t=int): return list(pin(t)) # %%code def resolve(): N, M = pin() # NofKen,MofSi PY = [[] for i in range(N)] for m in range(M): p, y = pin() PY[p - 1].append([y, m]) # print(PY) ANS = [] for i in range(N): PY[i].sort(key=lambda x: x[0]) for n, py in enumerate(PY[i]): py[0] = n + 1 ANS.append([i + 1] + py) # print(ANS) ANS.sort(key=lambda x: x[2]) # print(ANS) PY = ANS for k in range(M): x, y, z = PY[k] X, Y = str(x), str(y) t, s = 6 - len(X), 6 - len(Y) if t > 0: X = "0" * t + X if s > 0: Y = "0" * t + Y print(X + Y) # %%submit! resolve()
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s164335186
Wrong Answer
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
import sys, re from math import ceil, floor, sqrt, pi, factorial, gcd from copy import deepcopy from collections import Counter, deque from heapq import heapify, heappop, heappush from itertools import accumulate, product, combinations, combinations_with_replacement from bisect import bisect, bisect_left from functools import reduce from decimal import Decimal, getcontext # input = sys.stdin.readline def i_input(): return int(input()) def i_map(): return map(int, input().split()) def i_list(): return list(i_map()) def i_row(N): return [i_input() for _ in range(N)] def i_row_list(N): return [i_list() for _ in range(N)] def s_input(): return input() def s_map(): return input().split() def s_list(): return list(s_map()) def s_row(N): return [s_input for _ in range(N)] def s_row_list(N): return [s_list() for _ in range(N)] def Yes(): print("Yes") def No(): print("No") def YES(): print("YES") def NO(): print("NO") def lcm(a, b): return a * b // gcd(a, b) sys.setrecursionlimit(10**6) INF = float("inf") MOD = 10**9 + 7 num_list = [] str_list = [] def main(): n, m = i_map() for i in range(m): p, y = i_map() num_list.append([p, y, i]) sorted_data = sorted(num_list, key=lambda x: x[0]) sorted_data = sorted(sorted_data, key=lambda x: x[1]) ans_list = [] count_index = 0 for num in sorted_data: if count_index != num[0]: count_index = num[0] count_num = 1 else: count_num += 1 ans_num = str(num[0]).zfill(6) + str(count_num).zfill(6) ans_list.append([num[2], ans_num]) ans_list.sort() for ans in ans_list: print(ans[1]) if __name__ == "__main__": main()
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s330138005
Accepted
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
n, m = list(map(int, input().split())) PY = [list(map(int, input().split())) for _ in range(m)] id = [[] for _ in range(n)] for a, b in PY: id[a - 1].append(b) for v in id: v.sort() d = {} for i in range(n): k = 1 for j in range(len(id[i])): d[id[i][j]] = k k += 1 for i, j in PY: print("{:06g}{:06g}".format(i, d[j]))
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s255319742
Accepted
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
N, M = [int(a) for a in input().strip().split()] P = [] Y = [] prefs = {} YtoIdx = {} results = ["" for i in range(0, M)] for i in range(0, M): pk, yk = [int(a) for a in input().strip().split()] if not pk in prefs: prefs[pk] = [] prefs[pk].append(yk) P.append(pk) Y.append(yk) YtoIdx[yk] = i for p in prefs.keys(): prefs[p].sort() for i, y in enumerate(prefs[p]): pre = str(p).zfill(6) suf = str(i + 1).zfill(6) results[YtoIdx[y]] = pre + suf for res in results: print(res)
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s271729482
Accepted
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
if __name__ == "__main__": _, m = map(int, input().split()) pres = [[i] + [int(s) for s in input().split()] for i in range(m)] pres.sort(key=lambda t: t[2]) count = dict((p, 1) for _, p, _ in pres) prev_y = 0 addrs = [] for i, p, _ in pres: addrs.append((i, p * 1000000 + count[p])) count[p] += 1 addrs.sort(key=lambda t: t[0]) for _, a in addrs: print("%012d" % a)
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s534714811
Wrong Answer
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
N, M = [int(nm) for nm in input().split()] PY = [] for m in range(M): PY.append([int(py) for py in input().split()]) PY.sort() i = 1 print("0" * (6 - len(str(PY[0][0]))) + str(PY[0][0]) + "0" * (6 - len(str(i))) + str(i)) for m in range(1, M): if PY[m - 1][0] == PY[m][0]: print( "0" * (6 - len(str(PY[m][0]))) + str(PY[m][0]) + "0" * (6 - len(str(i + 1))) + str(i + 1) ) else: i = 1 print( "0" * (6 - len(str(PY[m][0]))) + str(PY[m][0]) + "0" * (6 - len(str(i))) + str(i) )
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s535956049
Wrong Answer
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
n, m = map(int, input().split()) a = [0] * (n) b = [list(map(int, input().split())) + [i] + [0] for i in range(m)] b.sort(key=lambda x: x[1]) for i, (v, x, y, z) in enumerate(b): a[v - 1] += 1 b[i][3] = a[v - 1] b.sort(key=lambda x: x[2]) for v, x, y, z in b: print("{0:06d}{0:06d}".format(v, z))
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). * * *
s534965515
Accepted
p03221
Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M
N, M = map(int, input().split()) # N個の県, M個の市 city_info = [] for i in range(M): # M個の市の情報 p, y = map(int, input().split()) # どこの県に属するかの情報p, 誕生した年y city_info.append( [i + 1, p, y, -1] ) # 市のインデックス, 属する県, 誕生した年, 何番目に誕生した city_info = sorted(city_info, key=lambda x: (x[1], x[2])) # 属する県でソート # print(city_info) now_pref = city_info[0][1] tmp = 0 for i in range(M): if city_info[i][1] == now_pref: tmp += 1 city_info[i][3] = tmp else: tmp = 1 city_info[i][3] = tmp now_pref = city_info[i][1] city_info = sorted(city_info, key=lambda x: x[0]) # print(city_info) for i in range(M): str_p = str(city_info[i][1]) str_zyunban = str(city_info[i][3]) lack_p = 6 - len(str_p) str_p = "0" * lack_p + str_p lack_zyunban = 6 - len(str_zyunban) str_zyunban = "0" * lack_zyunban + str_zyunban print(str_p + str_zyunban)
Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
[{"input": "2 3\n 1 32\n 2 63\n 1 12", "output": "000001000002\n 000002000001\n 000001000001\n \n\n * As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n * As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n * As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\n* * *"}, {"input": "2 3\n 2 55\n 2 77\n 2 99", "output": "000002000001\n 000002000002\n 000002000003"}]
Print the minimum total price of two different bells. * * *
s856862581
Accepted
p03671
Input is given from Standard Input in the following format: a b c
import itertools N_List = list(map(int, input().split())) a = sum(N_List) for v in itertools.combinations(N_List, 2): if a >= sum(v): a = sum(v) print(a)
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s952769729
Accepted
p03671
Input is given from Standard Input in the following format: a b c
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from fractions import gcd def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) INF = float("inf") mod = 10**9 + 7 l = LIST() comb = list(combinations(l, 2)) m_l = [] for c in comb: m_l.append(sum(c)) ans = min(m_l) print(ans)
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s727427496
Runtime Error
p03671
Input is given from Standard Input in the following format: a b c
a, b, c = map(int, input().split()) def answer(a: int, b: int, c: int) -> int: return min(a + b, a + c, b + c) print(answer(a, b, c)
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s830576766
Runtime Error
p03671
Input is given from Standard Input in the following format: a b c
#!/usr/bin/env python3 import sys # import time # import math # import numpy as np # import scipy.sparse.csgraph as cs # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall # import random # random, uniform, randint, randrange, shuffle, sample # import string # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits # import re # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s) # from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]). # from collections import deque # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate() # from collections import defaultdict # subclass of dict. defaultdict(facroty) # from collections import Counter # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter) # from datetime import date, datetime # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj # from datetime.datetime import strptime # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj # from datetime import timedelta # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available. # from copy import copy, deepcopy # use deepcopy to copy multi-dimentional matrix without reference # from functools import reduce # reduce(f, iter[, init]) # from functools import lru_cache # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed) # from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn). # from heapq import nlargest, nsmallest # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn). # from itertools import count, cycle, repeat # count(start[,step]), cycle(iter), repeat(elm[,n]) # from itertools import groupby # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])] # from itertools import starmap # starmap(pow, [[2,5], [3,2]]) returns [32, 9] # from itertools import product, permutations # product(iter, repeat=n), permutations(iter[,r]) # from itertools import combinations, combinations_with_replacement # from itertools import accumulate # accumulate(iter[, f]) # from operator import itemgetter # itemgetter(1), itemgetter('key') # from fractions import gcd # for Python 3.4 (previous contest @AtCoder) def main(): mod = 1000000007 # 10^9+7 inf = float("inf") # sys.float_info.max = 1.79...e+308 # inf = 2 ** 64 - 1 # (for fast JIT compile in PyPy) 1.84...e+19 sys.setrecursionlimit(10**6) # 1000 -> 1000000 def input(): return sys.stdin.readline().rstrip() def ii(): return int(input()) def mi(): return map(int, input().split()) def mi_0(): return map(lambda x: int(x) - 1, input().split()) def lmi(): return list(map(int, input().split())) def lmi_0(): return list(map(lambda x: int(x) - 1, input().split())) def li(): return list(input()) def find_duplicate(L): n = len(L) table = [None] * n for i, num in enumerate(L): if table[num] is not None: return table[num], i else: table[num] = i def make_factorial_table(size, mod): """ fact_mod[i] は i! % mod を表す。fact_mod[0] ~ facto_mod[size] まで計算可能なテーブルを返す >>> make_factorial_table(20, 10**9+7) [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 227020758, 178290591, 674358851, 789741546, 425606191, 660911389, 557316307, 146326063] """ fact_mod = [1] * (size + 1) for i in range(1, size + 1): fact_mod[i] = (fact_mod[i - 1] * i) % mod return fact_mod def combination(n, r, mod, fact_table): """ フェルマーの小定理 a ^ p-1 ≡ 1 (mod p) a ^ p-2 ≡ 1/a (mod p) (逆元) nCr = (n!) / ((n-r)! * r!) だが、mod p の世界ではこの分母を逆元を用いて計算しておくことが可能 >>> m = 1000000007 >>> fact_table = make_factorial_table(100, m) >>> combination(10, 5, m, fact_table) 252 >>> combination(100, 50, m, fact_table) 538992043 """ if r > n: return 0 numerator = fact_table[n] denominator = (fact_table[n - r] * fact_table[r]) % mod # pow はすでに繰り返し二乗法で効率的に実装されている return (numerator * pow(denominator, mod - 2, mod)) % mod n = ii() L = lmi_0() i, j = find_duplicate(L) fact = make_factorial_table(n + 1, mod) for l in range(1, n + 2): print( ( combination(n + 1, l, mod, fact) - combination(i + n - j, l - 1, mod, fact) ) % mod ) if __name__ == "__main__": main()
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s413808553
Accepted
p03671
Input is given from Standard Input in the following format: a b c
rp = list(map(int, input().split())) print(min([sum(rp) - x for x in rp]))
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s177484531
Accepted
p03671
Input is given from Standard Input in the following format: a b c
apple = sorted(list(map(int, input().split()))) print(apple[0] + apple[1])
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s402059294
Accepted
p03671
Input is given from Standard Input in the following format: a b c
li = a, b, c = list(map(int, input().split())) print(sorted(li)[0] + sorted(li)[1])
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s627710229
Accepted
p03671
Input is given from Standard Input in the following format: a b c
Prices = sorted(list(map(int, input().split()))) print(Prices[0] + Prices[1])
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s607207312
Accepted
p03671
Input is given from Standard Input in the following format: a b c
X = list(map(int, input().split())) xs = sorted(X) print(xs[0] + xs[1])
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s331808768
Runtime Error
p03671
Input is given from Standard Input in the following format: a b c
ary = list(map(lambda n: int(n), input().split(" "))).sort() print(ary[0] + ary[1])
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s990046155
Accepted
p03671
Input is given from Standard Input in the following format: a b c
D = list(map(int, input().split())) D.sort() print(D[0] + D[1])
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s323212143
Runtime Error
p03671
Input is given from Standard Input in the following format: a b c
print(sum(sorted(list(map(int, intput().split())))[0:2]))
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s284327405
Runtime Error
p03671
Input is given from Standard Input in the following format: a b c
a,b,c=map(int,input().split()) print(min(a+b, b+c, c+a)
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s034940485
Runtime Error
p03671
Input is given from Standard Input in the following format: a b c
a, b, c = map(int, input(), split()) print(min([a + b, b + c, c + a]))
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s146253875
Runtime Error
p03671
Input is given from Standard Input in the following format: a b c
!pip install numpy
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s729058677
Runtime Error
p03671
Input is given from Standard Input in the following format: a b c
print(sum(sorted(list(map(int,input().split()))[:2]))
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s489230696
Accepted
p03671
Input is given from Standard Input in the following format: a b c
M = list(map(int, input().split())) M.sort() print(M[0] + M[1])
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s401231181
Accepted
p03671
Input is given from Standard Input in the following format: a b c
# -*- coding: utf-8 -*- a = input().split() min_data = None for i in range(len(a)): for j in range(len(a)): if i == j: pass elif min_data is None: min_data = int(a[i]) + int(a[j]) else: min_data = min(min_data, int(a[i]) + int(a[j])) print(min_data)
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s383526801
Runtime Error
p03671
Input is given from Standard Input in the following format: a b c
b = 10**9 + 7 num = [-1] * (n + 1) temp = 1 temp2 = 1 for i in range(len(a)): if num[a[i]] != -1: p1, p2 = num[a[i]], i num[a[i]] = i for k in range(1, len(a) + 1): if k == 1: print(n) elif k == len(a): print(1) else: for l in range(k): temp = temp * (n + 1 - l) / (k - l) if k - l - 1 > 0: temp2 = temp2 * (n - p2 + p1 - l) / (k - l - 1) print(int((temp - temp2) % b)) temp = 1 temp2 = 1
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s708043372
Accepted
p03671
Input is given from Standard Input in the following format: a b c
p = sorted(list(map(int, input().split()))) print(sum(p[:2]))
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s866127830
Accepted
p03671
Input is given from Standard Input in the following format: a b c
item_l = list(map(int, input().split())) item_l = sorted(item_l) sum = item_l[0] + item_l[1] print(sum)
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s852922020
Accepted
p03671
Input is given from Standard Input in the following format: a b c
numbers = list(map(int, input().split())) num = [] num.append(numbers[0] + numbers[1]) num.append(numbers[0] + numbers[2]) num.append(numbers[1] + numbers[2]) print(min(num))
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s469212980
Wrong Answer
p03671
Input is given from Standard Input in the following format: a b c
x, y, z = map(int, input().split()) if (x + y) <= (x + z) and (x + y) <= (y + z): print(x + y) if (x + z) <= (x + y) and (x + z) <= (y + z): print(x + z) if (y + z) <= (x + y) and (y + z) <= (x + z): print(y + z)
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s707548566
Accepted
p03671
Input is given from Standard Input in the following format: a b c
num = [int(x) for x in input().split()] num = sorted(num) print(num[0] + num[1])
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s362097140
Accepted
p03671
Input is given from Standard Input in the following format: a b c
bell_list = [int(v) for v in input().split()] print(sum(bell_list) - max(bell_list))
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s993213312
Accepted
p03671
Input is given from Standard Input in the following format: a b c
arr = list(map(int, input().split(" "))) arr.sort() print(arr[0] + arr[1])
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s329178107
Accepted
p03671
Input is given from Standard Input in the following format: a b c
prices = sorted(list(map(int, input().split()))) print(sum(prices[:2:]))
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s864156603
Accepted
p03671
Input is given from Standard Input in the following format: a b c
value = list(map(int, input().split())) value.sort() print(value[0] + value[1])
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s245414861
Accepted
p03671
Input is given from Standard Input in the following format: a b c
a, b, c = [int(x) for x in input().strip().split()] print(min([a + b, b + c, a + c]))
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s751610947
Wrong Answer
p03671
Input is given from Standard Input in the following format: a b c
inp = list(input().split()) inp.sort() print(int(inp[0]) + int(inp[1]))
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s981216749
Wrong Answer
p03671
Input is given from Standard Input in the following format: a b c
lst = sorted(list(map(int, input().split()))) print(sum(lst[::2]))
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s483829211
Wrong Answer
p03671
Input is given from Standard Input in the following format: a b c
a = list(sorted(list(map(int, input().split())))) print(a[-1] + a[-2])
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s906003831
Runtime Error
p03671
Input is given from Standard Input in the following format: a b c
a,b,c = sorted(map(in,input().split())) print(a+b)
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s978149079
Accepted
p03671
Input is given from Standard Input in the following format: a b c
print(sum(sorted([int(x) for x in input().split()])[:2]))
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
Print the minimum total price of two different bells. * * *
s624156006
Wrong Answer
p03671
Input is given from Standard Input in the following format: a b c
x = sorted(input().split()) print(int(x[0]) + int(x[1]))
Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]