wrong_submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
user_id
stringlengths
10
10
time_limit
float64
1k
8k
memory_limit
float64
131k
1.05M
wrong_status
stringclasses
2 values
wrong_cpu_time
float64
10
40k
wrong_memory
float64
2.94k
3.37M
wrong_code_size
int64
1
15.5k
problem_description
stringlengths
1
4.75k
wrong_code
stringlengths
1
6.92k
acc_submission_id
stringlengths
10
10
acc_status
stringclasses
1 value
acc_cpu_time
float64
10
27.8k
acc_memory
float64
2.94k
960k
acc_code_size
int64
19
14.9k
acc_code
stringlengths
19
14.9k
s265884167
p03477
u923712635
2,000
262,144
Wrong Answer
17
3,060
135
A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R. Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and placed a mass of weight C and a mass of weight D on the right pan. Print `Left` if the balance scale tips to the left; print `Balanced` if it balances; print `Right` if it tips to the right.
A,B,C,D = [int(x) for x in input().split()] if(A+B < C+D): print('Left') elif(A+B == C+D): print('Balanced') else: print('Right')
s940065797
Accepted
17
3,060
132
A,B,C,D = [int(x) for x in input().split()] if(A+B > C+D): print('Left') elif(A+B == C+D): print('Balanced') else: print('Right')
s314075540
p02393
u372785464
1,000
131,072
Wrong Answer
20
7,500
62
Write a program which reads three integers, and prints them in ascending order.
x=list(map(int, input().split())) x.sort print(x[0],x[1],x[2])
s325459674
Accepted
20
7,664
64
x=list(map(int, input().split())) x.sort() print(x[0],x[1],x[2])
s053613899
p03048
u402629484
2,000
1,048,576
Wrong Answer
433
302,364
182
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes. How many triples of non-negative integers (r,g,b) achieve this?
R, G, B, N = map(int, input().split()) import numpy as np r = np.arange(0, N, R) g = np.arange(0, N, G) r, g = np.meshgrid(r, g) b = N - r - g print(np.sum(((b%B)==0) & (b>=0)))
s072996342
Accepted
434
302,500
218
R, G, B, N = map(int, input().split()) import numpy as np r = np.arange(0, N+1, R, dtype=np.int64) g = np.arange(0, N+1, G, dtype=np.int64) r, g = np.meshgrid(r, g) b = N - r - g print(np.sum(((b%B)==0) & (b>=0)))
s566039756
p03997
u814886720
2,000
262,144
Wrong Answer
26
8,964
62
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
a=int(input()) b=int(input()) h=int(input()) print((a+b)*h/2)
s688178578
Accepted
26
9,016
72
a=int(input()) b=int(input()) h=int(input()) c=(a+b)*h/2 print(int(c))
s367123107
p03408
u697696097
2,000
262,144
Wrong Answer
22
3,316
178
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen. Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.) At most how much can he earn on balance? Note that the same string may be written on multiple cards.
from collections import defaultdict d = defaultdict(int) n=int(input()) for _ in range(n): d[input()]+=1 n=int(input()) for _ in range(n): d[input()]-=1 print(d[max(d)])
s362060678
Accepted
21
3,316
193
from collections import defaultdict d = defaultdict(int) d["D"]=0 n=int(input()) for _ in range(n): d[input()]+=1 n=int(input()) for _ in range(n): d[input()]-=1 print(max(d.values()))
s669996075
p03671
u241231786
2,000
262,144
Wrong Answer
18
2,940
161
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.
lines = input().split() a = int(lines[0]) b = int(lines[1]) c = int(lines[2]) sum1 = a+b sum2 = a+c sum3 = b+c sum_list = [sum1, sum2,sum3] print(max(sum_list))
s224732579
Accepted
17
2,940
131
lines = list(input().split()) a = int(lines[0]) b = int(lines[1]) c = int(lines[2]) sum_list = [a+b, a+c, b+c] print(min(sum_list))
s632655530
p03777
u670180528
2,000
262,144
Wrong Answer
17
2,940
33
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or Dishonest_. In this game, an honest player always tells the truth, and an dishonest player always tell lies. You are given two characters a and b as the input. Each of them is either `H` or `D`, and carries the following information: If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`, AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that TopCoDeer is dishonest. Given this information, determine whether TopCoDeer is honest.
a=input();print("DH"[a[0]==a[1]])
s851106723
Accepted
17
2,940
33
a=input();print("DH"[a[0]==a[2]])
s621357756
p02972
u288500561
2,000
1,048,576
Wrong Answer
2,108
17,412
648
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
# coding: utf-8 # Your code here! import numpy as np N = int(input()) A = list(map(int,input().split())) B = A ct = 0 for i in range(N): j = N-i-1 if(j+1>N/2): B[j] = A[j] if(B[j]==1): ct = ct + 1 else: for k in range(j+1,N): sum = 0 if(k%(j+1)==0 and k!=j): sum = sum + B[k]; if(sum%2==0): B[j] = A[j] if(B[j]==1): ct = ct + 1 else: B[j] = 1 - A[j] if(B[j]==1): ct = ct + 1 print(ct) C = [] for i in range(N): if(B[i]==1): C.append(i) print(*C)
s511249081
Accepted
1,450
21,676
703
# coding: utf-8 # Your code here! import numpy as np N = int(input()) A = list(map(int,input().split())) B = A ct = 0 for i in range(N): j = N-i-1 if(j+1>N/2): B[j] = A[j] if(B[j]==1): ct = ct + 1 else: sum = 0 for k in range(j+1,N+1,j+1): if(k%(j+1)==0 and k!=j+1): sum = sum + B[k-1] if(sum%2==0): B[j] = A[j] if(B[j]==1): ct = ct + 1 else: B[j] = 1 - A[j] if(B[j]==1): ct = ct + 1 print(ct) C = [] for i in range(N): if(B[i]==1): C.append(i+1) print(*C)
s530284352
p03578
u153147777
2,000
262,144
Wrong Answer
286
55,264
255
Rng is preparing a problem set for a qualification round of CODEFESTIVAL. He has N candidates of problems. The difficulty of the i-th candidate is D_i. There must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems. Determine whether Rng can complete the problem set without creating new candidates of problems.
import sys from collections import Counter N = int(input()) D = Counter([int(c) for c in input().split()]) M = int(input()) T = Counter([int(c) for c in input().split()]) for t in T.items(): if D[t[0]] < t[1]: print('No') sys.exit() print('Yes')
s739788645
Accepted
280
55,264
255
import sys from collections import Counter N = int(input()) D = Counter([int(c) for c in input().split()]) M = int(input()) T = Counter([int(c) for c in input().split()]) for t in T.items(): if D[t[0]] < t[1]: print('NO') sys.exit() print('YES')
s807360134
p04029
u942871960
2,000
262,144
Wrong Answer
17
2,940
67
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
a = input() sum = 0 for i in range(int(a)): sum += i print(a)
s218803381
Accepted
19
2,940
73
a = input() sum = 0 for i in range(int(a)): sum += i + 1 print(sum)
s940691104
p03193
u823885866
2,000
1,048,576
Wrong Answer
118
27,232
566
There are N rectangular plate materials made of special metal called AtCoder Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically and B_i horizontally). Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are exactly H \times W. He is trying to obtain such a plate by choosing one of the N materials and cutting it if necessary. When cutting a material, the cuts must be parallel to one of the sides of the material. Also, the materials have fixed directions and cannot be rotated. For example, a 5 \times 3 material cannot be used as a 3 \times 5 plate. Out of the N materials, how many can produce an H \times W plate if properly cut?
import sys import math import itertools import collections import heapq import re import numpy as np from functools import reduce rr = lambda: sys.stdin.readline().rstrip() rs = lambda: sys.stdin.readline().split() ri = lambda: int(sys.stdin.readline()) rm = lambda: map(int, sys.stdin.readline().split()) rf = lambda: map(float, sys.stdin.readline().split()) rl = lambda: list(map(int, sys.stdin.readline().split())) inf = float('inf') mod = 10**9 + 7 n, h, w = rm() cnt = 0 for _ in range(n): a, b = rm() if a <= h and b <= w: cnt += 1 print(cnt)
s362362234
Accepted
116
27,248
566
import sys import math import itertools import collections import heapq import re import numpy as np from functools import reduce rr = lambda: sys.stdin.readline().rstrip() rs = lambda: sys.stdin.readline().split() ri = lambda: int(sys.stdin.readline()) rm = lambda: map(int, sys.stdin.readline().split()) rf = lambda: map(float, sys.stdin.readline().split()) rl = lambda: list(map(int, sys.stdin.readline().split())) inf = float('inf') mod = 10**9 + 7 n, h, w = rm() cnt = 0 for _ in range(n): a, b = rm() if a >= h and b >= w: cnt += 1 print(cnt)
s231055442
p00005
u424041287
1,000
131,072
Wrong Answer
30
7,768
205
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b.
t = 0 while t == 0: try: x,y=[int(i) for i in input().split()] except: break else: a = x * y if x < y: x,y =y,x while y > 0: r = x % y x = y y = r print(str(x) + " " + str(a/x))
s912796776
Accepted
20
7,608
211
t = 0 while t == 0: try: x,y=[int(i) for i in input().split()] except: break else: a = x * y if x < y: x,y =y,x while y > 0: r = x % y x = y y = r print(str(x) + " " + str(int(a / x)))
s793668301
p02842
u276841801
2,000
1,048,576
Wrong Answer
18
3,060
184
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer). Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer. If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.
# -*- coding: utf-8 -*- N = int(input()) X = int(N // 1.08) a = N*100 % 108 x = X+1 if a == 0: print(X) elif x*1.08 >= N and x*1.08 < N+1: print(x) else: print(":(")
s732176097
Accepted
17
3,060
231
# -*- coding: utf-8 -*- N = int(input()) X = int(N // 1.08) a = N*100 % 108 x = X+1 if a == 0: print(x) elif x*1.08 >= N and x*1.08 < N+1: print(x) elif X*1.08 >= N and X*1.08 < N+1: print(X) else: print(":(")
s109516135
p03555
u551109821
2,000
262,144
Wrong Answer
17
2,940
117
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
c1 = list(input()) c2 = list(input()) if c1[0] == c2[-1] and c1[-1] == c2[0]: print('Yes') else: print('No')
s302323207
Accepted
18
2,940
103
c1 = list(input()) c2 = list(input()) c1.reverse() if c1 == c2: print('YES') else: print('NO')
s654450865
p03435
u396890425
2,000
262,144
Wrong Answer
18
3,064
327
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j. Determine if he is correct.
N = [[int(i) for i in input().split()] for j in range(3)] if N[0][0]-N[0][1]==N[0][1]-N[0][2] and N[1][0]-N[1][1]==N[1][1]-N[1][2] and N[2][0]-N[2][1]==N[2][1]-N[2][2] and N[0][0]-N[1][0]==N[1][0]-N[2][0] and N[0][1]-N[1][1]==N[1][1]-N[2][1] and N[0][2]-N[1][2]==N[1][2]-N[2][2]: print('Yes') else: print('No')
s321988779
Accepted
18
3,064
321
N = [[int(i) for i in input().split()] for j in range(3)] if N[0][0]-N[0][1]==N[1][0]-N[1][1]==N[2][0]-N[2][1] and N[0][1]-N[0][2]==N[1][1]-N[1][2]==N[2][1]-N[2][2] and N[0][0]-N[1][0]==N[0][1]-N[1][1]==N[0][2]-N[1][2] and N[1][0]-N[2][0]==N[1][1]-N[2][1]==N[1][2]-N[2][2]: print('Yes') else: print('No')
s755535913
p03860
u320763652
2,000
262,144
Wrong Answer
18
2,940
55
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
a, b, c = input().split() print("A" + b.upper() + "C")
s225088120
Accepted
17
2,940
58
a, b, c = input().split() print("A" + b[0].upper() + "C")
s268517856
p03761
u228223940
2,000
262,144
Wrong Answer
27
3,064
520
Snuke loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string. He will receive a headline which contains one of the strings S_1,...,S_n tomorrow. He is excited and already thinking of what string he will create. Since he does not know the string on the headline yet, he is interested in strings that can be created regardless of which string the headline contains. Find the longest string that can be created regardless of which string among S_1,...,S_n the headline contains. If there are multiple such strings, find the lexicographically smallest one among them.
n = int(input()) s = [input() for i in range(n)] sort_s = [] for i in range(n): sort_s.append(sorted(s[i])) onaji = sort_s[0] new = [] tmp = 0 for i in range(1,n): for j in range(len(onaji)): for k in range(len(s[i])): if tmp+k >= len(s[i]): break if onaji[j] == sort_s[i][tmp+k]: new.append(onaji[j]) tmp = k break onaji = new new = [] print(*onaji)
s295753273
Accepted
20
3,064
580
n = int(input()) s = [input() for i in range(n)] sort_s = [] for i in range(n): sort_s.append(sorted(s[i])) onaji = sort_s[0] new = [] tmp = 0 for i in range(1,n): new = [] tmp = 0 for j in range(len(onaji)): for k in range(len(s[i])): if tmp+k >= len(s[i]): break if onaji[j] == sort_s[i][tmp+k]: new.append(onaji[j]) tmp = tmp+k+1 break #tmp = 0 onaji = new #new = [] print(*onaji,sep="")
s794941476
p03525
u223663729
2,000
262,144
Wrong Answer
27
3,444
1,006
In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi checked and found that the _time gap_ (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example. Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours. Find the maximum possible value of s.
# CODE FESTIVAL 2017 Final # C - Time Gap from collections import Counter N = int(input()) *A, = map(int, input().split()) INF = 1 << 30 C = Counter(A) if N >= 24 or 0 in C: print(0) exit() dt = [] nt = [] for k, v in C.items(): if v > 2: print(0) exit() if v == 2: dt.append(k) dt.append(24-k) if v == 1: nt.append(k) tmp = INF for i, t in enumerate(dt): for s in dt[i+1:]: if abs(t-s) < tmp: tmp = abs(t-s) ans = tmp M = len(nt) for bit in range(1 << M): D = [0]*M for i in range(M): if bit >> i & 1: D[i] = nt[i] else: D[i] = 24-nt[i] mn = tmp for j, d in enumerate(D): for e in D[j+1:]: if abs(d-e) < mn: mn = abs(d-e) for t in dt: if abs(d-t) < mn: mn = abs(d-t) if mn != INF and mn > ans: ans = mn print(ans)
s829948426
Accepted
26
3,316
1,101
# CODE FESTIVAL 2017 Final # C - Time Gap from collections import Counter N = int(input()) *A, = map(int, input().split()) INF = 1 << 30 C = Counter(A) if N >= 24 or 0 in C: print(0) exit() dt = [] nt = [] for k, v in C.items(): if v > 2: print(0) exit() if v == 2: dt.append(k) dt.append(24-k) if v == 1: nt.append(k) tmp = min(A) for i, t in enumerate(dt): for s in dt[i+1:]: if abs(t-s) < tmp: tmp = abs(t-s) ans = 0 M = len(nt) if M: for bit in range(1 << M): D = [0]*M for i in range(M): if bit >> i & 1: D[i] = nt[i] else: D[i] = 24-nt[i] mn = tmp for j, d in enumerate(D): for e in D[j+1:]: if abs(d-e) < mn: mn = abs(d-e) for t in dt: if abs(d-t) < mn: mn = abs(d-t) if mn != INF and mn > ans: ans = mn else: ans = tmp print(ans)
s041759543
p02612
u758815106
2,000
1,048,576
Wrong Answer
29
9,140
29
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
N=int(input()) print(N%1000)
s876621423
Accepted
28
9,148
77
N=int(input()) if N % 1000 == 0: print(0) else: print(1000 - N%1000)
s480101659
p03351
u819910751
2,000
1,048,576
Wrong Answer
29
9,060
154
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
a, b, c, d = map(int, input().split()) if c-a < d: print('Yes') else: if b-a < d and c-b < d: print('Yes') else: print('No')
s572149116
Accepted
26
9,056
172
a, b, c, d = map(int, input().split()) if abs(c-a) <= d: print('Yes') else: if abs(b-a) <= d and abs(c-b) <= d: print('Yes') else: print('No')
s325846449
p02843
u629607744
2,000
1,048,576
Wrong Answer
28
9,144
61
AtCoder Mart sells 1000000 of each of the six items below: * Riceballs, priced at 100 yen (the currency of Japan) each * Sandwiches, priced at 101 yen each * Cookies, priced at 102 yen each * Cakes, priced at 103 yen each * Candies, priced at 104 yen each * Computers, priced at 105 yen each Takahashi wants to buy some of them that cost exactly X yen in total. Determine whether this is possible. (Ignore consumption tax.)
x = int(input()) if x//100 < x%100: print(0) else: print(1)
s746215419
Accepted
28
9,100
63
x = int(input()) if x//100*5 < x%100: print(0) else: print(1)
s664131508
p03911
u476604182
2,000
262,144
Wrong Answer
635
12,952
825
On a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M. For _CODE FESTIVAL 20XX_ held on this planet, N participants gathered from all over the planet. The i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}. Two participants A and B can _communicate_ with each other if and only if one of the following conditions is satisfied: * There exists a language that both A and B can speak. * There exists a participant X that both A and B can communicate with. Determine whether all N participants can communicate with all other participants.
class UnionFind: def __init__(self, n): self.par = [i for i in range(n)] self.rank = [0]*n 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 unit(self, x, y): x = self.find(x) y = self.find(y) if x==y: return elif self.rank[x]<self.rank[y]: self.par[x] = y return elif self.rank[y]<self.rank[x]: self.par[y] = x else: self.par[y] = x self.rank[x] += 1 def same(self, x, y): return self.find(x)==self.find(y) N,M = map(int, input().split()) u = UnionFind(N+M) for i in range(N): inf = list(map(int, input().split())) for l in inf[1:]: u.unit(i,N+l-1) ans = all(u.same(i,i+1) for i in range(N-1)) if ans: print('Yes') else: print('No')
s188502834
Accepted
644
12,948
825
class UnionFind: def __init__(self, n): self.par = [i for i in range(n)] self.rank = [0]*n 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 unit(self, x, y): x = self.find(x) y = self.find(y) if x==y: return elif self.rank[x]<self.rank[y]: self.par[x] = y return elif self.rank[y]<self.rank[x]: self.par[y] = x else: self.par[y] = x self.rank[x] += 1 def same(self, x, y): return self.find(x)==self.find(y) N,M = map(int, input().split()) u = UnionFind(N+M) for i in range(N): inf = list(map(int, input().split())) for l in inf[1:]: u.unit(i,N+l-1) ans = all(u.same(i,i+1) for i in range(N-1)) if ans: print('YES') else: print('NO')
s533656003
p02936
u350093546
2,000
1,048,576
Wrong Answer
2,207
84,864
363
Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i. Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0. Now, the following Q operations will be performed: * Operation j (1 \leq j \leq Q): Increment by x_j the counter on every vertex contained in the subtree rooted at Vertex p_j. Find the value of the counter on each vertex after all operations.
n,q=map(int,input().split()) tree=[list(map(int,input().split())) for i in range(n-1)] point=[list(map(int,input().split())) for i in range(q)] ans=['?']+[0]*n def dfs(x,y): ans[x]+=y for i in range(n-1): if tree[i][0]==x: dfs(tree[i][1],y) for i,j in point: dfs(i,j) ans2='' for i in range(1,n+1): ans2+=str(ans[i]) ans2+=' ' print(ans2)
s633524820
Accepted
1,222
71,208
460
n,q=map(int,input().split()) lst=[[] for i in range(n)] ans=[0]*n for i in range(n-1): a,b=map(int,input().split()) lst[a-1].append(b-1) lst[b-1].append(a-1) for i in range(q): s,t=map(int,input().split()) ans[s-1]+=t Q=[0] flag=[True]+[False]*(n-1) while Q: v=Q.pop() flag[v]=True for i in lst[v]: if flag[i]: continue flag[i]=True ans[i]+=ans[v] Q.append(i) print(' '.join([str(i) for i in ans]))
s577181668
p03730
u254086528
2,000
262,144
Wrong Answer
17
2,940
253
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
a,b,c = map(int,input().split()) res = [] i = 1 while True: r = (a * i) % b if r == c: print("Yes") break else: if r in res: print("No") break else: res.append(r) i += 1
s688500454
Accepted
17
2,940
253
a,b,c = map(int,input().split()) res = [] i = 1 while True: r = (a * i) % b if r == c: print("YES") break else: if r in res: print("NO") break else: res.append(r) i += 1
s753617657
p03050
u830054172
2,000
1,048,576
Wrong Answer
416
9,928
161
Snuke received a positive integer N from Takahashi. A positive integer m is called a _favorite number_ when the following condition is satisfied: * The quotient and remainder of N divided by m are equal, that is, \lfloor \frac{N}{m} \rfloor = N \bmod m holds. Find all favorite numbers and print the sum of those.
from math import sqrt N = int(input()) ans = 0 for i in range(1, int(sqrt(N))+1): print(i) if N%i == 0 and i < N//i-1: ans += N//i-1 print(ans)
s334655974
Accepted
140
9,124
163
from math import sqrt N = int(input()) ans = 0 for i in range(1, int(sqrt(N))+1): # print(i) if N%i == 0 and i < N//i-1: ans += N//i-1 print(ans)
s577693282
p03658
u969848070
2,000
262,144
Wrong Answer
27
9,000
95
Snuke has N sticks. The length of the i-th stick is l_i. Snuke is making a snake toy by joining K of the sticks together. The length of the toy is represented by the sum of the individual sticks that compose it. Find the maximum possible length of the toy.
n, k = map(int, input().split()) l = list(map(int, input().split())) l.sort() print(sum(l[:k]))
s409959080
Accepted
23
8,928
107
n, k = map(int, input().split()) l = list(map(int, input().split())) l.sort(reverse=True) print(sum(l[:k]))
s228155912
p03846
u218843509
2,000
262,144
Wrong Answer
2,104
13,812
825
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
import sys n = int(input()) a = list(map(int, input().split())) if n % 2 == 0: i = 1 while True: if i in a: a.remove(i) else: print(0) sys.exit() if i in a: a.remove(i) else: print(0) sys.exit() i += 2 if a == []: break print((2 ** (n / 2)) % (10 ** 9 + 7)) elif n == 1: if a == [0]: print("1") else: print("0") else: i = 2 while True: if i in a: a.remove(i) else: print(0) sys.exit() if i in a: a.remove(i) else: print(0) sys.exit() i += 2 if a == [0]: break print((2 ** ((n - 1) / 2)) % (10 ** 9 + 7))
s532403274
Accepted
92
14,008
574
n = int(input()) a = list(map(int, input().split())) def beki(n): ans = 1 for _ in range(int(n)): ans = (ans * 2) % (10 ** 9 + 7) return int(ans) if n % 2 == 0: hikaku = [] for i in range(1, n, 2): hikaku += [i, i] if sorted(a) == hikaku: print(beki(n / 2)) else: print(0) elif n == 1: if a == [0]: print(1) else: print(0) else: hikaku = [0] for i in range(2, n, 2): hikaku += [i, i] if sorted(a) == hikaku: print(beki((n - 1) / 2)) else: print(0)
s567155061
p03997
u123273712
2,000
262,144
Wrong Answer
16
2,940
56
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
a,b,h=[int(input()) for i in range(3)] print((a+b)*h/2)
s724449759
Accepted
17
2,940
61
a,b,h=[int(input()) for i in range(3)] print(int((a+b)*h/2))
s766585053
p03377
u878138257
2,000
262,144
Wrong Answer
17
2,940
79
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
a,b,c = map(int, input().split()) if c-a>=b: print("YES") else: print("NO")
s090724042
Accepted
20
3,064
89
a,b,c = map(int, input().split()) if a+b>=c and a<=c: print("YES") else: print("NO")
s968205305
p03409
u763968347
2,000
262,144
Wrong Answer
22
3,064
420
On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point. At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.
N = int(input()) R = [] B = [] for _ in range(N): R.append(list(map(int,input().split()))) for _ in range(N): B.append(list(map(int,input().split()))) count = 0 R = sorted(R,reverse=True) for r in R: d = N*4 for i,b in enumerate(B): if r[0]<b[0] and r[1]<b[1] and b[0]-r[0]+b[1]-r[1] < d: d = b[0]-r[0]+b[1]-r[1] b_num = i if d != N*4: count += 1 print(count)
s233603746
Accepted
20
3,064
412
N = int(input()) R = [] B = [] for _ in range(N): R.append(list(map(int,input().split()))) for _ in range(N): B.append(list(map(int,input().split()))) count = 0 B = sorted(B) for b in B: y_max = -1 for i,r in enumerate(R): if r[0]<b[0] and r[1]<b[1] and y_max < r[1]: y_max = r[1] r_num = i if y_max != -1: R.pop(r_num) count += 1 print(count)
s996028617
p03434
u077291787
2,000
262,144
Wrong Answer
17
3,060
233
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
# ABC088B - Card Game for Two import sys input = sys.stdin.readline n = int(input()) lst = sorted(list(map(int, input().rstrip().split())), reverse=True) print(sum(i for i in lst if i % 2 == 0) - sum(i for i in lst if i % 2 == 1))
s142790119
Accepted
17
2,940
200
# ABC088B - Card Game for Two def main(): N, *A = map(int, open(0).read().split()) A.sort(reverse=1) ans = sum(A[::2]) - sum(A[1::2]) print(ans) if __name__ == "__main__": main()
s753926484
p02678
u065578867
2,000
1,048,576
Wrong Answer
523
10,436
554
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
from collections import deque n, m = map(int, input().split()) ans_list = [0]*(n+1) class Node: def __init__(self, x): self.val = x self.adj = [] for i in range(m): a, b = map(int, input().split()) Node(a).adj.append(b) Node(b).adj.append(a) q = deque() q.append(Node(1).val) while len(q) > 0: node = q.popleft() if node is not None: for i in Node(node).adj: if ans_list[i] == 0: ans_list[i] = Node(node).val print('Yes') for j in range(2, n + 1): print(ans_list[j])
s522616460
Accepted
890
53,352
663
from collections import deque n, m = map(int, input().split()) ans_list = [0]*(n+1) class Node: def __init__(self, x): self.val = x self.adj = [] nodelist = [Node(0)] for i in range(1, n+1): nodelist.append(Node(i)) for i in range(m): a, b = map(int, input().split()) nodelist[a].adj.append(b) nodelist[b].adj.append(a) q = deque() q.append(nodelist[1]) while len(q) > 0: node = q.popleft() if node is not None: for i in node.adj: if ans_list[i] == 0: ans_list[i] = node.val q.append(nodelist[i]) print('Yes') for j in range(2, n + 1): print(ans_list[j])
s001365302
p03068
u702208001
2,000
1,048,576
Wrong Answer
17
2,940
92
You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`.
n = int(input()) s = input() m = int(input()) print(*['*' if x == s[m-1] else x for x in s])
s325844315
Accepted
17
2,940
100
n = int(input()) s = input() m = int(input()) print(*['*' if x != s[m-1] else x for x in s], sep='')
s234883056
p03610
u126232616
2,000
262,144
Wrong Answer
17
3,188
26
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
s = input() print(s[1::2])
s463651648
Accepted
17
3,188
26
s = input() print(s[0::2])
s266632565
p03433
u565737194
2,000
262,144
Wrong Answer
288
20,632
130
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
import numpy as np N = input(); A= input() A,N = int(A), int(N) if N % 500 <= A: print(N % 500); print('Yes') else: print('No')
s214874646
Accepted
172
14,428
118
import numpy as np N = input(); A= input() A,N = int(A), int(N) if N % 500 <= A: print('Yes') else: print('No')
s414345086
p03024
u816631826
2,000
1,048,576
Wrong Answer
17
2,940
158
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day. Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
record = input() wins = 0 for match in record: if(match == "o" or match =="O"): wins += 1 if(wins > 7): print("YES") else: print("NO")
s024682790
Accepted
17
2,940
208
record = input() wins = 0 for match in record: if(match == "o" or match =="O"): wins += 1 matchesPlayed = len(record) if(15 - matchesPlayed + wins > 7): print("YES") else: print("NO")
s634076550
p00728
u808582184
1,000
131,072
Wrong Answer
70
10,108
168
The International Clown and Pierrot Competition (ICPC), is one of the most distinguished and also the most popular events on earth in the show business. One of the unique features of this contest is the great number of judges that sometimes counts up to one hundred. The number of judges may differ from one contestant to another, because judges with any relationship whatsoever with a specific contestant are temporarily excluded for scoring his/her performance. Basically, scores given to a contestant's performance by the judges are averaged to decide his/her score. To avoid letting judges with eccentric viewpoints too much influence the score, the highest and the lowest scores are set aside in this calculation. If the same highest score is marked by two or more judges, only one of them is ignored. The same is with the lowest score. The average, which may contain fractions, are truncated down to obtain final score as an integer. You are asked to write a program that computes the scores of performances, given the scores of all the judges, to speed up the event to be suited for a TV program.
import statistics while True: n = int(input()) if n == 0: break s = [int(input()) for i in range(n)] ave = statistics.mean(s[1:-1]) print(int(ave))
s726373845
Accepted
60
10,040
176
import statistics while True: n = int(input()) if n == 0: break s = [int(input()) for i in range(n)] ave = statistics.mean(sorted(s)[1:-1]) print(int(ave))
s879198142
p02612
u019053283
2,000
1,048,576
Wrong Answer
34
9,112
43
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
a=int(input()) ans = a % 1000 print(ans)
s912664588
Accepted
33
9,148
91
a=int(input()) ans = a % 1000 if ans != 0: print(1000-ans) else: print(ans)
s558031727
p02406
u462831976
1,000
131,072
Wrong Answer
20
7,660
834
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto. Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements. void call(int n){ int i = 1; CHECK_NUM: int x = i; if ( x % 3 == 0 ){ cout << " " << i; goto END_CHECK_NUM; } INCLUDE3: if ( x % 10 == 3 ){ cout << " " << i; goto END_CHECK_NUM; } x /= 10; if ( x ) goto INCLUDE3; END_CHECK_NUM: if ( ++i <= n ) goto CHECK_NUM; cout << endl; }
# -*- coding: utf-8 -*- import sys import os """ void call(int n){ int i = 1; CHECK_NUM: int x = i; if ( x % 3 == 0 ){ cout << " " << i; goto END_CHECK_NUM; } INCLUDE3: if ( x % 10 == 3 ){ cout << " " << i; goto END_CHECK_NUM; } x /= 10; if ( x ) goto INCLUDE3; END_CHECK_NUM: if ( ++i <= n ) goto CHECK_NUM; cout << endl; } """ def call(n): i = 1 while i <= n: x = i if x % 3 == 0: print(" ", end='') print(i, end='') i += 1 else: while x > 0: if x % 10 == 3: print(" ", end='') print(i, end='') i += 1 break else: x //= 10 i += 1 n = int(input()) call(n)
s911532715
Accepted
30
8,284
744
# -*- coding: utf-8 -*- import sys import os """ void call(int n){ int i = 1; CHECK_NUM: int x = i; if ( x % 3 == 0 ){ cout << " " << i; goto END_CHECK_NUM; } INCLUDE3: if ( x % 10 == 3 ){ cout << " " << i; goto END_CHECK_NUM; } x /= 10; if ( x ) goto INCLUDE3; END_CHECK_NUM: if ( ++i <= n ) goto CHECK_NUM; cout << endl; } """ def include3(v): s = str(v) if '3' in s: return True else: return False def call(n): for i in range(1, n + 1): if i % 3 == 0: print(" ", end='') print(i, end='') else: if include3(i): print(" ", end='') print(i, end='') n = int(input()) call(n) print()
s411529234
p03779
u923659712
2,000
262,144
Wrong Answer
27
2,940
104
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.
x=int(input()) k=0 j=0 for i in range(x): if j<x: j+=i k+=1 else: print(k) exit()
s539355810
Accepted
28
3,060
187
x=int(input()) k=0 j=0 if x==1: print("1") exit() elif x==2: print("2") exit() else: for i in range(x): if j<x: j+=i k+=1 else: print(k-1) exit()
s123407186
p03448
u354953865
2,000
262,144
Wrong Answer
47
9,080
338
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
inputlist = [input() for i in range(4)] n = 0 A,B,C= inputlist[0],inputlist[1],inputlist[2] for i in range(int(A)+1): X = inputlist[3] X = int(X) - i*500 for j in range(int(B)+1): X = X - j*100 for k in range(int(C)+1): X = X -k*50 if X == 0: n += 1 print(n)
s953698657
Accepted
47
9,164
307
A,B,C,X = [int(input()) for i in range(4)] X_original = X n = 0 for i in range(int(A)+1): X = X_original X500 = X - i*500 for j in range(int(B)+1): X100 = X500 - j*100 for k in range(int(C)+1): X50 = X100-k*50 if X50== 0: n += 1 print(n)
s448178753
p03436
u020604402
2,000
262,144
Wrong Answer
25
3,436
1,076
We have an H \times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j). Snuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares. Before Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game. When the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares. The color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is `.`; if square (i, j) is initially painted by black, s_{i, j} is `#`.
H,W = map(int,input().split()) maze = [] for _ in range(H): l = list(input()) maze.append(l) import collections as col q = col.deque() q.append((0,0)) maze[0][0] = 0 def bfs(maze): while True: try: nowx,nowy = q.popleft() except IndexError: print("-1") quit() if nowx == (H - 1) and nowy == (W - 1): return for x in [1,-1]: if nowx + x == H or nowy == W: continue if maze[nowx + x][nowy] != '.' : continue if 0 <= nowx + x and nowx + x <= H - 1: q.append((nowx+x,nowy)) maze[nowx + x][nowy] = maze[nowx][nowy] + 1 for y in [1,-1]: if nowx == H or nowy + y== W: continue if maze[nowx][nowy + y] != '.' : continue if 0 <= nowy + y and nowy + y <= W - 1: q.append((nowx,nowy+y)) maze[nowx][nowy + y] = maze[nowx][nowy] + 1 bfs(maze) cnt = 0 for x in maze: for y in x: if y == '#': cnt += 1 print(H*W - maze[H-1][W-1] - cnt - 1) print(maze)
s403951656
Accepted
25
3,316
1,049
H,W = map(int,input().split()) maze = [] for _ in range(H): l = list(input()) maze.append(l) import collections as col q = col.deque() q.append((0,0)) maze[0][0] = 0 def bfs(maze): while True: if len(q) == 0: print("-1") quit() else: nowx,nowy = q.popleft() if nowx == (H - 1) and nowy == (W - 1): return for x in [1,-1]: if nowx + x == H or nowy == W or \ maze[nowx + x][nowy] != '.' : continue if 0 <= nowx + x and nowx + x <= H - 1: q.append((nowx+x,nowy)) maze[nowx + x][nowy] = maze[nowx][nowy] + 1 for y in [1,-1]: if nowx == H or nowy + y== W or \ maze[nowx][nowy + y] != '.' : continue if 0 <= nowy + y and nowy + y <= W - 1: q.append((nowx,nowy+y)) maze[nowx][nowy + y] = maze[nowx][nowy] + 1 bfs(maze) cnt = 0 for x in maze: for y in x: if y == '#': cnt += 1 print(H*W - maze[H-1][W-1] - cnt - 1)
s941611813
p03385
u465629938
2,000
262,144
Wrong Answer
17
2,940
118
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
s = input() if s.find('a') != -1 and s.find('b') != -1 and s.find('c') != -1: print("YES") else: print("NO")
s972672848
Accepted
18
2,940
118
s = input() if s.find('a') != -1 and s.find('b') != -1 and s.find('c') != -1: print("Yes") else: print("No")
s358987803
p03447
u141642872
2,000
262,144
Wrong Answer
17
2,940
78
You went shopping to buy cakes and donuts with X yen (the currency of Japan). First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop. How much do you have left after shopping?
X = int(input()) A = int(input()) B = int(input()) print(X - (X - A) // B * B)
s987298549
Accepted
17
2,940
66
X = int(input()) A = int(input()) B = int(input()) print((X-A)%B)
s745295154
p03095
u580697892
2,000
1,048,576
Wrong Answer
23
3,188
187
You are given a string S of length N. Among its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings. Here, a subsequence of a string is a concatenation of **one or more** characters from the string without changing the order.
#coding: utf-8 N = int(input()) S = input() mod = 1e9 + 7 alpha = list(map(chr,range(97,123))) ans = 1 for i in alpha: ans *= S.count(i) + 1 print(S.count(i)) print((ans-1) % mod)
s252695803
Accepted
20
3,188
177
#coding: utf-8 N = int(input()) S = input() mod = 1000000000 + 7 alpha = list(map(chr,range(97,123))) ans = 1 for i in alpha: ans *= S.count(i) + 1 print(int((ans-1) % mod))
s376871984
p02389
u099155265
1,000
131,072
Wrong Answer
20
7,584
108
Write a program which calculates the area and perimeter of a given rectangle.
# -*- coding:UTF-8 -*- num = input().split() print(int(num[0]) * int(num[1]), int(num[0])*2 + int(num[1]*2))
s239583456
Accepted
20
7,544
108
# -*- coding:UTF-8 -*- num = input().split() print(int(num[0]) * int(num[1]), int(num[0])*2 + int(num[1])*2)
s638629949
p03359
u348868667
2,000
262,144
Wrong Answer
17
2,940
74
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi. How many days from 2018-1-1 through 2018-a-b are Takahashi?
a,b = map(int,input().split()) if a < b: print(a) else: print(a-1)
s122636169
Accepted
17
2,940
75
a,b = map(int,input().split()) if a <= b: print(a) else: print(a-1)
s589236685
p03797
u736729525
2,000
262,144
Wrong Answer
17
2,940
337
Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped pieces. Find the maximum number of `Scc` groups that can be created when Snuke has N `S`-shaped pieces and M `c`-shaped pieces.
def solve(S, c): if S > c//2: return c//2 elif S == c//2: return c//2 if S < c//2: cnt = S c -= S * 2 S -= S assert S == 0 assert c > 0 return cnt + c//4 S, c = [int(x) for x in input().split()]
s034077720
Accepted
17
2,940
357
def solve(S, c): if S > c//2: return c//2 elif S == c//2: return c//2 if S < c//2: cnt = S c -= S * 2 S -= S assert S == 0 assert c > 0 return cnt + c//4 S, c = [int(x) for x in input().split()] print(solve(S, c))
s522375845
p02646
u345389118
2,000
1,048,576
Wrong Answer
22
9,164
150
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
A, V = map(int, input().split()) B, W = map(int, input().split()) T = int(input()) if V * T + A >= W * T + B: print('Yes') else: print('No')
s450233907
Accepted
21
8,856
199
A, V = map(int, input().split()) B, W = map(int, input().split()) T = int(input()) if V == W: print('NO') exit() if 0 <= (abs(B - A) / (V - W)) <= T: print('YES') else: print('NO')
s134164502
p02646
u018258333
2,000
1,048,576
Wrong Answer
22
9,180
132
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
a,v = map(int,input().split()) b,w = map(int,input().split()) t = int(input()) if (v-w)*t >= b-a: print('Yes') else: print('No')
s421593133
Accepted
23
9,160
137
a,v = map(int,input().split()) b,w = map(int,input().split()) t = int(input()) if (v-w)*t >= abs(a-b): print('YES') else: print('NO')
s297820919
p02393
u082526811
1,000
131,072
Wrong Answer
20
7,464
104
Write a program which reads three integers, and prints them in ascending order.
if __name__ == "__main__": a = [ i for i in input().split() ] a.sort(reverse=True) print(' '.join(a))
s770687355
Accepted
30
7,540
92
if __name__ == "__main__": a = [ i for i in input().split() ] a.sort() print(' '.join(a))
s608752164
p03845
u578323547
2,000
262,144
Wrong Answer
17
3,064
303
Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her.
n = int(input()) t = [int(x) for x in input().split()] m = int(input()) drink = [] for i in range(m): effect = [int(x) for x in input().split()] effect[0] -= 1 drink.append(effect) print(drink) for i in range(m): score = sum(t) - t[drink[i][0]] + drink[i][1] print(score)
s022124398
Accepted
18
3,064
281
n = int(input()) t = [int(x) for x in input().split()] m = int(input()) drink = [] for i in range(m): effect = [int(x) for x in input().split()] effect[0] -= 1 drink.append(effect) for i in range(m): score = sum(t) - t[drink[i][0]] + drink[i][1] print(score)
s362062384
p02393
u981238682
1,000
131,072
Wrong Answer
20
7,540
52
Write a program which reads three integers, and prints them in ascending order.
a = list(map(int,input().split())) a.sort() print(a)
s723979056
Accepted
20
7,692
65
a = list(map(int,input().split())) a.sort() print(a[0],a[1],a[2])
s033994012
p02402
u905165344
1,000
131,072
Wrong Answer
20
7,648
93
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.
a=list(map(int,input().split())) print (min(a),end=" ") print (max(a),end=" ") print (sum(a))
s336144645
Accepted
60
8,668
101
input() a=list(map(int,input().split())) print (min(a),end=" ") print (max(a),end=" ") print (sum(a))
s964873050
p03494
u703442202
2,000
262,144
Wrong Answer
18
3,060
298
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
n = int(input()) a_list = list(map(int,input().split())) count = 0 for j in range(30): for a in a_list: frag = True if a % 2 !=0: frag = False if frag == False: print(count) break else: count += 1 for i in range(n): a_list[i] = a_list[i]//2
s525859223
Accepted
18
3,060
296
n = int(input()) a_list = list(map(int,input().split())) count = 0 for j in range(30): frag = True for a in a_list: if a % 2 !=0: frag = False if frag == False: print(count) break else: count += 1 for i in range(n): a_list[i] = a_list[i]//2
s288280671
p03469
u189385406
2,000
262,144
Wrong Answer
17
2,940
23
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.
s = input() print(s[3])
s052789854
Accepted
17
2,940
47
s = input() ss = s.replace('7','8',1) print(ss)
s625896542
p03625
u309977459
2,000
262,144
Wrong Answer
268
14,252
397
We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.
N = int(input()) A = list(map(int, input().split())) A.sort(reverse=True) res = A[0] cnt = 1 use = [] for i in range(1, N): if A[i] == res: cnt += 1 else: cnt = 1 res = A[i] print(i, A[i], cnt, use) if cnt >= 2: use.append(A[i]) cnt -= 2 if len(use) >= 2: break if len(use) >= 2: print(use[0]*use[1]) else: print(0)
s295687535
Accepted
104
14,224
367
N = int(input()) A = list(map(int, input().split())) A.sort(reverse=True) res = A[0] cnt = 1 use = [] for i in range(1, N): if A[i] == res: cnt += 1 else: cnt = 1 res = A[i] if cnt >= 2: use.append(A[i]) cnt -= 2 if len(use) >= 2: break if len(use) >= 2: print(use[0]*use[1]) else: print(0)
s382531634
p03471
u841621946
2,000
262,144
Wrong Answer
1,292
3,060
286
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
N, Y = tmp = list(map(int,input().split())) ans = [-1]*3 for i in range(Y // 10000 + 1): tmp = Y - 10000 * i for j in range(tmp // 5000 + 1): if i + j <= N: if 10000 * i + 5000 * j + 1000 * (N - i - j) == Y: ans = [i, j, N - i - j] print(ans)
s470293339
Accepted
1,048
3,064
305
N, Y = tmp = list(map(int,input().split())) ans = [-1]*3 for i in range(Y // 10000 + 1): tmp = Y - 10000 * i for j in range(tmp // 5000 + 1): if i + j <= N: if 10000 * i + 5000 * j + 1000 * (N - i - j) == Y: ans = [i, j, N - i - j] print(ans[0], ans[1], ans[2])
s041072070
p03795
u663014688
2,000
262,144
Wrong Answer
17
2,940
118
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
N = int(input()) fee = 0 for i in range(N): fee = fee + 800 * N if N % 15 == 0: fee -= 200 print(fee)
s907547477
Accepted
17
2,940
85
N = int(input()) fee = 0 back = 0 fee = N * 800 back = N // 15 * 200 print(fee-back)
s387507221
p02394
u983062352
1,000
131,072
Wrong Answer
20
5,596
150
Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.
a,b,c,d,e = map(int,(input().split())) print (a,b,c,d,e) if c >= e and d >= e and a >= c + e and b >= d + e: print ("Yes") else: print ("No")
s954942832
Accepted
20
5,596
136
W,H,x,y,r = map(int,(input().split())) if x >= r and y >= r and W >= (x + r) and H >= (y + r): print ("Yes") else: print ("No")
s668251015
p03957
u777028980
1,000
262,144
Wrong Answer
17
2,940
153
This contest is `CODEFESTIVAL`, which can be shortened to the string `CF` by deleting some characters. Mr. Takahashi, full of curiosity, wondered if he could obtain `CF` from other strings in the same way. You are given a string s consisting of uppercase English letters. Determine whether the string `CF` can be obtained from the string s by deleting some characters.
hoge=input() f=0 for i in range(len(hoge)): if(hoge[i:].count("C")>0 and hoge[:1].count("F")>0): f=1 if(f): print("Yes") else: print("No")
s070250201
Accepted
17
2,940
136
hoge=input() f=0 for i in range(len(hoge)): if("C" in hoge[:i] and "F" in hoge[i:]): f=1 if(f): print("Yes") else: print("No")
s004046853
p03407
u003501233
2,000
262,144
Wrong Answer
17
2,940
78
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
A,B,C=map(int,input().split()) if A+B <= C: print("Yes") else: print("No")
s129624381
Accepted
17
2,940
78
A,B,C=map(int,input().split()) if A+B >= C: print("Yes") else: print("No")
s587773044
p03854
u266014018
2,000
262,144
Wrong Answer
30
9,212
361
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
def main(): import sys def input(): return sys.stdin.readline().rstrip() s = input() word = ['eraser', 'erase', 'dreamer', 'dream'] for x in word: s = s.replace(x, '') if s == '': print('Yes') else: print('No') if __name__ == '__main__': main()
s926189076
Accepted
30
9,152
361
def main(): import sys def input(): return sys.stdin.readline().rstrip() s = input() word = ['eraser', 'erase', 'dreamer', 'dream'] for x in word: s = s.replace(x, '') if s == '': print('YES') else: print('NO') if __name__ == '__main__': main()
s334662156
p03672
u085883871
2,000
262,144
Wrong Answer
18
3,060
144
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input.
s = input() for i in reversed(range(1, int((len(s))/2+1))): print(s[:i]) print(s[i:2*i]) if(s[:i] == s[i:2*i]): print(2*i)
s761328220
Accepted
18
3,064
123
s = input() for i in reversed(range(1, int((len(s)-1)/2+1))): if(s[:i] == s[i:2*i]): print(2*i) break
s066776931
p03415
u131264627
2,000
262,144
Wrong Answer
17
2,940
80
We have a 3×3 square grid, where each square contains a lowercase English letters. The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}. Print the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.
a = list(input()) b = list(input()) c = list(input()) print(a[0] + b[0] + c[0])
s905608133
Accepted
17
2,940
80
a = list(input()) b = list(input()) c = list(input()) print(a[0] + b[1] + c[2])
s716176599
p03971
u871841829
2,000
262,144
Wrong Answer
97
4,016
332
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these. Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests. * A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B. * An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students. A string S is assigned indicating attributes of all participants. If the i-th character of string S is `a`, this means the participant ranked i-th in the Qualification contests is a Japanese student; `b` means the participant ranked i-th is an overseas student; and `c` means the participant ranked i-th is neither of these. Write a program that outputs for all the participants in descending rank either `Yes` if they passed the Qualification contests or `No` if they did not pass.
N, A, B = map(int, input().split()) S = input() import sys T = A + B Ta = B for p in S: if p == "c": print("No") continue elif p == "a": if T > 0: print("Yes") T -= 1 else: print("No") else: if T > 0 and Ta > 0: print("Yes") Ta -= 1 else: print("No")
s130720584
Accepted
99
4,016
345
N, A, B = map(int, input().split()) S = input() import sys T = A + B Ta = B for p in S: if p == "c": print("No") continue elif p == "a": if T > 0: print("Yes") T -= 1 else: print("No") else: if T > 0 and Ta > 0: print("Yes") Ta -= 1 T -= 1 else: print("No")
s461721538
p03599
u073775598
3,000
262,144
Wrong Answer
3,155
3,064
608
Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations. * Operation 1: Pour 100A grams of water into the beaker. * Operation 2: Pour 100B grams of water into the beaker. * Operation 3: Put C grams of sugar into the beaker. * Operation 4: Put D grams of sugar into the beaker. In our experimental environment, E grams of sugar can dissolve into 100 grams of water. Snuke will make sugar water with the highest possible density. The beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker. Find the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it. If there is more than one candidate, any of them will be accepted. We remind you that the sugar water that contains a grams of water and b grams of sugar is \frac{100b}{a + b} percent. Also, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.
#ABC074C A, B, C, D, E, F=map(int, input().split()) A=100*A B=100*B count_A=F//A count_B=F//B count_C=F//C count_D=F//D max=0 ans=[0]*2 total=0 density=0 for i in range(count_A+1): for j in range(count_B+1): for k in range(count_C+1): for l in range(count_D+1): total=(i)*A+(j)*B+(k)*C+(l)*D if total!=0: density=((k)*C+(l)*D)/total if total<=F and density<=E/(100+E) and max<density: max=density ans[0]=total ans[1]=(k)*C+(l)*D print(ans)
s508449556
Accepted
113
3,064
918
#ABC074C A, B, C, D, E, F=map(int, input().split()) A=100*A B=100*B count_A=F//A count_B=F//B count_C=F//C count_D=F//D max=-1 ans=[0]*2 total=0 density=0 for i in range(count_A+1): for j in range(count_B+1): if i*A+j*B<=F and 0<i*A+j*B: for k in range(count_C+1): if i*A+j*B+k*C<=F: for l in range(count_D+1): total=i*A+j*B+k*C+l*D if total!=0: density=(k*C+l*D)/total if total<=F and density<=E/(100+E) and max<density: max=density ans[0]=total ans[1]=k*C+l*D if density==E/(100+E): print(' '.join(map(str, ans))) exit() print(' '.join(map(str, ans)))
s591249035
p03761
u888092736
2,000
262,144
Wrong Answer
27
3,764
307
Snuke loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string. He will receive a headline which contains one of the strings S_1,...,S_n tomorrow. He is excited and already thinking of what string he will create. Since he does not know the string on the headline yet, he is interested in strings that can be created regardless of which string the headline contains. Find the longest string that can be created regardless of which string among S_1,...,S_n the headline contains. If there are multiple such strings, find the lexicographically smallest one among them.
from collections import Counter from string import ascii_lowercase n = int(input()) dic = {c: 50 for c in ascii_lowercase} print(dic) for _ in range(n): tmp = Counter(input()) for c in ascii_lowercase: dic[c] = min(dic[c], tmp.get(c, 0)) print(''.join(c * dic[c] for c in ascii_lowercase))
s248396998
Accepted
26
3,768
296
from collections import Counter from string import ascii_lowercase n = int(input()) dic = {c: 50 for c in ascii_lowercase} for _ in range(n): tmp = Counter(input()) for c in ascii_lowercase: dic[c] = min(dic[c], tmp.get(c, 0)) print(''.join(c * dic[c] for c in ascii_lowercase))
s360924964
p03457
u881192043
2,000
262,144
Wrong Answer
2,104
3,064
759
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
N=int(input()) clear_flag=0 for i in range(N): txy=list(map(int,input().split())) x=0 y=0 next_flag=0 for x_plus in range(txy[0]+1): if next_flag==1: break for x_minus in range(txy[0]+1-x_plus): if next_flag==1: break for y_plus in range(txy[0]+1-x_plus-x_minus): if next_flag==1: break for y_minus in range(txy[0]+1-x_plus-x_minus-y_plus): if x_plus+x_minus+y_plus+y_minus==txy[0]: x=x_plus-x_minus y=y_plus-y_minus if x==txy[1] and y==txy[2]: next_flag=1 clear_flag+=1 break if clear_flag==N: print("YES") else: print("NO")
s037228738
Accepted
370
3,060
240
N=int(input()) clear_flag=0 for i in range(N): txy=list(map(int,input().split())) if txy[0]>=(txy[1]+txy[2]) and (txy[0]+txy[1]+txy[2])%2==0: clear_flag+=1 else: break if clear_flag==N: print("Yes") else: print("No")
s627458530
p03415
u903596281
2,000
262,144
Wrong Answer
17
2,940
48
We have a 3×3 square grid, where each square contains a lowercase English letters. The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}. Print the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.
s=[] for i in range(3): s+=input()[i] print(s)
s560603940
Accepted
17
2,940
48
s="" for i in range(3): s+=input()[i] print(s)
s663514107
p03827
u298297089
2,000
262,144
Wrong Answer
17
2,940
63
You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).
n = int(input()) s = input() print(s.count('I') - s.count('D'))
s798629352
Accepted
18
2,940
130
n = int(input()) ans = 0 x = 0 for c in input(): if c == 'I': x += 1 else: x -= 1 if x > ans: ans = x print(ans)
s673677000
p03473
u425351967
2,000
262,144
Wrong Answer
17
2,940
22
How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?
print(int(input())+12)
s285050260
Accepted
17
2,940
22
print(48-int(input()))
s112802103
p03477
u182047166
2,000
262,144
Wrong Answer
17
3,060
364
A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R. Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and placed a mass of weight C and a mass of weight D on the right pan. Print `Left` if the balance scale tips to the left; print `Balanced` if it balances; print `Right` if it tips to the right.
import sys def input(): return sys.stdin.readline()[:-1] # N = int(input()) # A = [int(x) for x in input().split()] # a, b, c = map(int, input().split()) # name1 = str(input()) # alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5} a, b,c,d = map(int, input().split()) if a+b<c+d: print("Left") elif a+b==c+d: print("Balanced") else: print("Right")
s000044422
Accepted
17
2,940
364
import sys def input(): return sys.stdin.readline()[:-1] # N = int(input()) # A = [int(x) for x in input().split()] # a, b, c = map(int, input().split()) # name1 = str(input()) # alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5} a, b,c,d = map(int, input().split()) if a+b>c+d: print("Left") elif a+b==c+d: print("Balanced") else: print("Right")
s448661638
p03644
u686713618
2,000
262,144
Wrong Answer
17
2,940
27
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
n = input() print("ABC"+n)
s850296085
Accepted
18
2,940
103
N = int(input()) for i in range(1,N+1): if 2**i <= N: pass else: print(2**(i-1)) break
s073813307
p02407
u104931506
1,000
131,072
Wrong Answer
40
7,412
69
Write a program which reads a sequence and prints it in the reverse order.
n = input() A = [i for i in n.split()] A.reverse() print(' '.join(A))
s377713098
Accepted
30
7,476
71
input() A = [i for i in input().split()] A.reverse() print(' '.join(A))
s212060980
p03487
u390958150
2,000
262,144
Wrong Answer
229
30,064
350
You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a **good sequence**. Here, an sequence b is a **good sequence** when the following condition holds true: * For each element x in b, the value x occurs exactly x times in b. For example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not. Find the minimum number of elements that needs to be removed so that a will be a good sequence.
N = int(input().rstrip()) numbers =[ int(i) for i in input().rstrip().split()] print(numbers) n_dic = {str(i):0 for i in set(numbers)} for i in numbers: n_dic[str(i)] += 1 print(n_dic) count = 0 for i,j in n_dic.items(): if int(i) < j: count += j - int(i) elif int(i) > j: count += j print(count)
s683095996
Accepted
205
28,660
321
N = int(input().rstrip()) numbers =[ int(i) for i in input().rstrip().split()] n_dic = {str(i):0 for i in set(numbers)} for i in numbers: n_dic[str(i)] += 1 count = 0 for i,j in n_dic.items(): if int(i) < j: count += j - int(i) elif int(i) > j: count += j print(count)
s781043708
p03623
u338225045
2,000
262,144
Wrong Answer
21
3,316
120
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
x, a, b = map( int, input().split() ) if abs(x - a) > abs(x - b): print( 'A' ) else: print( 'B' )
s118669596
Accepted
17
3,064
120
x, a, b = map( int, input().split() ) if abs(x - a) > abs(x - b): print( 'B' ) else: print( 'A' )
s064223420
p03779
u189487046
2,000
262,144
Wrong Answer
36
4,884
318
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.
def create_koho(X): koho = [1] koho_sum = 1 i = 1 while koho_sum <= X: i += 1 koho.append(i) koho_sum += i return koho X = int(input()) koho = create_koho(X) nokori = X ans = 0 for i in reversed(koho): if nokori >= i: nokori -= i ans += 1 print(ans)
s247885834
Accepted
27
2,940
95
X = int(input()) i = 1 koho_sum = i while koho_sum < X: i += 1 koho_sum += i print(i)
s749427326
p02613
u740784649
2,000
1,048,576
Wrong Answer
191
16,060
416
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
list = [] words = ['AC','WA','TLE','RE'] words_count = {'AC':0,'WA':0,'TLE':0,'RE':0} try: while True: val = input() if val: list.append(val) else: break except EOFError: pass for i in range(1,len(list)): for word in words: if list[i] == word: words_count[word] += 1 for k,v in words_count.items(): print("{key} × {value}".format(key = k,value= v))
s345370394
Accepted
190
16,068
415
list = [] words = ['AC','WA','TLE','RE'] words_count = {'AC':0,'WA':0,'TLE':0,'RE':0} try: while True: val = input() if val: list.append(val) else: break except EOFError: pass for i in range(1,len(list)): for word in words: if list[i] == word: words_count[word] += 1 for k,v in words_count.items(): print("{key} x {value}".format(key = k,value= v))
s344385092
p02646
u296984343
2,000
1,048,576
Wrong Answer
23
9,204
329
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
a,v = map(int, input().split()) b,w = map(int, input().split()) t = int(input()) if a<b: new_a = a + v*t new_b = b + w*t if new_a >= new_b: print("Yes") else: print("No") elif a > b: new_a = a - v*t new_b = b - v*t if new_a <= new_b: print("Yes") else: print("No")
s970045199
Accepted
25
9,128
356
a,v = map(int, input().split()) b,w = map(int, input().split()) t = int(input()) if a<b: new_a = a + v*t new_b = b + w*t if new_a >= new_b: print("YES") elif new_a < new_b: print("NO") elif a>b: new_a = a - v*t new_b = b - w*t if new_a <= new_b: print("YES") elif new_a > new_b: print("NO")
s487539905
p02850
u030314915
2,000
1,048,576
Wrong Answer
2,104
12,524
592
Given is a tree G with N vertices. The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i. Consider painting the edges in G with some number of colors. We want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different. Among the colorings satisfying the condition above, construct one that uses the minimum number of colors.
n = int(input()) a = [] b = [] s = [0]*n ans = [0]*(n-1) count = 0 for i in range(n-1): x,y = map(int,input().split()) a.append(x) b.append(y) s[x-1] += 1 s[y-1] += 1 for i in range(n-1): num = s.index(max(s)) + 1 ai = [x for x, y in enumerate(a) if y == num] bi = [x for x, y in enumerate(b) if y == num] index = ai + bi t = s[num-1] for j in index: ans[j-1] = t t -= 1 s[a[j]-1] -= 1 s[b[j]-1] -= 1 a[j] = 0 b[j] = 0 count += 1 if count >= n-1: break for x in ans: print(x)
s488167737
Accepted
758
39,996
704
from collections import deque n = int(input()) l = [[] for _ in range(n)] ans = [0]*(n-1) q = deque() color = [0]*n count = 0 for i in range(n-1): x,y = map(lambda x: int(x)-1, input().split()) if i == 0: q.append(x) l[x].append((y,i)) l[y].append((x,i)) while count<n-1: node = q.popleft() c = 1 for d, ind in l[node]: if ans[ind] == 0: if c == color[node]: c += 1 ans[ind] = c q.append(d) color[d] = c c += 1 count += 1 print(max(ans)) for i in ans: print(i)
s804656353
p03997
u371467115
2,000
262,144
Wrong Answer
18
2,940
62
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
a=int(input()) b=int(input()) h=int(input()) print((a+b)*h/2)
s473114421
Accepted
18
2,940
62
a=int(input()) b=int(input()) h=int(input()) print((a+b)*h//2)
s893752502
p03478
u609061751
2,000
262,144
Wrong Answer
34
2,940
237
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
import sys input = sys.stdin.readline N, A, B = [int(x) for x in input().split()] ans = 0 for i in range(1, N + 1): i = str(i) total = 0 for j in i: total += int(j) if A <= total <= B: ans += 1 print(ans)
s937770968
Accepted
34
3,060
241
import sys input = sys.stdin.readline N, A, B = [int(x) for x in input().split()] ans = 0 for i in range(1, N + 1): i = str(i) total = 0 for j in i: total += int(j) if A <= total <= B: ans += int(i) print(ans)
s028693951
p02743
u384261199
2,000
1,048,576
Wrong Answer
1,482
21,604
128
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?
import numpy as np a,b,c = list(map(int, input().split())) if c - a - b - 2*np.sqrt(a*b): print("Yes") else: print("No")
s989686928
Accepted
17
2,940
175
a,b,c = list(map(int, input().split())) if c - b - a > 0: if c**2 + a**2 + b**2 - 2*a*c - 2*b*c - 2*a*b > 0: print("Yes") else: print("No") else: print("No")
s417720741
p03605
u923561222
2,000
262,144
Wrong Answer
17
2,940
61
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
if int(input()) % 10 == 9: print('YES') else: print('NO')
s663161200
Accepted
17
2,940
57
n=input() if '9' in n: print('Yes') else: print('No')
s805226700
p03448
u999503965
2,000
262,144
Wrong Answer
61
9,124
258
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
a=int(input()) b=int(input()) c=int(input()) x=int(input()) ans=0 for i in range(a): for j in range(b): for k in range(c): num_500=500*i num_100=100*j num_50=50*k if num_500+num_100+num_50==x: ans+=1 print(ans)
s845458925
Accepted
64
9,184
265
a=int(input()) b=int(input()) c=int(input()) x=int(input()) ans=0 for i in range(a+1): for j in range(b+1): for k in range(c+1): num_500=500*i num_100=100*j num_50=50*k if num_500+num_100+num_50==x: ans+=1 print(ans)
s370638427
p02612
u779483561
2,000
1,048,576
Wrong Answer
33
9,140
57
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
# -*- coding: utf-8 -*- n = int(input()) print(n % 1000)
s897318646
Accepted
32
9,156
124
# -*- coding: utf-8 -*- n = int(input()) if n % 1000 == 0: print(0) else: ans = (n//1000+1)*1000 - n print(ans)
s653061129
p03549
u223904637
2,000
262,144
Wrong Answer
17
2,940
142
Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
n,m=map(int,input().split()) k=1900*m l=0.50**m a=0 for i in range(1,100): a+=k*l*i l=(1.0-l)*(0.50**m) print(round(a)+(n-m)*100)
s947867300
Accepted
17
2,940
61
n,m=map(int,input().split()) print((1900*m+100*(n-m))*(2**m))
s332631514
p03644
u598229387
2,000
262,144
Wrong Answer
18
2,940
166
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
n = int(input()) ans = float('-inf') for i in range(1, n+1): count = 0 while i % 2 ==0: i /= 2 count += 1 ans = max(ans, count) print(ans)
s514375325
Accepted
17
3,060
168
n=int(input()) if n <=1: ans=n elif n <4: ans=2 elif n<8: ans=4 elif n<16: ans=8 elif n<32: ans=16 elif n<64: ans=32 else: ans=64 print(ans)
s932960130
p03471
u182047166
2,000
262,144
Wrong Answer
729
3,060
523
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
import bisect import sys def input(): return sys.stdin.readline()[:-1] # N = int(input()) # A = [int(x) for x in input().split()] # a, b, c = map(int, input().split()) # name1 = str(input()) # alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5} n, y = map(int, input().split()) ans = [-1, -1, -1] for man in range(n+1): for gosen in range(n+1-man): if 10000*man + 5000*gosen + 1000*(n-man-gosen) == y: ans = [man, gosen, n-man-gosen] print(ans)
s008851260
Accepted
755
3,060
561
import bisect import sys def input(): return sys.stdin.readline()[:-1] # N = int(input()) # A = [int(x) for x in input().split()] # a, b, c = map(int, input().split()) # name1 = str(input()) # alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5} n, y = map(int, input().split()) ans = [-1, -1, -1] for man in range(n+1): for gosen in range(n+1-man): if 10000*man + 5000*gosen + 1000*(n-man-gosen) == y: ans = [man, gosen, n-man-gosen] break print(" ".join(map(str, ans)))
s291492343
p03546
u485319545
2,000
262,144
Wrong Answer
44
9,444
920
Joisino the magical girl has decided to turn every single digit that exists on this world into 1. Rewriting a digit i with j (0≤i,j≤9) costs c_{i,j} MP (Magic Points). She is now standing before a wall. The wall is divided into HW squares in H rows and W columns, and at least one square contains a digit between 0 and 9 (inclusive). You are given A_{i,j} that describes the square at the i-th row from the top and j-th column from the left, as follows: * If A_{i,j}≠-1, the square contains a digit A_{i,j}. * If A_{i,j}=-1, the square does not contain a digit. Find the minimum total amount of MP required to turn every digit on this wall into 1 in the end.
H,W=map(int,input().split()) grid=[] for _ in range(10): grid.append(list(map(int,input().split()))) Wall=[] for _ in range(H): Wall.append(list(map(int,input().split()))) d=[0]*10 for start in range(10): distance=grid[start] visited=[0] * 10 visited[start] = 1 size = 1 while size<10: min_distance = 10**9 for i in range(10): if visited[i]==0 and distance[i] <min_distance: min_distance = distance[i] v = i visited[v] = 1 size+=1 for x in range(10): if distance[x] > distance[v] + grid[v][x]: distance[x] = distance[v] + grid[v][x] d[start]=distance[1] print(d) ans=0 for i in range(H): for j in range(W): if Wall[i][j]==-1: continue else: ans+=d[Wall[i][j]] print(ans)
s051283221
Accepted
44
9,468
909
H,W=map(int,input().split()) grid=[] for _ in range(10): grid.append(list(map(int,input().split()))) Wall=[] for _ in range(H): Wall.append(list(map(int,input().split()))) d=[0]*10 for start in range(10): distance=grid[start] visited=[0] * 10 visited[start] = 1 size = 1 while size<10: min_distance = 10**9 for i in range(10): if visited[i]==0 and distance[i] <min_distance: min_distance = distance[i] v = i visited[v] = 1 size+=1 for x in range(10): if distance[x] > distance[v] + grid[v][x]: distance[x] = distance[v] + grid[v][x] d[start]=distance[1] ans=0 for i in range(H): for j in range(W): if Wall[i][j]==-1: continue else: ans+=d[Wall[i][j]] print(ans)
s184703977
p02406
u328199937
1,000
131,072
Wrong Answer
20
5,592
282
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto. Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements. void call(int n){ int i = 1; CHECK_NUM: int x = i; if ( x % 3 == 0 ){ cout << " " << i; goto END_CHECK_NUM; } INCLUDE3: if ( x % 10 == 3 ){ cout << " " << i; goto END_CHECK_NUM; } x /= 10; if ( x ) goto INCLUDE3; END_CHECK_NUM: if ( ++i <= n ) goto CHECK_NUM; cout << endl; }
def check(num): n = str(num) for i in range(len(n)): if n[i] == '3': return True return False n = int(input()) print('3', end = '') for i in range(4, n): if i % 3 == 0: print(' ' + str(i), end = '') elif check(i): print(' ' + str(i), end = '')
s649661531
Accepted
30
5,876
273
def check(num): n = str(num) for i in range(len(n)): if n[i] == '3': return True return False n = int(input()) for i in range(1, n + 1): if i % 3 == 0: print(' ' + str(i), end = '') elif check(i): print(' ' + str(i), end = '') print()
s420850956
p03434
u935840914
2,000
262,144
Wrong Answer
18
2,940
229
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
n = int(input()) a = list(map(int, input().split())) a.sort() Alice = list() Bob = list() print(a) for i in range(n): if i % 2 == 0: Alice.append(a[i]) else: Bob.append(a[i]) print(sum(Alice) - sum(Bob))
s256356035
Accepted
17
3,060
232
n = int(input()) a = list(map(int, input().split())) a.sort(reverse=True) Alice = list() Bob = list() for i in range(n): if i % 2 == 0: Alice.append(a[i]) else: Bob.append(a[i]) print(sum(Alice) - sum(Bob))
s004609867
p02694
u410035828
2,000
1,048,576
Wrong Answer
23
9,212
101
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
X = int(input()) r = 0.01 s = 100 n = X i = 0 while s < X: s = int(s * (1 + r)) i = i + 1 print(i)
s141644350
Accepted
22
9,164
100
X = int(input()) r = 0.01 s = 100 n = X i = 0 while s < X: s = int(s * (1 + r)) i = i + 1 print(i)
s538921379
p03711
u145789675
2,000
262,144
Wrong Answer
17
3,060
204
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.
#!/bin/usr/python A = [1,3,5,7,8,10,12] B = [4,6,9,11] C = [2] x,y = [int(i) for i in input().split()] if x in A and y in A or x in B and y in B or x in C and y in C: print("yes") else: print("no")
s838375706
Accepted
17
3,060
204
#!/bin/usr/python A = [1,3,5,7,8,10,12] B = [4,6,9,11] C = [2] x,y = [int(i) for i in input().split()] if x in A and y in A or x in B and y in B or x in C and y in C: print("Yes") else: print("No")
s108049156
p03694
u652081898
2,000
262,144
Wrong Answer
17
2,940
84
It is only six months until Christmas, and AtCoDeer the reindeer is now planning his travel to deliver gifts. There are N houses along _TopCoDeer street_. The i-th house is located at coordinate a_i. He has decided to deliver gifts to all these houses. Find the minimum distance to be traveled when AtCoDeer can start and end his travel at any positions.
n = int(input()) x = sorted(list(map(int, input().split()))) print(max(x)-min(x)+1)
s691243444
Accepted
17
2,940
83
n = int(input()) x = sorted(list(map(int, input().split()))) print(max(x)-min(x))
s570565824
p02601
u674190122
2,000
1,048,576
Wrong Answer
31
9,160
303
M-kun has the following three cards: * A red card with the integer A. * A green card with the integer B. * A blue card with the integer C. He is a genius magician who can do the following operation at most K times: * Choose one of the three cards and multiply the written integer by 2. His magic is successful if both of the following conditions are satisfied after the operations: * The integer on the green card is **strictly** greater than the integer on the red card. * The integer on the blue card is **strictly** greater than the integer on the green card. Determine whether the magic can be successful.
r, g, b = [int(x) for x in input().split()] ops = int(input()) m = 0 while m <= ops: if max(r, g, b ) != b: b *= 2 m += 1 else:break while m < ops: if max(r, g) != g : g *= 2 m += 1 else: break print(r,g,b) print("Yes" if r < g < b else "No")
s148019484
Accepted
30
9,176
192
r, g, b = [int(x) for x in input().split()] ops = int(input()) m = 0 while g <= r: g *= 2 m += 1 while b <= g: b *= 2 m += 1 print("Yes" if m <= ops else "No")
s130330821
p03573
u780709476
2,000
262,144
Wrong Answer
17
2,940
107
You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
A, B, C = map(int, input().split()) if(A == B): print(C) elif(B == C): print(A) else: print(C)
s624804042
Accepted
18
2,940
107
A, B, C = map(int, input().split()) if(A == B): print(C) elif(B == C): print(A) else: print(B)
s759123909
p03472
u239528020
2,000
262,144
Wrong Answer
243
17,132
514
You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, …, Katana N, and can perform the following two kinds of attacks in any order: * Wield one of the katana you have. When you wield Katana i (1 ≤ i ≤ N), the monster receives a_i points of damage. The same katana can be wielded any number of times. * Throw one of the katana you have. When you throw Katana i (1 ≤ i ≤ N) at the monster, it receives b_i points of damage, and you lose the katana. That is, you can no longer wield or throw that katana. The monster will vanish when the total damage it has received is H points or more. At least how many attacks do you need in order to vanish it in total?
#!/usr/bin/env python3 import bisect import sys import math sys.setrecursionlimit(10**6) n, h = list(map(int, input().split())) a = [] b = [] ab = [] for i in range(n): a_tmp, b_tmp = list(map(int, input().split())) a.append(a_tmp) b.append(b_tmp) # ab.append((b_tmp, a_tmp)) a_max = max(a) b.sort() index = bisect.bisect_right(b, a_max) ans = 0 for i in reversed(range(index, n)): h -= b[i] ans += 1 if h <= 0: break if h > 0: ans += math.floor(h/a_max) print(ans)
s137836213
Accepted
245
17,184
524
#!/usr/bin/env python3 import bisect import sys import math sys.setrecursionlimit(10**6) n, h = list(map(int, input().split())) a = [] b = [] ab = [] for i in range(n): a_tmp, b_tmp = list(map(int, input().split())) a.append(a_tmp) b.append(b_tmp) # ab.append((b_tmp, a_tmp)) a_max = max(a) b.sort() index = bisect.bisect_right(b, a_max) ans = 0 for i in reversed(range(index, n)): h -= b[i] ans += 1 if h <= 0: break # print(h) if h > 0: ans += math.ceil(h/a_max) print(ans)
s022967980
p02618
u442877951
2,000
1,048,576
Wrong Answer
35
9,392
138
AtCoder currently hosts three types of contests: ABC, ARC, and AGC. As the number of users has grown, in order to meet the needs of more users, AtCoder has decided to increase the number of contests to 26 types, from AAC to AZC. For convenience, we number these 26 types as type 1 through type 26. AtCoder wants to schedule contests for D days so that user satisfaction is as high as possible. For every day, AtCoder will hold exactly one contest, and each contest will end on that day. The satisfaction is calculated as follows. * The satisfaction at the beginning of day 1 is 0. Satisfaction can be negative. * Holding contests increases satisfaction. The amount of increase will vary depending on a variety of factors. Specifically, we know in advance that holding a contest of type i on day d will increase the satisfaction by s_{d,i}. * If a particular type of contest is not held for a while, the satisfaction decreases. Each contest type i has an integer c_i, and at the end of each day d=1,2,...,D, the satisfaction decreases as follows. Let \mathrm{last}(d,i) be the last day before day d (including d) on which a contest of type i was held. If contests of type i have never been held yet, we define \mathrm{last}(d,i)=0. At the end of day d, the satisfaction decreases by \sum _{i=1}^{26}c_i \times (d-\mathrm{last}(d,i)). Please schedule contests on behalf of AtCoder. If the satisfaction at the end of day D is S, you will get a score of \max(10^6 + S, 0). There are 50 test cases, and the score of a submission is the total scores for each test case. You can make submissions multiple times, and the highest score among your submissions will be your score.
D = int(input()) C = list(map(int,input().split())) S = [list(map(int,input().split())) for _ in range(D)] for i in range(D): print(i+1)
s572362379
Accepted
38
9,532
244
D = int(input()) C = list(map(int,input().split())) S = [list(map(int,input().split())) for _ in range(D)] for i in range(D): count = 0 ans = 0 for j in range(26): if S[i][j] > count: count = S[i][j] ans = j+1 print(ans)