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
s384477799
p02697
u727980193
2,000
1,048,576
Wrong Answer
93
15,852
140
You are going to hold a competition of one-to-one game called AtCoder Janken. _(Janken is the Japanese name for Rock-paper-scissors.)_ N players will participate in this competition, and they are given distinct integers from 1 through N. The arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive). You cannot assign the same integer to multiple playing fields. The competition consists of N rounds, each of which proceeds as follows: * For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there. * Then, each player adds 1 to its integer. If it becomes N+1, change it to 1. You want to ensure that no player fights the same opponent more than once during the N rounds. Print an assignment of integers to the playing fields satisfying this condition. It can be proved that such an assignment always exists under the constraints given.
N,M=list(map(int, input().split())) src=[i+1 for i in range(M*2)] for m in range(M): a=src[m] b=src[-(m+1)] print('{} {}'.format(a,b))
s253825470
Accepted
96
15,820
434
N,M=list(map(int, input().split())) src=[i+1 for i in range(M*2+1)] if M%2==0: for m in range(M//2): a=src[m] b=src[M-m] print('{} {}'.format(a,b)) for m in range(M//2): a=src[M+1+m] b=src[-(m+1)] print('{} {}'.format(a,b)) else: for m in range(M//2): a=src[m] b=src[M-1-m] print('{} {}'.format(a,b)) for m in range(M-(M//2)): a=src[M+m] b=src[-(m+1)] print('{} {}'.format(a,b))
s383073029
p03434
u493491792
2,000
262,144
Wrong Answer
19
3,064
221
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()) lista=list(map(int,input().split())) lista.sort() alice=list() bob=list() for i in range(n): if i%2==0: alice.append(lista[i]) else: bob.append(lista[i]) print(sum(alice)-sum(bob))
s658282124
Accepted
18
3,060
242
n=int(input()) lista=list(map(int,input().split())) lista.sort(reverse=True) alice=list() bob=list() for i in range(n): if i%2==0: alice.append(lista[i]) else: bob.append(lista[i]) print(sum(alice)-sum(bob))
s314026467
p03795
u290211456
2,000
262,144
Wrong Answer
17
2,940
58
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()) print(n//15) print(800*n - 200 * (n//15))
s510591388
Accepted
17
2,940
45
n = int(input()) print(800*n - 200 * (n//15))
s444974513
p03473
u414699019
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(24-int(input()))
s637477501
Accepted
17
2,940
22
print(48-int(input()))
s108009883
p03129
u371467115
2,000
1,048,576
Wrong Answer
18
2,940
80
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
n,k=map(int,input().split()) if round(n/2)>k: print("YES") else: print("NO")
s942385014
Accepted
17
2,940
81
n,k=map(int,input().split()) if 1+2*(k-1)<=n: print("YES") else: print("NO")
s341648497
p03386
u585290246
2,000
262,144
Wrong Answer
17
3,060
173
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
#!/bin/python a, b, k = map(int, input().split()) for i in range(a, min(a + k, b)): print(i) for i in range(max(a + k, b - k + 1), min(a + k, b + 1)): print(i)
s242464330
Accepted
17
3,060
162
#!/bin/python a, b, k = map(int, input().split()) for i in range(a, min(a + k, b + 1)): print(i) for i in range(max(a + k, b - k + 1), b + 1): print(i)
s664434652
p03730
u343437894
2,000
262,144
Wrong Answer
17
2,940
145
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(" ")) for i in range(0, c): if (a * i) % b == c: print("YES") break else: print("NO")
s979486288
Accepted
17
2,940
145
a, b, c = map(int, input().split(" ")) for i in range(1, b): if (a * i) % b == c: print("YES") break else: print("NO")
s148649385
p03377
u268470352
2,000
262,144
Wrong Answer
17
2,940
136
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, x = map(int, input().split()) if a < x: print("NO") else: if (x - a)>b: print("NO") else: print("YES")
s122594656
Accepted
17
2,940
136
a, b, x = map(int, input().split()) if a > x: print("NO") else: if (x - a)>b: print("NO") else: print("YES")
s354278434
p03645
u547167033
2,000
262,144
Wrong Answer
859
38,936
252
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuke is on Island 1 now, and wants to go to Island N. However, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services. Help him.
n,m=map(int,input().split()) g=[[] for i in range(n)] for _ in range(m): u,v=map(int,input().split()) g[u-1].append(v-1) g[v-1].append(u-1) for x in g[0]: for y in g[x]: if y==n-1: print('POSSIBLE') else: print('IMPOSSIBLE')
s735278051
Accepted
897
38,320
250
n,m=map(int,input().split()) g=[[] for i in range(n)] for _ in range(m): u,v=map(int,input().split()) g[u-1].append(v-1) g[v-1].append(u-1) for x in g[0]: for y in g[x]: if y==n-1: print('POSSIBLE') exit() print('IMPOSSIBLE')
s874835174
p03080
u729133443
2,000
1,048,576
Wrong Answer
17
2,940
53
There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat.
print('YNeos'[int(input())<=input().count('R')*2::2])
s297235638
Accepted
17
2,940
53
print('YNeos'[int(input())>=input().count('R')*2::2])
s495607601
p03387
u934868410
2,000
262,144
Wrong Answer
17
2,940
129
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.
import math a = sorted(list(map(int,input().split()))) print(a[2] - a[1] + math.ceil((a[1] - a[0]) / 2) + (a[1] - a[0]) % 2 == 1)
s739577279
Accepted
23
2,940
131
import math a = sorted(list(map(int,input().split()))) print(a[2] - a[1] + math.ceil((a[1] - a[0]) / 2) + ((a[1] - a[0]) % 2 == 1))
s206896873
p03360
u050121913
2,000
262,144
Wrong Answer
17
2,940
87
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after K operations?
x = list(map(int,input().split( ))) y = int(input()) M = max(x) Max = M*2**y print(Max)
s756863609
Accepted
17
2,940
106
x = list(map(int,input().split( ))) y = int(input()) xx = sorted(x) xx[2] *= 2**y ans = sum(xx) print(ans)
s878973871
p03494
u603234915
2,000
262,144
Time Limit Exceeded
2,104
2,940
203
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()) l = list(map(int,input().split())) k = 0 while True: for i in l : if i % 2 != 0: break elif i == 2: break i = i/2 k += 1 print(k)
s549921331
Accepted
19
2,940
269
n = int(input()) l = list(map(int,input().split())) k = 0 m = 0 for _ in range(100): for i in range(len(l)) : if l[i] % 2 != 0 : m = 10 break else: l[i] = l[i]/2 if m != 0 : break k += 1 print(k)
s928825561
p03067
u485716382
2,000
1,048,576
Wrong Answer
17
2,940
132
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
def main(): a, b, c = map(int, input().split(' ')) if a > c > b: print('Yes') else: print("No") main()
s320170310
Accepted
17
2,940
172
def main(): a, b, c = map(int, input().split(' ')) if b > c > a: print('Yes') elif a > c > b: print('Yes') else: print("No") main()
s648965215
p02614
u564655959
1,000
1,048,576
Wrong Answer
171
26,288
606
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation: * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns. You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.
import itertools import numpy as np h, w, k = (int(each) for each in input().split()) c = [] for _ in range(h): c.append(list(input())) result = 0 n_c = np.array(c) for y in itertools.product([0,1], repeat = h): for x in itertools.product([0,1], repeat = w): # print(y, x) n_c2 = np.array(c) for i, y2 in enumerate(y): if y2 == 1: n_c2[i] = 'R' for i, x2 in enumerate(x): if x2 == 1: n_c2[:,i] = 'R' # print(n_c2) m = np.count_nonzero(n_c2 == '#') if k == m: result += 1
s318549962
Accepted
164
27,000
622
import itertools import numpy as np h, w, k = (int(each) for each in input().split()) c = [] for _ in range(h): c.append(list(input())) result = 0 n_c = np.array(c) for y in itertools.product([0,1], repeat = h): for x in itertools.product([0,1], repeat = w): # print(y, x) n_c2 = np.array(c) for i, y2 in enumerate(y): if y2 == 1: n_c2[i] = 'R' for i, x2 in enumerate(x): if x2 == 1: n_c2[:,i] = 'R' # print(n_c2) m = np.count_nonzero(n_c2 == '#') if k == m: result += 1 print(result)
s872699229
p03449
u372345564
2,000
262,144
Wrong Answer
19
3,060
289
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them. At most how many candies can you collect when you choose the best way to travel?
n = int(input()) a = [] for i in range(2): a.append([int(num) for num in input().split()]) #print(a) result = 0 for i in range(0, n): point = sum(a[0][0:i+1]) + sum(a[1][i:]) print(a[0][0:i+1]) print(a[1][i:]) if(result < point): result = point print(result)
s152607243
Accepted
19
3,060
291
n = int(input()) a = [] for i in range(2): a.append([int(num) for num in input().split()]) #print(a) result = 0 for i in range(0, n): point = sum(a[0][0:i+1]) + sum(a[1][i:]) # print(a[0][0:i+1]) # print(a[1][i:]) if(result < point): result = point print(result)
s150698734
p02694
u744695362
2,000
1,048,576
Time Limit Exceeded
2,205
9,072
91
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?
n = int(input()) b = 100 ans = 0 while b<=n : b *= int(b*0.01) ans += 1 print(ans)
s935962088
Accepted
22
9,160
89
n = int(input()) b = 100 ans = 0 while b<n : b = int(b*1.01) ans += 1 print(ans)
s034763473
p02972
u226912938
2,000
1,048,576
Wrong Answer
49
7,148
63
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.
n = int(input()) A = list(map(int, input().split())) print(-1)
s533314073
Accepted
264
17,228
366
n = int(input()) A = list(map(int, input().split())) Bo = [0 for _ in range(n)] Ans = [] for i in range(n-1, -1, -1): tot = sum(Bo[i::i+1]) if (tot % 2 == A[i]): pass elif (tot % 2 != A[i]): Ans.append(str(i+1)) Bo[i] += 1 else: pass if len(Ans) ==0: print(0) else: print(len(Ans)) print(' '.join(Ans))
s008235894
p03433
u807948625
2,000
262,144
Wrong Answer
17
2,940
100
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
N=int(input()) A=int(input()) amari = N % 500 if amari > A: print("no") else: print("yes")
s678346712
Accepted
17
2,940
100
N=int(input()) A=int(input()) amari = N % 500 if amari > A: print("No") else: print("Yes")
s534749345
p03697
u271044469
2,000
262,144
Wrong Answer
20
2,940
82
You are given two integers A and B as the input. Output the value of A + B. However, if A + B is 10 or greater, output `error` instead.
a,b = map(int, input().split()) if a+b<10: print('error') else: print(a+b)
s949752713
Accepted
17
2,940
84
a,b = map(int, input().split()) if a+b>=10: print('error') else: print(a+b)
s416710939
p03730
u063073794
2,000
262,144
Wrong Answer
17
2,940
115
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()) flag="No" for i in range(1,100): if a*i%b==c: flag="Yes" break print(flag)
s960293173
Accepted
17
2,940
115
a,b,c=map(int,input().split()) flag="NO" for i in range(1,100): if a*i%b==c: flag="YES" break print(flag)
s103062337
p03550
u207707177
2,000
262,144
Wrong Answer
18
3,188
164
We have a deck consisting of N cards. Each card has an integer written on it. The integer on the i-th card from the top is a_i. Two people X and Y will play a game using this deck. Initially, X has a card with Z written on it in his hand, and Y has a card with W written on it in his hand. Then, starting from X, they will alternately perform the following action: * Draw some number of cards from the top of the deck. Then, discard the card in his hand and keep the last drawn card instead. Here, at least one card must be drawn. The game ends when there is no more card in the deck. The score of the game is the absolute difference of the integers written on the cards in the two players' hand. X will play the game so that the score will be maximized, and Y will play the game so that the score will be minimized. What will be the score of the game?
n,z,w = [int(i) for i in input().split()] a = list(int(i) for i in input().split()) print(a) abs1 = abs(a[n-1] - w) abs2 = abs(a[n-2]-a[n-1]) print(max(abs1,abs2))
s533176958
Accepted
18
3,188
165
n,z,w = [int(i) for i in input().split()] a = list(int(i) for i in input().split()) #print(a) abs1 = abs(a[n-1] - w) abs2 = abs(a[n-2]-a[n-1]) print(max(abs1,abs2))
s615894886
p03813
u317044805
2,000
262,144
Wrong Answer
17
2,940
250
Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise. You are given Smeke's current rating, x. Print `ABC` if Smeke will participate in ABC, and print `ARC` otherwise.
# -*- coding: utf-8 -*- x = int(input()) quot, rem = divmod(x, 11) quot *= 2 if rem>6: quot += 2 elif rem>0: quot += 1 print(quot)
s181784968
Accepted
17
2,940
67
x = int(input()) if x<1200: print("ABC") else: print("ARC")
s225895932
p03141
u191635495
2,000
1,048,576
Wrong Answer
659
28,964
281
There are N dishes of cuisine placed in front of Takahashi and Aoki. For convenience, we call these dishes Dish 1, Dish 2, ..., Dish N. When Takahashi eats Dish i, he earns A_i points of _happiness_ ; when Aoki eats Dish i, she earns B_i points of happiness. Starting from Takahashi, they alternately choose one dish and eat it, until there is no more dish to eat. Here, both of them choose dishes so that the following value is maximized: "the sum of the happiness he/she will earn in the end" minus "the sum of the happiness the other person will earn in the end". Find the value: "the sum of the happiness Takahashi earns in the end" minus "the sum of the happiness Aoki earns in the end".
# input n = int(input()) ab = sorted([list(map(int, input().split())) for _ in range(n)]) res = 0 for i in range(n): if i % 2 == 0: abi = ab.pop(len(ab)-1) res += abi[0] else: abi = ab.pop(len(ab)-1) res -= abi[1] print(abi) print(res)
s470202792
Accepted
1,880
8,284
248
n = int(input()) dd = [] sb = 0 for _ in range(n): a, b = map(int, input().split()) dd.append(a+b) sb -= b abd = sorted(dd, reverse=True) res = 0 for i in range(n): d = abd.pop(0) if i % 2 == 0: res += d print(res+sb)
s003454246
p03400
u245870380
2,000
262,144
Wrong Answer
19
3,316
192
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces. Find the number of chocolate pieces prepared at the beginning of the camp.
N = int(input()) D, X = map(int, input().split()) A = [int(input()) for i in range(N)] choco = 0 for i in A: for j in range(1,D+1,i): print(j) choco += 1 print(choco + X)
s586137930
Accepted
18
3,064
175
N = int(input()) D, X = map(int, input().split()) A = [int(input()) for i in range(N)] choco = 0 for i in A: for j in range(1,D+1,i): choco += 1 print(choco + X)
s289295494
p02615
u284120954
2,000
1,048,576
Wrong Answer
2,208
31,504
276
Quickly after finishing the tutorial of the online game _ATChat_ , you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the **friendliness** of Player i is A_i. The N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere. When each player, except the first one to arrive, arrives at the place, the player gets **comfort** equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0. What is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?
N = int(input()) A = [] a, *an = map(int, input().split()) A.append(a) A += an A.sort() Node = [] score = 0 Node.append(A.pop()) print(A) for n in range(N - 1): score += Node.pop(0) num = A.pop() Node.append(num) Node.append(num) #print(Node) print(score)
s458668900
Accepted
210
31,560
328
N = int(input()) A = [] a, *an = map(int, input().split()) A.append(a) A += an A.sort() Node = [] score = 0 Node.append(A.pop()) #print(A) start = 0 for n in range(N - 1): score += Node[start] num = A.pop() start += 1 #Node = Node[1:] Node.append(num) Node.append(num) #print(Node) print(score)
s944739409
p03386
u277802731
2,000
262,144
Wrong Answer
17
3,060
127
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
#93b a,b,k=map(int,input().split()) for i in range(k): print(a+i) for i in range(k): print(b-k+i)
s537657782
Accepted
17
3,060
120
#93b a,b,k=map(int,input().split()) c=min(a+k,b) for i in range(a,c):print(i) for i in range(max(c,b-k+1),b+1):print(i)
s103741683
p03729
u694422786
2,000
262,144
Wrong Answer
17
2,940
90
You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `YES`. Otherwise, print `NO`.
a,b,c = map(str,input().split()) print("Yes" if a[-1] == b[0] and b[-1] == c[0] else "No")
s737738585
Accepted
17
2,940
92
a,b,c = map(str,input().split()) print("YES" if (a[-1] == b[0] and b[-1] == c[0]) else "NO")
s198877826
p03080
u517447467
2,000
1,048,576
Wrong Answer
17
2,940
121
There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat.
hat = input() num = 0 for i in hat: if i == "R": num += 1 if num > (len(hat)/2): print("Yes") else: print("No")
s924854221
Accepted
18
2,940
129
input() hat = input() num = 0 for i in hat: if i == "R": num += 1 if num > (len(hat)/2): print("Yes") else: print("No")
s133941464
p02853
u747602774
2,000
1,048,576
Wrong Answer
17
2,940
104
We held two competitions: Coding Contest and Robot Maneuver. In each competition, the contestants taking the 3-rd, 2-nd, and 1-st places receive 100000, 200000, and 300000 yen (the currency of Japan), respectively. Furthermore, a contestant taking the first place in both competitions receives an additional 400000 yen. DISCO-Kun took the X-th place in Coding Contest and the Y-th place in Robot Maneuver. Find the total amount of money he earned.
X,Y = map(int,input().split()) if X*Y == 1: print(10^6) else: print(10^5*(max(0,4-X)+max(0,4-X)))
s624801513
Accepted
17
2,940
106
X,Y = map(int,input().split()) if X*Y == 1: print(10**6) else: print(10**5*(max(0,4-X)+max(0,4-Y)))
s479804196
p03719
u772649753
2,000
262,144
Wrong Answer
17
2,940
89
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
A,B,C = map(int,input().split()) if A <= C and C <= B: print("YES") else: print("NO")
s727703895
Accepted
17
2,940
84
a,b,c = map(int, input().split()) if a <= c <= b: print("Yes") else: print("No")
s693353997
p03501
u752552310
2,000
262,144
Wrong Answer
17
2,940
78
You are parking at a parking lot. You can choose from the following two fee plans: * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours. * Plan 2: The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours.
n, a, b = map(int, input().split()) if n*a > b: print(n*a) else: print(b)
s321035363
Accepted
17
2,940
80
n, a, b = map(int, input().split()) if n*a >= b: print(b) else: print(n*a)
s533775667
p02972
u821284362
2,000
1,048,576
Wrong Answer
240
10,560
356
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.
N = int(input()) a_ls = list(map(int,input().split(" "))) a_ls_rev = a_ls[::-1] N_rev = [0]*N l = len(a_ls) for i,a in enumerate(a_ls_rev): s_2 = sum(N_rev[::(i+1)])%2 if s_2 != a: N_rev[i]+=1 s = "" for i,n in enumerate(N_rev[::-1]): if n == 1: s += "{} ".format(i+1) if len(s) == 0: print(0) else: print(s[:-1])
s020034564
Accepted
301
9,912
421
N = int(input()) a_ls = list(map(int,input().split(" "))) N = [0]*N l = len(a_ls) for i in range(l): a = a_ls[-(i+1)] s = sum(N[(l-i)-1::(l-i)])%2 # print(s) # print(a) if a != s: N[-(i+1)]=1 sen = "" for i,n in enumerate(N): if n == 1: sen += "{} ".format(i+1) if len(sen) == 0: print(0) else: print(sum(N)) print(sen[:-1])
s976543731
p03861
u209619667
2,000
262,144
Wrong Answer
17
2,940
87
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
A = list(map(int,input().split())) a=A[0] b=A[1] x=A[2] s = 0 n = 0 s=(b-a)//x print(s)
s771406015
Accepted
17
2,940
98
A = list(map(int,input().split())) a=A[0] b=A[1] x=A[2] a = (a-1) // x b = b // x s = b-a print(s)
s872687241
p02608
u457802431
2,000
1,048,576
Wrong Answer
2,207
47,312
250
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
def func(x,y,z): return x**2+y**2+z**2+x*y+y*z+z*x n = int(input()) ans = 0 arr = [] for x in range(1,100): for y in range(1,100): for z in range(1,100): arr.append(func(x,y,z)) for i in range(n): print(arr.count(i))
s024088619
Accepted
291
19,824
395
import itertools import math import collections def func(x,y,z): return x**2+y**2+z**2+x*y+y*z+z*x n = int(input()) ans = 0 arr = [] for x in range(1,100): for y in range(1,100): for z in range(1,100): ans = func(x,y,z) arr.append(ans) if ans > n: break c = collections.Counter(arr) for i in range(n): print(c[i+1])
s213168194
p03228
u009414205
2,000
1,048,576
Wrong Answer
18
3,060
256
In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi: * If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person. Find the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.
a, b, k = map(int, input().split()) for i in range(k): if i % 2 == 0: if a % 2 == 1: a -= 1 b += a / 2 a /= 2 else: if b % 2 == 1: b -= 1 a += b / 2 b /= 2 print(a, b)
s507420614
Accepted
17
2,940
260
a, b, k = map(int, input().split()) for i in range(k): if i % 2 == 0: if a % 2 == 1: a -= 1 b += a // 2 a //= 2 else: if b % 2 == 1: b -= 1 a += b // 2 b //= 2 print(a, b)
s760348727
p03110
u712082626
2,000
1,048,576
Wrong Answer
17
2,940
165
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative. For example, if x_1 = `10000` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins. If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?
N = int(input()) list = [] for i in range(N): a, b = input().split() list.append(float(a) if b == "JPY" else float(a) * 380000) print(list) print(sum(list))
s623379775
Accepted
17
2,940
153
N = int(input()) list = [] for i in range(N): a, b = input().split() list.append(float(a) if b == "JPY" else float(a) * 380000) print(sum(list))
s863434145
p00008
u742178809
1,000
131,072
Wrong Answer
30
7,528
215
Write a program which reads an integer n and identifies the number of combinations of a, b, c and d (0 ≤ a, b, c, d ≤ 9) which meet the following equality: a + b + c + d = n For example, for n = 35, we have 4 different combinations of (a, b, c, d): (8, 9, 9, 9), (9, 8, 9, 9), (9, 9, 8, 9), and (9, 9, 9, 8).
s = int(input()) results=set() for a in range(10): for b in range(10): for c in range(10): d = s-a-b-c if d<0:break if d<=9: results.add((a,b,c,d)) print(len(results))
s095801391
Accepted
40
7,712
379
import sys #from me.io import dup_file_stdin def solve(): for s in map(int,sys.stdin): results=set() for a in range(10): for b in range(10): for c in range(10): d = s-a-b-c if d<0:break if d<=9: results.add((a,b,c,d)) print(len(results)) solve()
s904112890
p04011
u241190800
2,000
262,144
Wrong Answer
19
2,940
152
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
NKXY = [int(input()) for i in range(4)] total=0 for i in range(NKXY[0]): if i<=NKXY[1]: total += NKXY[2] else: total += NKXY[3] print(total)
s528791439
Accepted
20
2,940
151
NKXY = [int(input()) for i in range(4)] total=0 for i in range(NKXY[0]): if i<NKXY[1]: total += NKXY[2] else: total += NKXY[3] print(total)
s511039289
p02613
u840570107
2,000
1,048,576
Wrong Answer
147
16,112
166
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.
n = int(input()) lis = [input() for _ in range(n)] dic = {"AC":0, "WA":0, "TLE":0, "RE":0} for x in lis: dic[x] += 1 for y in dic.keys(): print(y, "×", dic[y])
s305680114
Accepted
144
16,152
165
n = int(input()) lis = [input() for _ in range(n)] dic = {"AC":0, "WA":0, "TLE":0, "RE":0} for x in lis: dic[x] += 1 for y in dic.keys(): print(y, "x", dic[y])
s165499554
p02612
u810066979
2,000
1,048,576
Wrong Answer
25
9,136
30
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)
s238653723
Accepted
29
9,152
74
n = int(input()) ans = 1000 - n%1000 if ans ==1000: ans -=1000 print(ans)
s113756270
p03485
u141410514
2,000
262,144
Wrong Answer
17
2,940
50
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
a,b = map(int,input().split()) print(round(a+b)/2)
s395665705
Accepted
17
2,940
69
import math a,b = map(int,input().split()) print(math.ceil((a+b)/2))
s515225215
p02603
u924594299
2,000
1,048,576
Wrong Answer
34
9,252
699
To become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives. He is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows: * A_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day. In the i-th day, M-kun can make the following trade **any number of times** (possibly zero), **within the amount of money and stocks that he has at the time**. * Buy stock: Pay A_i yen and receive one stock. * Sell stock: Sell one stock for A_i yen. What is the maximum possible amount of money that M-kun can have in the end by trading optimally?
N = int(input()) A = list(map(int, input().split())) # dp[i]: dp = [0] * N dp[0] = 1000 for i in range(1, N): for j in range(0, i): v = int(dp[j] / A[j]) w = dp[j] - v*A[j] + v*A[i] print(v, w) dp[i] = max(dp[i-1], w) print(dp)
s523659706
Accepted
29
9,136
683
N = int(input()) A = list(map(int, input().split())) # dp[i]: dp = [0] * N dp[0] = 1000 for i in range(1, N): for j in range(0, i): v = int(dp[j] / A[j]) w = dp[j] - v*A[j] + v*A[i] dp[i] = max(dp[i-1], w) print(max(dp))
s705661947
p03457
u637289184
2,000
262,144
Wrong Answer
370
30,672
465
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()) t=[[0,0,0]] for i in range(N): A=list(map(int, input().strip().split())) t.append(A) flag3=0 for i in range(N): flag=0 flag2=0 time=t[i+1][0]-t[i][0] x=t[i+1][1]-t[i][1] y=t[i+1][2]-t[i][2] time=abs(time) x=abs(x) y=abs(y) if time==(x+y): flag=1 elif (time-(x+y))%2==0 and time>x+y: flag=1 if flag!=1: flag3=1 if flag3==1: print("No") else: print("Yes") print(t)
s783808345
Accepted
323
27,120
429
N = int(input()) t=[[0,0,0]] for i in range(N): A=list(map(int, input().strip().split())) t.append(A) flag=0 flag2=0 for i in range(N): flag=0 time=t[i+1][0]-t[i][0] x=t[i+1][1]-t[i][1] y=t[i+1][2]-t[i][2] time=abs(time) x=abs(x) y=abs(y) if (time-(x+y))%2==0 and time>=(x+y): flag=1 if flag!=1: flag2=1 if flag2==1: print("No") else: print("Yes")
s417681071
p03555
u238510421
2,000
262,144
Wrong Answer
18
2,940
126
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[2])&(C1[1]==C2[1])&(C1[2]==C2[0]): print("Yes") else: print("No")
s363718861
Accepted
17
2,940
126
C1 = list(input()) C2 = list(input()) if (C1[0]==C2[2])&(C1[1]==C2[1])&(C1[2]==C2[0]): print("YES") else: print("NO")
s355434779
p03455
u151625340
2,000
262,144
Wrong Answer
18
2,940
90
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
a,b = map(int,input().split()) if (a*b)% 2 == 0: print('Odd') else: print('Even')
s780283632
Accepted
17
2,940
91
a,b = map(int,input().split()) if (a*b)% 2 == 1: print('Odd') else: print('Even')
s110111866
p03836
u218838821
2,000
262,144
Wrong Answer
18
3,060
178
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
sx, sy, tx, ty = map(int,input().split()) print("U"*(ty-sy) + "R"*(tx-sx) + "U" + "L"*(tx-sx+1) + "D"*(ty-sy+1) + "R"*(tx-sx)+ "U"*(ty-sy) + "R" + "D"*(ty-sy+1) + "L"*(tx-sx+1))
s638474820
Accepted
17
3,064
191
sx, sy, tx, ty = map(int,input().split()) print("U"*(ty-sy) + "R"*(tx-sx) + "D"*(ty-sy) + "L"*(tx-sx) + "L" + "U"*(ty-sy+1) + "R"*(tx-sx+1) + "D" + "R" + "D"*(ty-sy+1) + "L"*(tx-sx+1) + "U")
s355981839
p03752
u351480677
1,000
262,144
Wrong Answer
176
3,636
636
There are N buildings along the line. The i-th building from the left is colored in color i, and its height is currently a_i meters. Chokudai is a mayor of the city, and he loves colorful thigs. And now he wants to see at least K buildings from the left. You can increase height of buildings, but it costs 1 yens to increase 1 meters. It means you cannot make building that height is not integer. You cannot decrease height of buildings. Calculate the minimum cost of satisfying Chokudai's objective. Note: "Building i can see from the left" means there are no j exists that (height of building j) ≥ (height of building i) and j < i.
n, k = map(int,input().split()) a = list(map(int,input().split())) res = float("inf") for i in range(2**n): if(i%2 == 0): continue useidx = [0 for _ in range(n)] usecnt = 0 for j in range(n): if (i>>j)&1: useidx[j] = 1 usecnt = usecnt+1 if (usecnt < k): continue sm = 0 mx = a[0] for j in range(1,n): if useidx[j]==1: if a[j]<=mx: print("a[j]="+str(a[j])) sm = sm + (mx+1)-a[j] print("max="+str(mx+1)) mx = mx +1 mx = max(mx, a[j]) res = min(res,sm) print(sm)
s577544404
Accepted
115
3,064
1,723
n, k = map(int, input().split()) a = list(map(int, input(). split())) res = 1 << 60 for i in range(1<<n): if(i%2 == 0): continue use_idx = [0 for _ in range(n)] use_cnt = 0 for j in range(n): if(i & (1<<j)): use_idx[j] = 1 use_cnt += 1 if(use_cnt != k): continue sm = 0 mx = a[0] for j in range(1, n): if(use_idx[j]): if(a[j] <= mx): sm += mx+1 - a[j] mx += 1 mx = max(mx, a[j]) res = min(res, sm) print(res)
s159060055
p03129
u191635495
2,000
1,048,576
Wrong Answer
17
2,940
108
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
import math n, k = map(int, input().split()) if k <= math.ceil(n/2): print("Yes") else: print("No")
s120043529
Accepted
17
3,064
108
import math n, k = map(int, input().split()) if k <= math.ceil(n/2): print("YES") else: print("NO")
s868020712
p02694
u579746769
2,000
1,048,576
Wrong Answer
22
9,172
91
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()) a=100 count=0 while a<=X: a=int(a+(a*0.01)) count=count+1 print(count)
s305501944
Accepted
25
9,164
90
X=int(input()) a=100 count=0 while a<X: a=int(a+(a*0.01)) count=count+1 print(count)
s846399056
p03371
u620480037
2,000
262,144
Wrong Answer
108
7,048
503
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.
input_line =input() input_line = input_line.rstrip().split(" ") a = int(input_line[0]) b = int(input_line[1]) c = int(input_line[2]) x = int(input_line[3]) y = int(input_line[4]) list1=[] for i in range(max(x,y)+1): if x-i<=0: cost = b*(y-i)+2*c*i list1.append(cost) i +=1 elif y-i<=0: cost = a*(x-i)+2*c*i list1.append(cost) i +=1 else: cost = a*(x-i)+b*(y-i)+2*c*i list1.append(cost) i +=1 print(min(list1))
s019434257
Accepted
120
3,064
202
A,B,C,X,Y=map(int,input().split()) ans=10**10 for i in range(max(X,Y)+1): cnt=0 cnt+=C*2*i x=X-i y=Y-i cnt+=max(0,x*A) cnt+=max(0,y*B) if ans>cnt: ans=cnt print(ans)
s749837905
p03090
u690536347
2,000
1,048,576
Wrong Answer
23
3,740
290
You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S. It can be proved that at least one such graph exists under the constraints of this problem.
from itertools import combinations as comb N = int(input()) n = N-1 if N%2 else N s = set() for i in range(1, N+1): if N%2: a, b = i, N-i else: a, b = i, N-i+1 if a<b: s.add((a, b)) for i in comb(range(1, N+1), 2): if not i in s: print(*i)
s439297057
Accepted
24
3,996
216
from itertools import combinations as comb N = int(input()) n = N-N%2 s = {(i, n+1-i) for i in range(1, N+1) if i<n+1-i} l = [i for i in comb(range(1, N+1), 2) if not i in s] print(len(l)) for i in l: print(*i)
s802855115
p02602
u458925609
2,000
1,048,576
Wrong Answer
274
31,612
340
M-kun is a student in Aoki High School, where a year is divided into N terms. There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows: * For the first through (K-1)-th terms: not given. * For each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term. M-kun scored A_i in the exam at the end of the i-th term. For each i such that K+1 \leq i \leq N, determine whether his grade for the i-th term is **strictly** greater than the grade for the (i-1)-th term.
N, K = list(map(int, input().split())) A = list(map(int, input().split())) results = list() for first, second in zip(A[0:N - K], A[K:N]): print(first, second) if second > first: results.append(True) else: results.append(False) for res in results: if res: print('Yes') else: print('No')
s723507313
Accepted
155
31,760
315
N, K = list(map(int, input().split())) A = list(map(int, input().split())) results = list() for first, second in zip(A[0:N - K], A[K:N]): if second > first: results.append(True) else: results.append(False) for res in results: if res: print('Yes') else: print('No')
s677711004
p03544
u101627912
2,000
262,144
Wrong Answer
17
3,060
126
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2)
# coding: utf-8 N=int(input()) lst=[2,1] for i in range(N): lst.append(lst[i]+lst[i+1]) print(lst[i+2]) print(lst[N])
s132489601
Accepted
17
2,940
106
# coding: utf-8 N=int(input()) lst=[2,1] for i in range(N): lst.append(lst[i]+lst[i+1]) print(lst[N])
s341427372
p03448
u189397279
2,000
262,144
Wrong Answer
49
3,064
263
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.
# -*- coding: utf-8 -*- A = int(input()) B = int(input()) C = int(input()) X = int(input()) count = 0 for i in range(1, A + 1): for j in range(1, B + 1): for k in range(1, C + 1): if 500 * i + 100 * j + 50 * k == X: count += 1 print(count)
s474259751
Accepted
52
3,060
256
# -*- coding: utf-8 -*- A = int(input()) B = int(input()) C = int(input()) X = int(input()) count = 0 for i in range(A + 1): for j in range(B + 1): for k in range(C + 1): if 500 * i + 100 * j + 50 * k == X: count += 1 print(count)
s024261579
p02273
u782850499
2,000
131,072
Wrong Answer
20
7,712
793
Write a program which reads an integer _n_ and draws a Koch curve based on recursive calles of depth _n_. The Koch curve is well known as a kind of You should start (0, 0), (100, 0) as the first segment.
import math as mt def kock(n, p1, p2): if n == 0: return s =[(2 * p1[0] + p2[0]) / 3 , (2 * p1[1] + p2[1]) / 3] t = [(p1[0] + 2 * p2[0]) / 3, (p1[1] + 2 * p2[1]) / 3] u = [(t[0]-s[0])*mt.cos(mt.radians(60)) -(t[1]-s[1])*mt.sin(mt.radians(60)) + s[0], (t[0]-s[0])*mt.sin(mt.radians(60)) +(t[1]-s[1])*mt.cos(mt.radians(60)) + s[1]] kock(n-1, p1, s) print("{0:.8f} {1:.8f}".format(s[1],s[0])) kock(n-1, s, u) print("{0:.8f} {1:.8f}".format(u[1],u[0])) kock(n-1, u, t) print("{0:.8f} {1:.8f}".format(t[1],t[0])) kock(n-1, t, p2) if __name__ == '__main__': n = 2 p1 = (0,0) p2 = (0,100) print("{0:.8f} {1:.8f}".format(p1[0],p1[1])) kock(n, p1, p2) print("{0:.8f} {1:.8f}".format(p2[0],p2[1]))
s338306445
Accepted
30
7,992
804
import math as mt def kock(n, p1, p2): if n == 0: return s =[(2 * p1[0] + p2[0]) / 3 , (2 * p1[1] + p2[1]) / 3] t = [(p1[0] + 2 * p2[0]) / 3, (p1[1] + 2 * p2[1]) / 3] u = [(t[0]-s[0])*mt.cos(mt.radians(60)) -(t[1]-s[1])*mt.sin(mt.radians(60)) + s[0], (t[0]-s[0])*mt.sin(mt.radians(60)) +(t[1]-s[1])*mt.cos(mt.radians(60)) + s[1]] kock(n-1, p1, s) print("{0:.8f} {1:.8f}".format(s[0],s[1])) kock(n-1, s, u) print("{0:.8f} {1:.8f}".format(u[0],u[1])) kock(n-1, u, t) print("{0:.8f} {1:.8f}".format(t[0],t[1])) kock(n-1, t, p2) if __name__ == '__main__': n = int(input()) p1 = (0,0) p2 = (100,0) print("{0:.8f} {1:.8f}".format(p1[0],p1[1])) kock(n, p1, p2) print("{0:.8f} {1:.8f}".format(p2[0],p2[1]))
s829864557
p03599
u092650292
3,000
262,144
Wrong Answer
25
3,064
505
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.
a,b,c,d,e,f = map(int, input().split(' ')) w = 0 s = 0 ratio = 0 for i in range((f // (b*100))+1): for j in range(((f-(i*b*100))//a)+1): if i == 0 and j == 0: continue smax = min(f-(j*a+i*b)*100,(j*a+i*b)*e) sm = 0 for k in range((smax//d)+1): sm = max(sm, k*d+c*((smax-(k*d))//c)) ratio = sm/((j*a+i*b)*100+sm) w = (j*a+i*b)*100 s = sm print("%i %i" %(w+s,s))
s449513463
Accepted
19
3,064
510
a,b,c,d,e,f = map(int, input().split(' ')) w = 0 s = 0 ratio = 0 for i in range((f // (b*100))+1): for j in range(((f-(i*b*100))//(a*100))+1): if i == 0 and j == 0: continue smax = min(f-(j*a+i*b)*100,(j*a+i*b)*e) sm = 0 for k in range((smax//d)+1): sm = max(sm, k*d+c*((smax-(k*d))//c)) if ratio <= sm/((j*a+i*b)*100+sm): ratio = sm/((j*a+i*b)*100+sm) w = (j*a+i*b)*100 s = sm print("%i %i" %(w+s,s))
s336737585
p03433
u684330841
2,000
262,144
Wrong Answer
18
3,188
121
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
N=int(input()) A=int(input()) for i in range(A): if (N-i)%500==0: print("Yes") else: print("No")
s418196095
Accepted
17
2,940
86
N=int(input()) A=int(input()) x=N%500 if x<=A: print("Yes") else: print("No")
s894853951
p03131
u995062424
2,000
1,048,576
Wrong Answer
27
9,176
144
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the maximum possible number of biscuits in Snuke's pocket after K operations.
K, A, B = map(int, input().split()) if(B-A <= 2): print(K+1) else: m = max(0, K-(A-1)//2)*(B-A)+(K+1)-2*max(0, K-(A-1)//2) print(m)
s906553675
Accepted
26
9,036
148
K, A, B = map(int, input().split()) if(B-A <= 2): print(K+1) else: m = max(0, (K-(A-1))//2)*(B-A)+(K+1)-2*max(0, (K-(A-1))//2) print(m)
s315546320
p04013
u789205676
2,000
262,144
Wrong Answer
2,108
21,832
269
Tak has N cards. On the i-th (1 \leq i \leq N) card is written an integer x_i. He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A. In how many ways can he make his selection?
import numpy as np n, a = map(int, input().split()) x = np.array(list(map(int, input().split()))) dp = {0:1} for y in x-a: for k, v in dp.copy().items(): print("before",dp) dp[y+k] = dp.get(y+k, 0) + v print("after",dp) print(dp[0]-1)
s291375065
Accepted
330
21,772
215
import numpy as np n, a = map(int, input().split()) x = np.array(list(map(int, input().split()))) dp = {0:1} for y in x-a: for k, v in dp.copy().items(): dp[y+k] = dp.get(y+k, 0) + v print(dp[0]-1)
s934686963
p02936
u501724534
2,000
1,048,576
Wrong Answer
2,109
91,976
953
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.
# -*- coding: utf-8 -*- """ Created on Mon Sep 16 21:29:27 2019 @author: lamducanhndgv """ class Node: def __init__(self): self.value = 0 self.next = [] def __add__(self, value): self.value += value return self def add_next(self, node): self.next.append(node) def solution(t): q = [] q.append((0, 0)) while q: addValue, tNode = q.pop(0) t[tNode] += addValue for i in t[tNode].next: q.append((t[tNode].value, i)) if __name__ == "__main__": N, Q = list(map(int, input().split())) tree = [Node() for i in range(N)] for _ in range(N - 1): a, b = list(map(int, input().split())) tree[a - 1].add_next(b - 1) for _ in range(Q): p, x = list(map(int, input().split())) tree[p - 1].value += x solution(tree) print(*(i.value for i in tree), end = "")
s605820547
Accepted
1,863
56,160
895
import collections n,q=map(int,input().split()) cnt=[0]*(n+1) g=[[] for _ in range(n+1)] for _ in range(n-1): a,b=map(int,input().split()) g[a].append(b) g[b].append(a) for _ in range(q): v,val=map(int,input().split()) cnt[v]+=val q=collections.deque() q.append(1) checked=[0]*(n+1) while q: v=q.pop() checked[v]=1 for u in g[v]: if checked[u]==1: continue cnt[u]+=cnt[v] q.append(u) print(*cnt[1:])
s169600701
p03712
u934868410
2,000
262,144
Wrong Answer
18
3,060
198
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
h,w = map(int, input().split()) for i in range(w): print('#', end='') print() for i in range(h): print('#', end='') print(input(), end='') print('#') for i in range(w): print('#', end='')
s187269831
Accepted
18
3,060
209
h,w = map(int, input().split()) for i in range(w+2): print('#', end='') print() for i in range(h): print('#', end='') print(input(), end='') print('#') for i in range(w+2): print('#', end='') print()
s630049861
p03007
u625729943
2,000
1,048,576
Wrong Answer
244
14,024
860
There are N integers, A_1, A_2, ..., A_N, written on a blackboard. We will repeat the following operation N-1 times so that we have only one integer on the blackboard. * Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y. Find the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.
N = int(input()) A = list(map(int, input().split())) A.sort() if N==2: print(A[-1] - A[0]) print(A[-1], A[0]) elif A[0]<0 and A[-1]<0: tmpA = A.copy() print(-sum(A[:-2]) + (A[-1]-A[-2])) for i in range(N-1): if i==0: print(A[-1], A[-2]) tmp = A[-1] - A[-2] elif i==N-2: print(tmp, A[-i-1]) else: print(tmp, A[-i-1]) tmp = tmp - A[i-1] elif A[0]>0 and A[-1]>0: tmpA = A.copy() print(sum(A[2:]) + (A[1] - A[0])) for i in range(N-1): if i==0: print(A[0], A[1]) tmp = A[0] - A[1] elif i==N-2: print(A[i+1], tmp) else: print(tmp, A[i+1]) tmp = tmp - A[i+1] else: tmpA = A.copy() len_of_Apos = len([a for a in A if a>=0]) len_of_Aneg = len([a for a in A if a<0]) zero_in = 0 in A minv = min(len_of_Aneg, len_of_Apos) print(sum([abs(a) for a in A]))
s081118959
Accepted
129
18,132
490
def c(N, A): A.sort() maximum = A.pop() minimum = A.pop(0) operation = [] for a in A: if a >= 0: operation.append('{} {}'.format(minimum, a)) minimum -= a else: operation.append('{} {}'.format(maximum, a)) maximum -= a operation.append('{} {}'.format(maximum, minimum)) return str(maximum - minimum) + '\n' + '\n'.join(operation) N = int(input()) A = list(map(int, input().split())) print(c(N, A))
s513964958
p03385
u126823513
2,000
262,144
Wrong Answer
17
2,940
134
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
str_i = input() if str_i.count('a') == 1 and str_i.count('b') == 1 and str_i.count('c') == 1: print('YES') else: print('No')
s367801148
Accepted
17
2,940
134
str_i = input() if str_i.count('a') == 1 and str_i.count('b') == 1 and str_i.count('c') == 1: print('Yes') else: print('No')
s855995061
p03493
u416758623
2,000
262,144
Wrong Answer
17
2,940
118
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
sentence = input().split() count = 0 for i in range(len(sentence)): if sentence[i] == 1: count+=1 print(count)
s478994599
Accepted
17
2,940
91
s = input() ans = 0 for i in range(len(s)): if s[i] == "1": ans += 1 print(ans)
s053386187
p03110
u261891508
2,000
1,048,576
Wrong Answer
17
3,060
140
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative. For example, if x_1 = `10000` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins. If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?
n=int(input()) ans=0 for i in range(n): x,u=input().split() x=float(x) if u=="JPY": ans+=x else: ans+=3800*x print(int(ans))
s254647977
Accepted
18
2,940
137
n=int(input()) ans=0 for i in range(n): x,u=input().split() x=float(x) if u=="JPY": ans+=x else: ans+=380000*x print(ans)
s558858965
p03574
u846634344
2,000
262,144
Wrong Answer
29
3,064
690
You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process.
import sys if sys.platform =='ios': sys.stdin=open('input.txt') h, w = [int(x) for x in input().split()] board = [input() for _ in range(h)] mines=['' for _ in range(h)] print(board) for row in range(h): for col in range(w): if board[row][col] != '#': counts = 0 dx = [x for x in range(-1, 2) if (col+x>=0 and col+x<w)] dy = [y for y in range(-1, 2) if (row+y>=0 and row+y<h)] #print('row:{}, col:{}, dx:{}, dy:{}'.format(row,col,dx,dy)) for x in dx: for y in dy: #print('row+y:{}, col+x:{}'.format(row+y, col+x)) if board[row+y][col+x] == '#': counts += 1 mines[row] += str(counts) else: mines[row] += '#' for mine in mines: print(mine)
s900589186
Accepted
29
3,064
765
h, w = [int(x) for x in input().split()] board = [input() for _ in range(h)] mines=['' for _ in range(h)] #print(board) for row in range(h): for col in range(w): if board[row][col] != '#': counts = 0 dx = [x for x in range(-1, 2) if (col+x>=0 and col+x<w)] dy = [y for y in range(-1, 2) if (row+y>=0 and row+y<h)] #print('row:{}, col:{}, dx:{}, dy:{}'.format(row,col,dx,dy)) for x in dx: for y in dy: #print('row+y:{}, col+x:{}'.format(row+y, col+x)) if board[row+y][col+x] == '#': counts += 1 mines[row] += str(counts) else: mines[row] += '#' for mine in mines: print(mine)
s996614369
p04043
u342106216
2,000
262,144
Wrong Answer
17
2,940
235
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
data = input().split() def main(data): five_num = data.count(5) seven_num = data.count(7) if five_num == 2 and seven_num == 1: print("YES") else: print("NO") if __name__ == "__main__": main(data)
s753267174
Accepted
17
2,940
239
data = input().split() def main(data): five_num = data.count("5") seven_num = data.count("7") if five_num == 2 and seven_num == 1: print("YES") else: print("NO") if __name__ == "__main__": main(data)
s392386253
p03699
u606174760
2,000
262,144
Wrong Answer
2,125
339,052
454
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
# -*- coding:utf-8 -*- import sys, itertools N = int(input()) Sn = sorted([int(input()) for i in range(N)]) total = sum(Sn) print(total) if total % 10 != 0: print(total) sys.exit() sub_set = set(Sn) for i in range(2, N): comb = [sum(l) for l in itertools.combinations(Sn, i)] for c in comb: sub_set.add(c) for sub in sorted(sub_set): if (total - sub) % 10 != 0: print(total - sub) break else: print(0)
s040493080
Accepted
18
3,060
353
# -*- coding:utf-8 -*- import sys N = int(input()) Sn = sorted([int(input()) for i in range(N)]) total = sum(Sn) if total % 10 != 0: print(total) sys.exit() else: i = 0 while True: if (total - Sn[i]) % 10 != 0: print(total - Sn[i]) sys.exit() i += 1 if i == N: break print(0)
s438547710
p01102
u481571686
8,000
262,144
Wrong Answer
20
5,584
442
The programming contest named _Concours de Programmation Comtemporaine Interuniversitaire_ (CPCI) has a judging system similar to that of ICPC; contestants have to submit correct outputs for two different inputs to be accepted as a correct solution. Each of the submissions should include the program that generated the output. A pair of submissions is judged to be a correct solution when, in addition to the correctness of the outputs, they include an identical program. Many contestants, however, do not stop including a different version of their programs in their second submissions, after modifying a single string literal in their programs representing the input file name, attempting to process different input. The organizers of CPCI are exploring the possibility of showing a special error message for such _close_ submissions, indicating contestants what's wrong with such submissions. Your task is to detect such close submissions.
A=[] while True: a=input().split('"') if a[0]==".": break b=input().split('"') cnt=0 if len(a)!=len(b): A.append(-1) else: for i in range(len(a)): if(a[i]==b[i]): pass else: cnt+=1 if cnt==2: A.append(-1) if cnt==1: A.append(0) if cnt==0: A.append(1) A.reverse() for i in range(len(A)): tmp=A.pop() if tmp==-1: print("DIFFERENT") elif tmp==0: print("CLOSE") else: print("IDENTICAL")
s510258139
Accepted
20
5,592
487
A=[] while True: a=input().split('"') if a[0]==".": break b=input().split('"') cnt=0 if len(a)!=len(b): A.append(-1) else: for i in range(len(a)): if(a[i]==b[i]): pass else: if i%2==1: cnt+=1 else: cnt+=2 if cnt>=2: A.append(-1) if cnt==1: A.append(0) if cnt==0: A.append(1) A.reverse() #print(A) for i in range(len(A)): tmp=A.pop() if tmp==-1: print("DIFFERENT") elif tmp==0: print("CLOSE") else: print("IDENTICAL")
s663595754
p03400
u331997680
2,000
262,144
Wrong Answer
19
3,188
218
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces. Find the number of chocolate pieces prepared at the beginning of the camp.
N = int(input()) D, X = map(int, input().split()) A = [int(input()) for i in range(N)] B = [] for i in A: if D//i > 0: B.append(D//i+1) elif D//i == 0: B.append(D//i) else: B.append(1) print(sum(B)+X)
s220813485
Accepted
19
3,060
152
N = int(input()) D, X = map(int, input().split()) A = [int(input()) for i in range(N)] B = [] for i in A: n = (D-1)//i+1 B.append(n) print(sum(B)+X)
s718347695
p00013
u776559258
1,000
131,072
Wrong Answer
20
7,492
174
This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top- right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. We can simulate the movement (comings and goings) of the cars as follow: * An entry of a car is represented by its number. * An exit of a car is represented by 0 For example, a sequence 1 6 0 8 10 demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks.
# coding: utf-8 L=[] while True: try: n=int(input()) if n==0: L.pop() else: L.append(n) except EOFError: break
s222976081
Accepted
20
7,528
199
# coding: utf-8 L=[] while True: try: n=int(input()) if n==0: print(L[-1]) L.pop() else: L.append(n) except EOFError: break
s232836489
p02612
u092614249
2,000
1,048,576
Wrong Answer
28
9,152
98
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()) if n%1000 == 0: print(0) else: while n > 1000: n = n - 1000 print(n)
s211391658
Accepted
29
9,116
105
n = int(input()) if n%1000 == 0: print(0) else: while n > 1000: n = n - 1000 print(1000 - n)
s054499080
p03378
u532502139
2,000
262,144
Wrong Answer
17
3,064
243
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right. Initially, you are in Square X. You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N. However, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0, Square X and Square N. Find the minimum cost incurred before reaching the goal.
a=[int(x) for x in input().split()] n = a[0] m = a[1] x = a[2] arr = a[3:3+m] goLeft = 0 goRight = 0 for i in arr: if i < x: goLeft += 1 else: goRight += 1 if goLeft > goRight: print(goRight) else: print(goLeft)
s600285908
Accepted
17
3,060
206
n,m,x=[int(x) for x in input().split()] arr=[int(x) for x in input().split()] goLeft = 0 goRight = 0 for i in arr: if i < x: goLeft += 1 else: goRight += 1 print(min(goLeft,goRight))
s627735543
p02393
u294922877
1,000
131,072
Wrong Answer
20
7,544
56
Write a program which reads three integers, and prints them in ascending order.
nums=list(map(int, input().split())) print(sorted(nums))
s895144397
Accepted
20
5,584
66
print(" ".join(map(str, sorted(list(map(int,input().split()))))))
s105217162
p04029
u881472317
2,000
262,144
Wrong Answer
17
2,940
39
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?
n = int(input()) print((n + 1) * n / 2)
s630150067
Accepted
19
2,940
45
n = int(input()) print(int((n + 1) * n / 2))
s348858239
p03719
u013756322
2,000
262,144
Wrong Answer
17
2,940
94
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
a, b, c = map(int, input().split()) if (a <= c and c <= b): print('YES') else: print('NO')
s411753106
Accepted
17
2,940
88
a, b, c = map(int, input().split()) if (a <= c <= b): print('Yes') else: print('No')
s999661727
p04043
u686253980
2,000
262,144
Wrong Answer
17
2,940
202
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
s = [int(i) for i in input().split(' ')] n = [0] * 5 for i in s: if i == 5: n[0] += 1 elif i == 7: n[1] += 1 if n[0] == 2 and n[1] == 1: print('Yes') else: print('No')
s890795783
Accepted
17
3,060
205
s = [int(i) for i in input().split(' ')] n = [0] * 2 for i in s: if i == 5: n[0] += 1 elif i == 7: n[1] += 1 if n[0] == 2 and n[1] == 1: print('YES') else: print('NO')
s326159088
p03739
u760802228
2,000
262,144
Wrong Answer
256
14,468
588
You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero. * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.
n = int(input()) a = list(map(int, input().split())) def check(f): flag = f t = 0 c = 0 for i in range(n): if t + a[i] <= 0 and flag == 1: c += 1 - t - a[i] t = 1 elif t + a[i] >= 0 and flag == -1: c += 1 + t + a[i] t = -1 else: t += a[i] flag *= -1 print(t) return c total_p = check(1) total_m = check(-1) print(min(total_p, total_m))
s116832632
Accepted
110
14,468
563
n = int(input()) a = list(map(int, input().split())) def check(f): flag = f t = 0 c = 0 for i in range(n): if t + a[i] <= 0 and flag == 1: c += 1 - t - a[i] t = 1 elif t + a[i] >= 0 and flag == -1: c += 1 + t + a[i] t = -1 else: t += a[i] flag *= -1 return c total_p = check(1) total_m = check(-1) print(min(total_p, total_m))
s898659067
p03044
u839857256
2,000
1,048,576
Wrong Answer
2,225
1,993,844
796
We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied: * For any two vertices painted in the same color, the distance between them is an even number. Find a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.
from collections import deque def bfs(s): flag_list[s] = 1 color_list[s] = 0 q.append(s) while len(q)>0: u = q.popleft() for v in range(n): if m_list[u][v] > 0 and flag_list[v] == 0: flag_list[v] = 1 if color_list[u] == 0: color_list[v] = 1 else: color_list[v] = 0 q.append(v) flag_list[u] = 2 if __name__ == "__main__": n = int(input()) m_list = [[0]*n for _ in range(n)] color_list = [0]*n flag_list = [0]*n q = deque([]) for _ in range(n-1): u, v, w = map(int, input().split()) m_list[u-1][v-1] = w m_list[v-1][u-1] = w bfs(0) for color in color_list: print(color)
s297908651
Accepted
774
46,140
854
import sys from collections import deque def bfs(s): color_list[s] = 0 flag_list[s] = 1 q.append(s) while len(q) > 0: u = q.popleft() for v, w in m_list[u]: if flag_list[v] == 0: flag_list[v] = 1 if w%2 == 0: color_list[v] = color_list[u] else: color_list[v] = (color_list[u]+1)%2 q.append(v) flag_list[u] = 2 if __name__ == "__main__": input = sys.stdin.readline n = int(input()) m_list = [[]*n for _ in range(n)] color_list = [0]*n flag_list = [0]*n q = deque([]) for _ in range(n-1): u, v, w = map(int, input().split()) m_list[u-1].append([v-1, w]) m_list[v-1].append([u-1, w]) bfs(0) for color in color_list: print(color)
s793857291
p03251
u996434204
2,000
1,048,576
Wrong Answer
17
3,060
211
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
n,m,X,Y=map(int,input().split()) p_x=[int(j) for j in input().split()] p_y=[int(i) for i in input().split()] max_x=max(p_x) Z=min(p_y) if max_x<Z and (X<Z and X<=Y): print('No war') else: print('War')
s365706867
Accepted
17
3,060
211
n,m,X,Y=map(int,input().split()) p_x=[int(j) for j in input().split()] p_y=[int(i) for i in input().split()] max_x=max(p_x) Z=min(p_y) if max_x<Z and (X<Z and Z<=Y): print('No War') else: print('War')
s428605935
p02865
u921773161
2,000
1,048,576
Wrong Answer
17
2,940
12
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
print('Yes')
s442159135
Accepted
18
2,940
46
#%% n = int(input()) ans = (n-1)//2 print(ans)
s036470580
p03469
u584153341
2,000
262,144
Wrong Answer
17
2,940
30
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.
print('2017'+str(input())[4:])
s483108474
Accepted
17
2,940
31
print('2018'+str(input())[4:])
s930282939
p03401
u360116509
2,000
262,144
Wrong Answer
188
14,048
326
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled.
def main(): N = int(input()) + 2 A = list(map(int, input().split())) A.insert(0, 0) A.append(0) D = sum([abs(A[i + 1] - A[i]) for i in range(N - 1)]) print(D) for i in range(1, N - 1): print(D - abs(A[i - 1] - A[i]) - abs(A[i] - A[i + 1]) + abs(A[i - 1] - A[i + 1])) main()
s695930082
Accepted
195
14,044
313
def main(): N = int(input()) + 2 A = list(map(int, input().split())) A.insert(0, 0) A.append(0) D = sum([abs(A[i + 1] - A[i]) for i in range(N - 1)]) for i in range(1, N - 1): print(D - abs(A[i - 1] - A[i]) - abs(A[i] - A[i + 1]) + abs(A[i - 1] - A[i + 1])) main()
s490484156
p02694
u423282882
2,000
1,048,576
Wrong Answer
23
9,168
168
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?
import math X = int(input()) money = 100 counts=0 while True: counts+=1 money=money+math.floor((money*0.01)) if X<money: print(counts) break
s966319298
Accepted
24
9,164
169
import math X = int(input()) money = 100 counts=0 while True: money=money+math.floor((money*0.01)) counts+=1 if X<=money: print(counts) break
s156563838
p03162
u480138356
2,000
1,048,576
Wrong Answer
498
30,580
375
Taro's summer vacation starts tomorrow, and he has decided to make plans for it now. The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day: * A: Swim in the sea. Gain a_i points of happiness. * B: Catch bugs in the mountains. Gain b_i points of happiness. * C: Do homework at home. Gain c_i points of happiness. As Taro gets bored easily, he cannot do the same activities for two or more consecutive days. Find the maximum possible total points of happiness that Taro gains.
N = int(input()) h = [] for i in range(N): h.append(list(map(int, input().split(" ")))) cost = h[-1] today_cost = [0 for i in range(3)] for day in range(N-2, -1, -1): today_cost[0] = h[day][0] + max(cost[1], cost[2]) today_cost[1] = h[day][1] + max(cost[0], cost[2]) today_cost[2] = h[day][2] + max(cost[0], cost[1]) cost = today_cost print(max(cost))
s664825357
Accepted
513
30,580
369
N = int(input()) h = [] for i in range(N): h.append(list(map(int, input().split(" ")))) cost = h[-1] for day in range(N-2, -1, -1): today_cost = [] today_cost.append(h[day][0] + max(cost[1], cost[2])) today_cost.append(h[day][1] + max(cost[0], cost[2])) today_cost.append(h[day][2] + max(cost[0], cost[1])) cost = today_cost print(max(cost))
s339102795
p03377
u768896740
2,000
262,144
Wrong Answer
17
2,940
98
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, x = map(int, input().split()) if x < a or x > a + b: print('No') else: print('Yes')
s305210212
Accepted
17
2,940
98
a, b, x = map(int, input().split()) if x < a or x > a + b: print('NO') else: print('YES')
s979732917
p02694
u189604332
2,000
1,048,576
Wrong Answer
25
9,248
153
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?
import math X = int(input()) res = 100 count = 0 while X > res: res = math.floor(res * 1.01) print(str(res)) count +=1 print(str(count))
s842501287
Accepted
22
9,180
133
import math X = int(input()) res = 100 count = 0 while X > res: res = math.floor(res * 1.01) count +=1 print(str(count))
s626550680
p02602
u033839917
2,000
1,048,576
Wrong Answer
2,206
33,984
259
M-kun is a student in Aoki High School, where a year is divided into N terms. There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows: * For the first through (K-1)-th terms: not given. * For each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term. M-kun scored A_i in the exam at the end of the i-th term. For each i such that K+1 \leq i \leq N, determine whether his grade for the i-th term is **strictly** greater than the grade for the (i-1)-th term.
N,K = [int(i)for i in input().split()] A = [int(i) for i in input().split()] S = [] for i in range(K-1,N): s = 1 for j in range(i,i-K,-1): s *= A[j] S.append(s) print(S) for i in range(1,len(S)): print("Yes" if S[i-1]<S[i] else "No")
s789691648
Accepted
152
31,628
178
N,K = [int(i)for i in input().split()] A = [int(i) for i in input().split()] for i in range(K,N): if A[i] / A[i-K] > 1 : print("Yes") else : print("No")
s773438760
p04044
u842689614
2,000
262,144
Wrong Answer
17
2,940
91
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.
N,L=map(int,input().split()) s=[] for n in range(N): s.append(input()) "".join(sorted(s))
s364637151
Accepted
18
3,060
98
N,L=map(int,input().split()) s=[] for n in range(N): s.append(input()) print("".join(sorted(s)))
s121340536
p02612
u114365796
2,000
1,048,576
Wrong Answer
29
9,032
125
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.
amount = int(input()) if(amount % 1000 == 0): print(0) else: change = (amount / 1000 + 1) * 1000 - amount print(change)
s005451991
Accepted
29
9,036
126
amount = int(input()) if(amount % 1000 == 0): print(0) else: change = (amount // 1000 + 1) * 1000 - amount print(change)
s907280064
p04044
u006167882
2,000
262,144
Wrong Answer
16
3,060
121
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.
N, L = map(int,input().split()) l = [] for i in range(N): l.append(input()) l.sort result = ''.join(l) print(result)
s139660160
Accepted
17
3,060
123
N, L = map(int,input().split()) l = [] for i in range(N): l.append(input()) l.sort() result = ''.join(l) print(result)
s760055483
p03719
u720417458
2,000
262,144
Wrong Answer
20
3,316
90
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
A, B, C = map(int, input().split()) if C < B: if C > A: print('YES') else: print('NO')
s660736346
Accepted
17
2,940
84
A, B, C = map(int, input().split()) if A <= C <= B: print('Yes') else: print('No')
s289025938
p02613
u030819239
2,000
1,048,576
Wrong Answer
150
16,048
150
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.
N = int(input()) S = list() for i in range(N): S.append(input()) for k in ['AC', 'TLE', 'WA', 'RE']: print('{0} x {1}'.format(k, S.count(k)))
s909039523
Accepted
147
16,240
150
N = int(input()) S = list() for i in range(N): S.append(input()) for k in ['AC', 'WA', 'TLE', 'RE']: print('{0} x {1}'.format(k, S.count(k)))
s629474975
p03860
u171014488
2,000
262,144
Wrong Answer
17
2,940
25
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.
print("A"+input()[0]+"C")
s994617165
Accepted
17
2,940
25
print("A"+input()[8]+"C")
s900130341
p03545
u634079249
2,000
262,144
Wrong Answer
18
3,064
936
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
import sys import os ii = lambda: int(sys.stdin.buffer.readline().rstrip()) il = lambda: list(map(int, sys.stdin.buffer.readline().split())) iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)] iss = lambda: sys.stdin.buffer.readline().decode().rstrip() isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)] def main(): if os.getenv("LOCAL"): sys.stdin = open("input.txt", "r") *S, = iss() print(S) E = ['+', '-'] tmp = [0] * 7 for e in E: tmp[0] = S[0] tmp[1] = e for e in E: tmp[2] = S[1] tmp[3] = e for e in E: tmp[4] = S[2] tmp[5] = e tmp[6] = S[3] ans = ''.join(map(str, tmp)) if eval(ans) == 7: print(ans + '=7') exit() if __name__ == '__main__': main()
s451117400
Accepted
18
3,064
923
import sys import os ii = lambda: int(sys.stdin.buffer.readline().rstrip()) il = lambda: list(map(int, sys.stdin.buffer.readline().split())) iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)] iss = lambda: sys.stdin.buffer.readline().decode().rstrip() isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)] def main(): if os.getenv("LOCAL"): sys.stdin = open("input.txt", "r") *S, = iss() E = ['+', '-'] tmp = [0] * 7 for e in E: tmp[0] = S[0] tmp[1] = e for e in E: tmp[2] = S[1] tmp[3] = e for e in E: tmp[4] = S[2] tmp[5] = e tmp[6] = S[3] ans = ''.join(map(str, tmp)) if eval(ans) == 7: print(ans + '=7') exit() if __name__ == '__main__': main()
s051952495
p03556
u507116804
2,000
262,144
Wrong Answer
2,104
19,464
117
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
n=int(input()) for i in range(n): if (float.is_integer(n**0.5)): print(n) else: n=n-1
s174669253
Accepted
50
3,444
113
n=int(input()) a=n for i in range(n): if (float.is_integer(a**0.5)): print(a) break else: a=a-1
s954019779
p03472
u771365068
2,000
262,144
Wrong Answer
436
36,820
430
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?
import math N, H = map(int, input().split()) swords = [list(map(int, input().split())) for _ in range(N)] swords_T = [list(x) for x in zip(*swords)] #print(swords_T) swing_max = max(swords_T[0]) order = sorted(swords_T[1]) print(order) count = 0 while H > 0 and len(order) != 0: tmp = order.pop() if tmp > swing_max: H -= tmp count += 1 #print(f'{H=}') count += math.ceil(H/swing_max) print(count)
s938405191
Accepted
427
36,820
444
import math N, H = map(int, input().split()) swords = [list(map(int, input().split())) for _ in range(N)] swords_T = [list(x) for x in zip(*swords)] #print(swords_T) swing_max = max(swords_T[0]) order = sorted(swords_T[1]) #print(order) count = 0 while H > 0 and len(order) != 0: tmp = order.pop() if tmp > swing_max: H -= tmp count += 1 #print(f'{H=}') if H > 0: count += math.ceil(H/swing_max) print(count)
s358054946
p03448
u145035045
2,000
262,144
Wrong Answer
50
3,316
212
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): if (a * 500 + b* 100 + c * 50 == x): ans += 1 print(ans)
s016229622
Accepted
48
3,060
221
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): if ((i * 500 + j * 100 + k * 50) == x): ans += 1 print(ans)
s826960194
p03493
u188272222
2,000
262,144
Wrong Answer
17
2,940
18
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
input().count('1')
s667554464
Accepted
17
2,940
25
print(input().count('1'))