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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s859823771 | p03455 | u306060982 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 88 | 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') | s154630834 | Accepted | 17 | 2,940 | 88 | a,b = map(int,input().split())
if a * b % 2 == 1:
print('Odd')
else:
print('Even') |
s181881245 | p03371 | u974792613 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 293 | "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. |
a,b,c,x,y = map(int, input().split())
price1 = x*a + y*b
price2 = max(x, y)*2*c
if x<=y:
price3 = x*2*c
price3 += (y-x)*b
else:
price3 = y*2*c
price3 += (y-x)*a
print(min(price1, price2, price3)) | s036769270 | Accepted | 17 | 2,940 | 292 |
a, b, c, x, y = map(int, input().split())
price1 = x * a + y * b
price2 = max(x, y) * 2 * c
price3 = min(x, y) * 2 * c + a * (x - min(x, y)) + b * (y - (min(x, y)))
print(min(price1, price2, price3))
|
s129045001 | p03720 | u075595666 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 274 | There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city? | n,m = [int(i) for i in input().split()]
ab = []
for i in range(m):
ay = list(map(int,input().split()))
ab.append(ay)
ans = []
for i in range(n):
ans.append(0)
for i in range(m):
for j in range(1,n+1):
#print(i,j)
if j in ab[i]:
ans[j-1] += 1
print(ans) | s688317959 | Accepted | 18 | 3,064 | 298 | n,m = [int(i) for i in input().split()]
ab = []
for i in range(m):
ay = list(map(int,input().split()))
ab.append(ay)
ans = []
for i in range(n):
ans.append(0)
for i in range(m):
for j in range(1,n+1):
#print(i,j)
if j in ab[i]:
ans[j-1] += 1
for i in range(n):
print(ans[i]) |
s085672589 | p03971 | u137214546 | 2,000 | 262,144 | Wrong Answer | 67 | 10,012 | 534 | 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. | def qsimulator(s, a, b):
paas = 0
bpaas = 0
aflg = True
bflg = True
total = a + b
res = []
for i in s:
if i == 'c':
res.append("No")
elif i == 'a':
if aflg and paas <= total:
paas += 1
res.append("Yes")
else:
aflg = False
res.append("No")
else:
if bflg and paas <= total and bpaas < b:
paas += 1
bpaas += 1
res.append("Yes")
else:
bflg = False
res.append("No")
return res
n, a, b = map(int, input().split())
s = input()
ans = qsimulator(s, a, b)
for i in ans:
print(i) | s401685904 | Accepted | 65 | 9,952 | 532 | def qsimulator(s, a, b):
paas = 0
bpaas = 0
aflg = True
bflg = True
total = a + b
res = []
for i in s:
if i == 'c':
res.append("No")
elif i == 'a':
if aflg and paas < total:
paas += 1
res.append("Yes")
else:
aflg = False
res.append("No")
else:
if bflg and paas < total and bpaas < b:
paas += 1
bpaas += 1
res.append("Yes")
else:
bflg = False
res.append("No")
return res
n, a, b = map(int, input().split())
s = input()
ans = qsimulator(s, a, b)
for i in ans:
print(i) |
s641312151 | p03997 | u331464808 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 73 | 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())
s = (a+b)*h/2
print(s) | s193582908 | Accepted | 17 | 2,940 | 78 | a = int(input())
b = int(input())
h = int(input())
s = (a+b)*h/2
print(int(s)) |
s722561816 | p02612 | u642098073 | 2,000 | 1,048,576 | Wrong Answer | 29 | 9,088 | 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) | s237171990 | Accepted | 25 | 9,116 | 78 | n = int(input())
if n % 1000 == 0:
print(0)
else:
print(1000 - (n % 1000)) |
s760630573 | p03380 | u842950479 | 2,000 | 262,144 | Wrong Answer | 2,104 | 14,436 | 359 | Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted. | import math
n=int(input().rstrip())
A=list(map(int, input().rstrip().split()))
A.sort()
work=int()
bestr=int()
def comb(x,y):
return(math.factorial(x)/(math.factorial(x-y)*math.factorial(y)))
for i in range(n-2):
if comb(A[n-1],A[i-1])>work:
work=comb(A[n-1],A[i-1])
bestr=A[i-1]
print("{0} {1}".format(A[n-1],bestr)) | s855564195 | Accepted | 152 | 14,428 | 444 | n=int(input().rstrip())
A=list(map(int, input().rstrip().split()))
A.sort()
work=int()
bestr=int(A[0])
#def comb(x,y):
# return(math.factorial(x)/(math.factorial(x-y)*math.factorial(y)))
# if comb(A[n-1],A[i-1])>work:
for i in range(n-2):
if abs(A[i]-A[n-1]/2)<abs(bestr-A[n-1]/2):
bestr=A[i]
print("{0} {1}".format(A[n-1],bestr)) |
s893063212 | p03360 | u690536347 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 93 | 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? | l=list(map(int,input().split()))
k=int(input())
m=max(l)
l.pop(l.index(m))
print(sum(l)+m**k) | s887700651 | Accepted | 17 | 2,940 | 97 | l=list(map(int,input().split()))
k=int(input())
m=max(l)
l.pop(l.index(m))
print(sum(l)+m*(2**k)) |
s329520971 | p04030 | u751047721 | 2,000 | 262,144 | Wrong Answer | 39 | 3,064 | 110 | Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now? | A = []
S = input()
S=list(str(S))
for n in S:
if n == "b":
A.pop(-1)
else:
A.append(n)
print("".join(A)) | s432837259 | Accepted | 38 | 3,064 | 133 | I = input()
A =''
for n in I:
if n == '0':
A += '0'
elif n == '1':
A += '1'
else:
if len(A) > 0:
A = A[:-1]
print(A)
|
s357404829 | p03486 | u875028418 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 51 | You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order. | a,b = input(),input()
print("Yes" if a<b else "No") | s212919300 | Accepted | 17 | 2,940 | 68 | print("Yes" if sorted(input())<sorted(input(),reverse=1) else "No")
|
s543268333 | p02613 | u205145698 | 2,000 | 1,048,576 | Wrong Answer | 32 | 9,072 | 265 | 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=map(int,input().split())
S=list(map(str,input().split()))
AC=S.count('AC')
WA=S.count('WA')
TLE=S.count('TLE')
RE=S.count('RE')
print("AC×", end='')
print(AC)
print("WA×", end='')
print(WA)
print("TLE×", end='')
print(TLE)
print("RE×", end='')
print(RE) | s403731975 | Accepted | 154 | 16,176 | 286 | N=int(input())
S=[]
for i in range(0, N):
val = input()
S.append(val)
ac=S.count('AC')
wa=S.count('WA')
tle=S.count('TLE')
re=S.count('RE')
print("AC x ", end='')
print(ac)
print("WA x ", end='')
print(wa)
print("TLE x ", end='')
print(tle)
print("RE x ", end='')
print(re) |
s023944327 | p04011 | u588081069 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 449 | 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. | String = str(input())
## print(char.count(String) & 1)
result = {}
for char in String:
try:
result[char] += 1
except KeyError:
result[char] = 1
result = list(map(lambda x: x % 2, list(result.values())))
if result == [0] * len(result):
print('Yes')
else:
print('No')
| s648354649 | Accepted | 19 | 3,060 | 259 | N = int(input())
K = int(input())
X = int(input())
Y = int(input())
result = 0
for i in range(1, N+1):
if i <= K:
result += X
else:
result += Y
print(result) |
s085842488 | p02389 | u071333111 | 1,000 | 131,072 | Wrong Answer | 20 | 5,580 | 67 | Write a program which calculates the area and perimeter of a given rectangle. | #!/usr/bin/env python
a, b = map(int, input().split())
print(a*b)
| s090454378 | Accepted | 20 | 5,580 | 92 | #!/usr/bin/env python
a, b = map(int, input().split())
print("{} {}".format(a*b, 2*(a+b)))
|
s110215076 | p02613 | u957843607 | 2,000 | 1,048,576 | Wrong Answer | 151 | 9,216 | 305 | 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())
str_lis = []
C0 = 0
C1 = 0
C2 = 0
C3 = 0
for i in range(N):
result = input()
if result == "AC":
C0 += 1
elif result == "WA":
C1 += 1
elif result == "TLE":
C2 += 1
else:
C3 += 1
print("AC × ", C0)
print("WA × ", C1)
print("TLE × ", C2)
print("RE × ", C3) | s928887045 | Accepted | 149 | 9,104 | 284 | N = int(input())
C0 = 0
C1 = 0
C2 = 0
C3 = 0
for i in range(N):
result = input()
if result == "AC":
C0 += 1
elif result == "WA":
C1 += 1
elif result == "TLE":
C2 += 1
else:
C3 += 1
print("AC x", C0)
print("WA x", C1)
print("TLE x", C2)
print("RE x", C3) |
s370181330 | p03448 | u198062737 | 2,000 | 262,144 | Wrong Answer | 51 | 3,060 | 233 | 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(0, A + 1):
for j in range(0, B + 1):
for k in range(0, C + 1):
if i * 500 + j * 100 + k * 50 == X:
ans
print(ans) | s501175206 | Accepted | 51 | 3,060 | 238 | A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(0, A + 1):
for j in range(0, B + 1):
for k in range(0, C + 1):
if i * 500 + j * 100 + k * 50 == X:
ans += 1
print(ans) |
s723646579 | p03095 | u787456042 | 2,000 | 1,048,576 | Wrong Answer | 22 | 3,188 | 68 | 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. | n,s=open(0);a=1
for c in set(s):a*=s.count(c)+1
print(~-a%(10**9+7)) | s603508348 | Accepted | 21 | 3,188 | 76 | n,s=open(0);a=1
for c in set(s.strip()):a*=s.count(c)+1
print(~-a%(10**9+7)) |
s605560671 | p03351 | u226912938 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 133 | 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 abs(a-b) + abs(b-c) <= d or abs(a-c) <= d:
ans = 'Yes'
else:
ans = 'No'
print(ans) | s514370591 | Accepted | 19 | 3,316 | 143 | a, b, c, d = map(int, input().split())
if (abs(a-b) <= d and abs(b-c) <= d) or abs(a-c) <= d:
ans = 'Yes'
else:
ans = 'No'
print(ans) |
s996221933 | p03997 | u271044469 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 69 | 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)
| s034194677 | Accepted | 17 | 2,940 | 70 | a = int(input())
b = int(input())
h = int(input())
print((a+b)*h//2)
|
s152056984 | p03564 | u646792990 | 2,000 | 262,144 | Wrong Answer | 29 | 9,152 | 163 | Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value: * Operation A: The displayed value is doubled. * Operation B: The displayed value increases by K. Square1001 needs to perform these operations N times in total. Find the minimum possible value displayed in the board after N operations. | n = int(input())
k = int(input())
ans = 1
cnt = n
while ans <= k:
ans *= 2
cnt -= 1
if cnt == 1:
break
print(ans)
ans += cnt * k
print(ans)
| s370071994 | Accepted | 28 | 9,100 | 106 | n = int(input())
k = int(input())
ans = 1
for _ in range(n):
ans = min(2 * ans, ans + k)
print(ans)
|
s323944514 | p02613 | u760760982 | 2,000 | 1,048,576 | Wrong Answer | 160 | 9,044 | 346 | 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. | num = int(input())
word = {"AC":0, "WA":0, "TLE":0, "RE":0}
for i in range(num):
judge = input()
if judge in word:
word[str(judge)] += 1
else:
none
print("AC × " + str(word["AC"]))
print("WA × " + str(word["WA"]))
print("TLE × " + str(word["TLE"]))
print("RE × " + str(word["RE"]))
| s686138300 | Accepted | 159 | 9,200 | 329 | num = int(input())
word = {"AC":0, "WA":0, "TLE":0, "RE":0}
for i in range(num):
judge = input()
if judge in word:
word[str(judge)] += 1
else:
pass
print("AC x " + str(word["AC"]))
print("WA x " + str(word["WA"]))
print("TLE x " + str(word["TLE"]))
print("RE x " + str(word["RE"])) |
s413139521 | p03471 | u201565171 | 2,000 | 262,144 | Wrong Answer | 2,104 | 3,060 | 439 | 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=list(map(int,input().split()))
flg=1
for i in range(N):
for j in range(N):
for k in range(N):
if i+j+k==N and 10000*i+5000*j+1000*k==Y:
flg=0
x=i
y=j
z=k
if flg==1:
print('-1 -1 -1')
else:
print(x,end=" ")
print(y,end=" ")
print(z,end="")
| s756085021 | Accepted | 773 | 3,060 | 396 | N,Y=list(map(int,input().split()))
flg=1
for i in range(N+1):
for j in range(N-i+1):
k=N-(i+j)
if 10000*i+5000*j+1000*k==Y:
flg=0
x=i
y=j
z=k
if flg==1:
print('-1 -1 -1')
else:
print(x,end=" ")
print(y,end=" ")
print(z)
|
s188838560 | p03457 | u308588791 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 166 | 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())
for i in range(n):
t, x, y = map(int, input().split())
if x + y < t or (x + y + t) % 2 == 0:
print("No")
exit()
print("Yes")
| s503937898 | Accepted | 328 | 3,060 | 163 | N = int(input())
for _ in range(N):
t, x, y = map(int, input().split())
if x + y > t or (t + x + y)%2 != 0:
print("No")
quit()
print("Yes") |
s831881453 | p03494 | u227210643 | 2,000 | 262,144 | Wrong Answer | 20 | 3,060 | 195 | 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. | C=int(input())
D=list(map(int,input().split()))
S=0
flag=0
while(flag==0):
for I in range(C):
if D[I]%2==0:
D[I]/=2
if I==(C-1):
S+=1
else:
flag=1
break
print(D,S)
print(S) | s328976501 | Accepted | 19 | 2,940 | 183 | C=int(input())
D=list(map(int,input().split()))
S=0
flag=0
while(flag==0):
for I in range(C):
if D[I]%2==0:
D[I]/=2
if I==(C-1):
S+=1
else:
flag=1
break
print(S) |
s878874013 | p02613 | u951985579 | 2,000 | 1,048,576 | Wrong Answer | 147 | 9,200 | 309 | 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())
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(N):
s = input()
if s == 'AC':
AC += 1
elif s == 'WA':
WA += 1
elif s == 'TLE':
TLE += 1
else:
RE += 1
print('AC', '×', AC)
print('WA', '×', WA)
print('TLE', '×', TLE)
print('RE', '×', RE)
| s234310798 | Accepted | 142 | 9,144 | 165 | ans = {
'AC' : 0,
'WA' : 0,
'TLE' : 0,
'RE' : 0
}
for i in range(int(input())):
ans[input()] += 1
for k, v in ans.items():
print(k, 'x', v) |
s560639792 | p03713 | u089376182 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 495 | There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}. | h,w = map(int, input().split())
h1,h2 = h//3, h//3+1
w1,w2= min(w//2, w//2+1), max(w//2, w//2+1)
h3,h4 = min(h//2, h//2+1), max(h//2, h//2+1)
w3,w4 = w//3, w//3+1
ans = []
a,b,c = h1*w, (h-h1)*w1, (h-h1)*w2
ans.append(max([a,b,c])-min([a,b,c]))
a,b,c = h2*w, (h-h2)*w1, (h-h2)*w2
ans.append(max([a,b,c])-min([a,b,c]))
a,b,c = w3*h, (w-w3)*h3, (w-w3)*h4
ans.append(max([a,b,c])-min([a,b,c]))
a,b,c = w4*h, (w-w4)*h3, (w-w4)*h4
ans.append(max([a,b,c])-min([a,b,c]))
ans.append(h)
ans.append(w) | s929755277 | Accepted | 17 | 3,188 | 722 | h,w = map(int, input().split())
h1,h2 = h//3, h//3+1
w1,w2= min(w//2, w//2+1), max(w//2, w//2+1)
h3,h4 = min(h//2, h//2+1), max(h//2, h//2+1)
w3,w4 = w//3, w//3+1
ans = []
a,b,c = h1*w, (h-h1)*w1, (h-h1)*w2
ans.append(max([a,b,c])-min([a,b,c]))
a,b,c = h2*w, (h-h2)*w1, (h-h2)*w2
ans.append(max([a,b,c])-min([a,b,c]))
a,b,c = w3*h, (w-w3)*h3, (w-w3)*h4
ans.append(max([a,b,c])-min([a,b,c]))
a,b,c = w4*h, (w-w4)*h3, (w-w4)*h4
ans.append(max([a,b,c])-min([a,b,c]))
ans.append(h)
ans.append(w)
if w%2==0:
ans.append(abs(h1*w-(h-h1)*w//2))
ans.append(abs(h2*w-(h-h2)*w//2))
if h%2==0:
ans.append(abs(w3*h-(w-w3)*h//2))
ans.append(abs(w4*h-(w-w4)*h//2))
if h%3==0 or w%3==0:
ans.append(0)
print(min(ans)) |
s094839978 | p02612 | u415995713 | 2,000 | 1,048,576 | Wrong Answer | 27 | 9,144 | 48 | 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())
x = N % 1000
x = int()
print(x) | s995652055 | Accepted | 31 | 9,148 | 52 | N = int(input())
x =(1000 - N % 1000)%1000
print(x)
|
s867981962 | p03478 | u655975843 | 2,000 | 262,144 | Wrong Answer | 25 | 3,060 | 258 | 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). | n, a, b = map(int, input().split())
sum = 0
for i in range(1, n + 1):
a1 = n // 10000
a2 = n // 1000
a3 = n // 100
a4 = n // 10
k = a1 + (a2 - a1*10) + (a3 - a2*10) + (a4 - a3*10)
if (k >= a) and (k <= b):
sum += k
print(sum)
| s034536871 | Accepted | 42 | 3,064 | 252 | n, a, b = map(str, input().split())
a = int(a)
b = int(b)
N = int(n)
sum = 0
for i in range(1, N + 1):
k = 0
num = list(str(i))
for j in range(len(num)):
k = k + int(num[j])
if (k >= a) and (k <= b):
sum += i
print(sum)
|
s171272760 | p03679 | u217303170 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 120 | Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache. | x,a,b=map(int,input().split())
if a > b:
print('delicious')
elif a < b < x:
print('safe')
else:
print('dangerous') | s874810131 | Accepted | 17 | 2,940 | 117 | X,A,B=map(int,input().split())
if X<B-A:
print("dangerous")
elif B-A<=0:
print("delicious")
else:
print("safe") |
s764387089 | p03485 | u166621202 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 65 | 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. | import math
a,b = map(int,input().split())
print(math.floor(a/b)) | s766550339 | Accepted | 20 | 2,940 | 69 | import math
a,b = map(int,input().split())
print(math.ceil((a+b)/2))
|
s702030916 | p03360 | u584558499 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 257 | 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? | numbers = list(map(int, input().split()))
K = int(input())
max_index = numbers.index(max(numbers))
result = 0
print('max: ', numbers[max_index])
result = [numbers[i] * 2 ** K if i == max_index else numbers[i] for i in range(len(numbers))]
print(sum(result)) | s245320209 | Accepted | 18 | 3,060 | 236 | numbers = [int(i) for i in input().split()]
K = list(map(int, input().split()))[0]
max_index = numbers.index(max(numbers))
result = [numbers[i] * 2 ** K if i == max_index else numbers[i] for i in range(len(numbers))]
print(sum(result)) |
s433644014 | p02928 | u969062493 | 2,000 | 1,048,576 | Wrong Answer | 378 | 3,188 | 289 | We have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}. Let B be a sequence of K \times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2. Find the inversion number of B, modulo 10^9 + 7. Here the inversion number of B is defined as the number of ordered pairs of integers (i,~j)~(0 \leq i < j \leq K \times N - 1) such that B_i > B_j. | n, k = map(int, input().split())
a = list(map(int, input().split()))
inv = 0
for i in range(n - 1):
for j in range(i + 1, n):
if a[i] > a[j]:
inv += 1
print(k * (k - 1) / 2)
total_inv = k * inv + k * (k - 1) / 2 * inv
dst = int(total_inv % (10e+9 + 7))
print(dst)
| s270422403 | Accepted | 1,051 | 3,188 | 396 | n, k = map(int, input().split())
a = list(map(int, input().split()))
intra_inv = 0
for i in range(n):
for j in range(i + 1, n):
if a[i] > a[j]:
intra_inv += 1
inter_inv = 0
for i in range(n):
for j in range(n):
if a[i] > a[j]:
inter_inv += 1
total_inv = k * intra_inv + k * (k - 1) // 2 * inter_inv
dst = int(total_inv % (10**9 + 7))
print(dst)
|
s414475656 | p03545 | u170077602 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 646 | 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. | row = input()
row = list(row)
row = list(map(int, row))
for i in range(2):
sum = row[0]
if i == 0:
op1 = "+"
sum += row[1]
else:
op1 = "-"
sum -= row[1]
for j in range(1):
if j == 0:
op2 = "+"
sum += row[2]
else:
op2 = "-"
sum -= row[2]
for k in range(1):
if j == 0:
op3 = "+"
sum += row[3]
else:
op3 = "-"
sum -= row[3]
if sum == 7:
break
print(row[0],op1,row[1],op2,row[2],op3,row[3],"=7", sep="") | s366312668 | Accepted | 18 | 3,064 | 824 | row = input()
row = list(row)
row = list(map(int, row))
Flag = False
for i in range(2):
for j in range(2):
for k in range(2):
sum = row[0]
if i == 0:
op1 = "+"
sum += row[1]
else:
op1 = "-"
sum -= row[1]
if j == 0:
op2 = "+"
sum += row[2]
else:
op2 = "-"
sum -= row[2]
if k == 0:
op3 = "+"
sum += row[3]
else:
op3 = "-"
sum -= row[3]
if sum == 7:
Flag = True
break
if Flag:
break
if Flag:
break
print(row[0],op1,row[1],op2,row[2],op3,row[3],"=7", sep="") |
s115995260 | p03494 | u953753178 | 2,000 | 262,144 | Time Limit Exceeded | 2,104 | 2,940 | 140 | 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. | input()
a = list(map(int, input().split()))
ans = 0
ai = 0
while all(ai%2==0 for ai in a):
a = [ai/2 for i in a]
ans += 1
print(ans) | s028695004 | Accepted | 19 | 3,064 | 134 | input()
a = list(map(int, input().split()))
ans = 0
while all(ai%2==0 for ai in a):
a = [ai/2 for ai in a]
ans += 1
print(ans) |
s403187138 | p03861 | u252805217 | 2,000 | 262,144 | Wrong Answer | 2,103 | 2,940 | 135 | 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, b, x = map(int, input().split())
l = b - a + 1
ans = l // x + len([i for i in range(a, a+l%x) if i % x == 0])
print(x, (a, b), ans)
| s390717141 | Accepted | 18 | 2,940 | 115 | a, b, x = map(int, input().split())
def bibe(n, x):
return n // x
ans = bibe(b, x) - bibe(a-1, x)
print(ans)
|
s021863815 | p03693 | u886712136 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 84 | AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4? | a,b,c=input().split()
num=int(a+b+c)
if num%4==0:
print("Yes")
else:
print("No") | s562591761 | Accepted | 17 | 2,940 | 84 | a,b,c=input().split()
num=int(a+b+c)
if num%4==0:
print("YES")
else:
print("NO") |
s399747836 | p03471 | u993138647 | 2,000 | 262,144 | Wrong Answer | 2,104 | 3,064 | 300 | 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. | s=[[int(j) for j in input().split()] for i in range (1)]
N=s[0][0]
Y=s[0][1]
ans=list()
for x in range(0,N+1):
for y in range(0,N+1):
for z in range(0,N+1):
if 10000*x+5000*y+1000*z==Y:
ans=[x,y,z]
if len(ans)==0:
ans=[-1,-1,-1]
print(ans[0],ans[1],ans[2]) | s224286320 | Accepted | 1,635 | 3,064 | 255 | s=[[int(j) for j in input().split()] for i in range (1)]
N=s[0][0]
Y=s[0][1]
ans=[-1,-1,-1]
for x in range(0,N+1):
for y in range(0,N+1):
z=N-x-y
if 10000*x+5000*y+1000*z==Y and z>=0:
ans=[x,y,z]
print(ans[0],ans[1],ans[2]) |
s013857785 | p03377 | u419535209 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 187 | 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. | def A():
A, B, X = [int(a) for a in input().split()]
possible = all([
A <= X,
X <= A + B
])
if possible:
print('YES')
else:
print('NO') | s411817992 | Accepted | 17 | 2,940 | 142 | A, B, X = [int(a) for a in input().split()]
possible = all([
A <= X,
X <= A + B
])
if possible:
print('YES')
else:
print('NO') |
s791765853 | p03721 | u798093965 | 2,000 | 262,144 | Wrong Answer | 864 | 4,212 | 197 | There is an empty array. The following N operations will be performed to insert integers into the array. In the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array. Find the K-th smallest integer in the array after the N operations. For example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3. | n,k = map(int,input().split())
count = 0
ans = 0
for i in range(n):
a,b =map(int,input().split())
print(a,b)
count += b
if count >= k:
ans = a
break
print(ans) | s379239944 | Accepted | 426 | 29,864 | 298 | from operator import itemgetter
n,k = map(int,input().split())
count = 0
ans = 0
a = [list(map(int,input().split())) for i in range(n)]
number = sorted(a, key = lambda x: x[0])
for i in range(n):
count += number[i][1]
if count >= k:
ans = number[i][0]
break
print(ans) |
s476714665 | p03494 | u625428807 | 2,000 | 262,144 | Time Limit Exceeded | 2,103 | 2,940 | 267 | 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(map(int, input().split()))
count = 0
flag = False
while flag == False:
for ai in a:
if ai % 2 == 0:
ai = ai / 2
else:
flag = True
if flag == True:
break
count += 1
print(count) | s759063677 | Accepted | 18 | 3,060 | 165 | import math
n = input()
a = list(map(int, input().split()))
ans = float("inf")
for i in a:
ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1)
print(round(ans))
|
s682088946 | p02603 | u346308892 | 2,000 | 1,048,576 | Wrong Answer | 127 | 27,192 | 1,778 | 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? |
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline
def array(size, init=0):
return [[init for j in range(size[1])] for i in range(size[0])]
def acinput():
return list(map(int, input().split(" ")))
def II():
return int(input())
directions = np.array([[1, 0], [0, 1], [-1, 0], [0, -1]])
directions = list(map(np.array, directions))
mod = 10**9+7
def factorial(n):
fact = 1
for integer in range(1, n + 1):
fact *= integer
return fact
def permutate(x, A):
n = len(x)
res = [-1]*n
for i in range(n):
res[i] = x[A[i]]
return res
def generate_bin(digit):
for b in range(2**digit):
b = bin(b)
tmp = b[2:].zfill(digit)
yield list(map(int, tmp))
# yield b
def search(x, count):
#print("top", x, count)
for d in directions:
nx = d+x
# print(nx)
if np.all(0 <= nx) and np.all(nx < (H, W)):
if field[nx[0]][nx[1]] == "E":
count += 1
field[nx[0]][nx[1]] = "V"
count = serch(nx, count)
continue
if field[nx[0]][nx[1]] == "#":
field[nx[0]][nx[1]] = "V"
count = serch(nx, count)
return count
N = II()
A = acinput()
A.insert(0, A[0]+1)
A.append(A[-1]-1)
tmp = []
for i in range(len(A)):
if A[i] != A[i-1]:
tmp.append(A[i])
A = tmp
x = 1000
k = 0
for i in range(len(A)-1):
print(i, x, k)
if A[i-1] > A[i] and A[i] < A[i+1]:
k += x//A[i]
x = x % A[i]
elif A[i-1] < A[i] and A[i] > A[i+1]:
#print(i, x, k)
x += A[i]*k
k = 0
print(x)
# print(A)
| s426767576 | Accepted | 129 | 27,160 | 1,779 |
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline
def array(size, init=0):
return [[init for j in range(size[1])] for i in range(size[0])]
def acinput():
return list(map(int, input().split(" ")))
def II():
return int(input())
directions = np.array([[1, 0], [0, 1], [-1, 0], [0, -1]])
directions = list(map(np.array, directions))
mod = 10**9+7
def factorial(n):
fact = 1
for integer in range(1, n + 1):
fact *= integer
return fact
def permutate(x, A):
n = len(x)
res = [-1]*n
for i in range(n):
res[i] = x[A[i]]
return res
def generate_bin(digit):
for b in range(2**digit):
b = bin(b)
tmp = b[2:].zfill(digit)
yield list(map(int, tmp))
# yield b
def search(x, count):
#print("top", x, count)
for d in directions:
nx = d+x
# print(nx)
if np.all(0 <= nx) and np.all(nx < (H, W)):
if field[nx[0]][nx[1]] == "E":
count += 1
field[nx[0]][nx[1]] = "V"
count = serch(nx, count)
continue
if field[nx[0]][nx[1]] == "#":
field[nx[0]][nx[1]] = "V"
count = serch(nx, count)
return count
N = II()
A = acinput()
A.insert(0, A[0]+1)
A.append(A[-1]-1)
tmp = []
for i in range(len(A)):
if A[i] != A[i-1]:
tmp.append(A[i])
A = tmp
x = 1000
k = 0
for i in range(len(A)-1):
#print(i, x, k)
if A[i-1] > A[i] and A[i] < A[i+1]:
k += x//A[i]
x = x % A[i]
elif A[i-1] < A[i] and A[i] > A[i+1]:
#print(i, x, k)
x += A[i]*k
k = 0
print(x)
# print(A)
|
s281011376 | p02259 | u844704750 | 1,000 | 131,072 | Wrong Answer | 30 | 7,640 | 556 | Write a program of the Bubble Sort algorithm which sorts a sequence _A_ in ascending order. The algorithm should be based on the following pseudocode: BubbleSort(A) 1 for i = 0 to A.length-1 2 for j = A.length-1 downto i+1 3 if A[j] < A[j-1] 4 swap A[j] and A[j-1] Note that, indices for array elements are based on 0-origin. Your program should also print the number of swap operations defined in line 4 of the pseudocode. | N = int(input())
A = list(map(int, input().split(" ")))
def print_list(A):
for a in A[:-1]:
print ("%d "%a, end="")
print(A[-1])
def BubbleSort(A, N):
print_list(A)
count = 0
flag = True
while flag:
flag = False
for j in range(N-1, 0, -1):
if A[j] < A[j-1]:
v = A[j]
A[j] = A[j-1]
A[j-1] = v
count += 1
flag = True
return A, count
A_sorted, c = BubbleSort(A, N)
print_list(A_sorted)
print(c) | s774166459 | Accepted | 30 | 7,756 | 538 | N = int(input())
A = list(map(int, input().split(" ")))
def print_list(A):
for a in A[:-1]:
print ("%d "%a, end="")
print(A[-1])
def BubbleSort(A, N):
count = 0
flag = True
while flag:
flag = False
for j in range(N-1, 0, -1):
if A[j] < A[j-1]:
v = A[j]
A[j] = A[j-1]
A[j-1] = v
count += 1
flag = True
return A, count
A_sorted, c = BubbleSort(A, N)
print_list(A_sorted)
print(c) |
s294187382 | p03679 | u763881112 | 2,000 | 262,144 | Wrong Answer | 157 | 13,568 | 168 | Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache. |
import numpy as np
import fractions as fra
x,a,b=map(int,input().split())
if(a>=b):
print("delicious")
elif(x>=b):
print("safe")
else:
print("dangerous") | s110803427 | Accepted | 156 | 13,524 | 170 |
import numpy as np
import fractions as fra
x,a,b=map(int,input().split())
if(a>=b):
print("delicious")
elif(a+x>=b):
print("safe")
else:
print("dangerous") |
s186809195 | p03433 | u055687574 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 104 | 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())
n %= 500
print(n)
if n <= a:
print("Yes")
else:
print("No")
| s168487821 | Accepted | 17 | 2,940 | 95 | n = int(input())
a = int(input())
n %= 500
if n <= a:
print("Yes")
else:
print("No")
|
s946725619 | p03351 | u626337957 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 117 | 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 abs(c-a) <= d or abs(c-b)+abs(b-a) <= d:
print('Yes')
else:
print('No') | s476687763 | Accepted | 17 | 2,940 | 129 | a, b, c, d = map(int, input().split())
if abs(c-a) <= d or (abs(c-b) <= d and abs(b-a) <= d):
print('Yes')
else:
print('No')
|
s495415046 | p03471 | u696197059 | 2,000 | 262,144 | Wrong Answer | 2,205 | 9,076 | 258 | 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 = map(int,input().split())
list = {}
for i in range(n):
for j in range(n - i):
for k in range(n - i - j):
if (i*10000 + j * 5000 + k* 1000) == y:
list = [i,j,k]
if len(list) == 0:
list = [-1,-1,-1]
print(list) | s225321488 | Accepted | 522 | 9,152 | 330 | n ,y = map(int,input().split())
list = [-1,-1,-1]
for i in range(n+1):
for j in range(n+1 - i):
if (j *10000 + i * 5000 + (n-i-j)* 1000) == y:
list = [i,j,(n-i-j)]
break
if (j *10000 + i * 5000 + (n-i-j)* 1000) == y:
break
print(list[1],list[0],list[2]) |
s251156906 | p02850 | u531599639 | 2,000 | 1,048,576 | Wrong Answer | 446 | 29,608 | 485 | 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. | from collections import deque
n = int(input())
tree = [[] for i in range(n+1)]
for _ in range(n-1):
a,b = map(int,input().split())
tree[a].append(b)
tree[b].append(a)
m = len(max(tree,key=len))
col = [0]*(n+1)
Q = deque([1])
print(tree)
while Q:
temp = Q.popleft()
pre = col[temp]
now = 1
for n in tree[temp]:
if col[n]:
continue
if now!=pre:
col[n]=now
now += 1
else:
col[n]=now+1
now += 2
Q.append(n)
print(m,*col[2:]) | s648175621 | Accepted | 492 | 46,832 | 563 | from collections import deque
n = int(input())
tree = [[] for i in range(n+1)]
edge = []
for _ in range(n-1):
a,b = map(int,input().split())
tree[a].append(b)
tree[b].append(a)
edge.append((a,b))
m = len(max(tree,key=len))
col = [0]*(n+1)
col[1]='a'
Q = deque([1])
#print(tree)
ans = {}
while Q:
temp = Q.popleft()
now = 1
for n in tree[temp]:
if col[n]:
continue
if now == col[temp]:
now += 1
col[n] = now
ans[min(temp,n),max(temp,n)] = now
now += 1
Q.append(n)
print(m)
for a,b in edge:
print(ans[(a,b)]) |
s904295696 | p03380 | u597455618 | 2,000 | 262,144 | Wrong Answer | 311 | 52,672 | 538 | Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted. | from scipy.special import comb
import bisect
def main():
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
ans = [0, 0]
chk = 0
for i in range(n):
for j in range(bisect.bisect_left(a, a[i]//2), bisect.bisect_right(a, a[i]//2+1)):
tmp = max(comb(a[i], a[j], exact=True), comb(a[j], a[i], exact=True))
if chk < tmp:
chk = tmp
ans[0] = a[j]
ans[1] = a[i]
print(*ans)
if __name__ == "__main__":
main()
| s818284323 | Accepted | 62 | 19,964 | 277 | def main():
n = int(input())
a = list(map(int, input().split()))
l = max(a)
r = 0
chk = 10**9+1
for x in a:
if abs(x-l//2) < chk and x != l:
r = x
chk = abs(x-l//2)
print(l, r)
if __name__ == "__main__":
main()
|
s584473780 | p03160 | u896741788 | 2,000 | 1,048,576 | Wrong Answer | 202 | 13,980 | 179 | There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N. | n=int(input())
l=list(map(int,input().split()))
dp=[float("INF")]*n
dp[0]=0
for i in range(2,n):
for j in range(1,3):
dp[i]=min(dp[i-j]+abs(l[i]-l[i-j]),dp[i])
print(dp[-1]) | s567629006 | Accepted | 127 | 14,696 | 189 | n=int(input())
dp=[10**4*n]*n
l=list(map(int,input().split()))
dp[0]=0
dp[1]=abs(l[0]-l[1])
for i in range(2,n):
dp[i]=min(dp[i-1]+abs(l[i]-l[i-1]),dp[i-2]+abs(l[i]-l[i-2]))
print(dp[-1]) |
s883133401 | p03644 | u931889893 | 2,000 | 262,144 | Wrong Answer | 19 | 3,060 | 327 | 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())
results = 0
number = 0
for i in range(n+1):
if i == 0:
continue
count = 0
while True:
if i % 2 == 0:
count += 1
i = i / 2
else:
if results < count:
results = count
number = n
break
print(number) | s404039257 | Accepted | 17 | 3,060 | 323 | n = int(input())
results = 0
number = 0
for i in range(n + 1):
if i == 0:
continue
if i == 1:
number = 1
continue
count = 0
v = i
while v % 2 == 0:
count += 1
v = v / 2
if results < count:
results = count
number = i
continue
print(number) |
s113915620 | p03997 | u769411997 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 67 | 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) | s813398439 | Accepted | 17 | 2,940 | 68 | a = int(input())
b = int(input())
h = int(input())
print((a+b)*h//2) |
s139854547 | p03997 | u325206354 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 61 | 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())
c=int(input())
print((a+b)*c/2) | s192057005 | Accepted | 17 | 2,940 | 67 | a=int(input())
b=int(input())
c=int(input())
print(int((a+b)*c/2))
|
s475088835 | p03456 | u882370611 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 68 | AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number. | a,b=input().split()
c=int(a+b)
print('Yes' if c**(1/2)==c else 'No') | s606466819 | Accepted | 18 | 2,940 | 79 | a,b=input().split()
c=int(a+b)
print('Yes' if (int(c**(1/2)))**2==c else 'No')
|
s368663524 | p03657 | u428132025 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 118 | Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. | a, b = map(int, input().split())
if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0:
print('Yes')
else:
print('No') | s484320529 | Accepted | 17 | 2,940 | 131 | a, b = map(int, input().split())
if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0:
print('Possible')
else:
print('Impossible') |
s677879039 | p03471 | u846552659 | 2,000 | 262,144 | Wrong Answer | 2,103 | 3,064 | 326 | 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. | # -*- coding:utf-8 -*-
import sys
n, y = map(int, input().split())
for a in range(n+1):
for b in range(n-a+1):
for c in range(n-a-b+1):
if 10000*a+5000*b+1000*c == y:
print(str(a)+' '+str(b)+' '+str(c))
sys.exit()
else:
pass
print("-1 -1 -1") | s494985624 | Accepted | 509 | 3,060 | 542 | # -*- coding:utf-8 -*-
import sys
n, y = map(int, input().split())
for a in range(n+1):
for b in range(n+1-a):
if 5000*a+9000*b == 10000*n-y and n-a-b >= 0:
print(str(n-a-b)+' '+str(a)+' '+str(b))
sys.exit()
else:
pass
'''
for a in range(n+1):
for b in range(n-a+1):
for c in range(n-a-b+1):
if 10000*a+5000*b+1000*c == y:
print(str(a)+' '+str(b)+' '+str(c))
sys.exit()
else:
pass
'''
print("-1 -1 -1") |
s557463192 | p03636 | u429319815 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 59 | The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way. | s = (list(input()))
S = s[0] + str(len(s)) + s[-1]
print(S) | s599040912 | Accepted | 18 | 2,940 | 61 | s = (list(input()))
S = s[0] + str(len(s)-2) + s[-1]
print(S) |
s550518267 | p02747 | u068142202 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 75 | A Hitachi string is a concatenation of one or more copies of the string `hi`. For example, `hi` and `hihi` are Hitachi strings, while `ha` and `hii` are not. Given a string S, determine whether S is a Hitachi string. | s = input()
check = "hi"
if s in check:
print("Yes")
else:
print("No")
| s188539602 | Accepted | 19 | 3,188 | 200 | import re
s = input()
if len(s) % 2 == 1:
s += "a"
li = re.split('(..)',s)[1::2]
check = "hi"
ans = 0
for i in li:
if check not in i:
ans += 1
if ans == 0:
print("Yes")
else:
print("No")
|
s375183840 | p03760 | u027165539 | 2,000 | 262,144 | Wrong Answer | 19 | 2,940 | 184 | Snuke signed up for a new website which holds programming competitions. He worried that he might forget his password, and he took notes of it. Since directly recording his password would cause him trouble if stolen, he took two notes: one contains the characters at the odd-numbered positions, and the other contains the characters at the even-numbered positions. You are given two strings O and E. O contains the characters at the odd- numbered positions retaining their relative order, and E contains the characters at the even-numbered positions retaining their relative order. Restore the original password. | o = input()
e = input()
s = ''
for i in range(len(o)):
s += o[i]
if i + 1 == len(o):
break
s += e[i]
print(s) | s648743528 | Accepted | 17 | 2,940 | 184 | o = input()
e = input()
s = ''
for i in range(len(o)):
s += o[i]
if i + 1 > len(e):
break
s += e[i]
print(s)
|
s388998064 | p03605 | u779308281 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 137 | 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? | b = list(input())
num = 0
for i in b:
if i == "9":
num += 1
break
if num == 1:
print("YES")
else:
print("NO") | s671866835 | Accepted | 17 | 2,940 | 136 | b = list(input())
num = 0
for i in b:
if i == "9":
num = 1
break
if num == 1:
print("Yes")
else:
print("No") |
s832501878 | p04043 | u209616713 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 116 | 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. | w = input()
l = list(w)
l.sort()
ans = l[0] + l[1] + l[2]
if l == '557':
print('YES')
else:
print('NO')
| s966161724 | Accepted | 17 | 2,940 | 124 | w = input()
l = list(w)
l.sort()
ans = str(l[2]) + str(l[3]) + str(l[4])
if ans == '557':
print('YES')
else:
print('NO') |
s847519749 | p03730 | u646412443 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 201 | 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 = list(map(int, input().split()))
i = 1
while(True):
if (a * i) % b == 0:
print('No')
break
elif (a * i) % b == c:
print('Yes')
break
i += 1
| s657775199 | Accepted | 17 | 2,940 | 203 | a, b, c = list(map(int, input().split()))
i = 1
while(True):
if (a * i) % b == 0:
print('NO')
exit()
elif (a * i) % b == c:
print('YES')
exit()
i += 1
|
s581274823 | p03644 | u928784113 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 90 | 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. | # -*- coding: utf-8 -*-
N = int(input())
x = 1
while N >= 2**x:
x = x+1
print(2 ** x) | s474823201 | Accepted | 18 | 2,940 | 94 | # -*- coding: utf-8 -*-
N = int(input())
x = 1
while N >= 2**x:
x = x+1
print(2 ** x //2) |
s321214782 | p00003 | u626838615 | 1,000 | 131,072 | Wrong Answer | 40 | 7,552 | 192 | Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so. | n = int(input())
for i in range(n):
side = list(map(int,input().split()))
side.sort()
if(side[0]**2 + side[1]**2 == side[2]**2):
print("Yes")
else:
print("No") | s800700164 | Accepted | 40 | 7,596 | 192 | n = int(input())
for i in range(n):
side = list(map(int,input().split()))
side.sort()
if(side[0]**2 + side[1]**2 == side[2]**2):
print("YES")
else:
print("NO") |
s572805811 | p03470 | u360061665 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 81 | An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have? | N = int(input())
a = sorted(set([int(input(i)) for i in range(N)]))
print(len(a)) | s276675119 | Accepted | 18 | 2,940 | 81 | N = int(input())
a = sorted(set([int(input()) for i in range(N)]))
print(len(a))
|
s574728266 | p03720 | u584529823 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 231 | There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city? | N, M = map(int, input().split())
cities = [list(map(int, input().split())) for _ in range(M)]
print(cities)
roads = [0] * N
for city in cities:
roads[city[0] - 1] += 1
roads[city[1] - 1] += 1
for road in roads:
print(road) | s556226637 | Accepted | 17 | 3,060 | 216 | N, M = map(int, input().split())
cities = [list(map(int, input().split())) for _ in range(M)]
roads = [0] * N
for city in cities:
roads[city[0] - 1] += 1
roads[city[1] - 1] += 1
for road in roads:
print(road) |
s706660562 | p03860 | u246572032 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 35 | 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. | s = input()
print('A' + s[1] + 'C') | s212544541 | Accepted | 17 | 2,940 | 47 | a,b,c = input().split()
print('A' + b[0] + 'C') |
s022261524 | p04030 | u957872856 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 83 | Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now? | t = ""
for x in input():
if x == "B":
t=t[:-1]
else:
t+=x
print(len(t)) | s164973702 | Accepted | 17 | 2,940 | 78 | t = ""
for x in input():
if x == "B":
t=t[:-1]
else:
t+=x
print(t) |
s121287427 | p03150 | u272557899 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,064 | 513 | A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string. | s = input()
t = "keyence"
p = 0
for i in range(len(s)):
if p == 0:
if i <= 6:
if s[i] != t[i]:
k = i
p = 1
elif p == 1:
if s[i] == t[k]:
j = i
p = 2
if i == len(s) - 1:
print("No")
exit()
elif p == 2:
if k + i - j <= 6:
if s[i] != t[k + i - j]:
print("No")
exit()
else:
print("No")
exit()
print("Yes") | s683147269 | Accepted | 17 | 3,188 | 1,308 | s = input()
t = "keyence"
if t in s:
print("YES")
exit()
if len(s) >= 7:
if "k" in s and "eyence" in s:
if s[0] == "k" and s[-1] == "e" and s[-2] == "c" and s[-3] == "n" and s[-4] == "e" and s[-5] == "y" and s[-6] == "e":
print("YES")
exit()
if "ke" in s and "yence" in s:
if s[0] == "k" and s[-1] == "e" and s[-2] == "c" and s[-3] == "n" and s[-4] == "e" and s[-5] == "y" and s[1] == "e":
print("YES")
exit()
if "key" in s and "ence" in s:
if s[0] == "k" and s[-1] == "e" and s[-2] == "c" and s[-3] == "n" and s[-4] == "e" and s[2] == "y" and s[1] == "e":
print("YES")
exit()
if "keye" in s and "nce" in s:
if s[0] == "k" and s[-1] == "e" and s[-2] == "c" and s[-3] == "n" and s[3] == "e" and s[2] == "y" and s[1] == "e":
print("YES")
exit()
if "keyen" in s and "ce" in s:
if s[0] == "k" and s[-1] == "e" and s[-2] == "c" and s[4] == "n" and s[3] == "e" and s[2] == "y" and s[1] == "e":
print("YES")
exit()
if "keyenc" in s and "e" in s:
if s[0] == "k" and s[-1] == "e" and s[5] == "c" and s[4] == "n" and s[3] == "e" and s[2] == "y" and s[1] == "e":
print("YES")
exit()
print("NO")
|
s162323798 | p00042 | u024715419 | 1,000 | 131,072 | Wrong Answer | 20 | 5,644 | 666 | 宝物がたくさん収蔵されている博物館に、泥棒が大きな風呂敷を一つだけ持って忍び込みました。盗み出したいものはたくさんありますが、風呂敷が耐えられる重さが限られており、これを超えると風呂敷が破れてしまいます。そこで泥棒は、用意した風呂敷を破らず且つ最も価値が高くなるようなお宝の組み合わせを考えなくてはなりません。 風呂敷が耐えられる重さ W、および博物館にある個々のお宝の価値と重さを読み込んで、重さの総和が W を超えない範囲で価値の総和が最大になるときの、お宝の価値総和と重さの総和を出力するプログラムを作成してください。ただし、価値の総和が最大になる組み合わせが複数あるときは、重さの総和が小さいものを出力することとします。 | import itertools
case = 0
while True:
case += 1
w_max = int(input())
if w_max == 0:
break
n = int(input())
t = []
for i in range(n):
t.append(list(map(int, input().split(","))))
v_best = 0
w_best = w_max
p_all = itertools.product([0,1], repeat=n)
for p in p_all:
v = 0
w = 0
for i in range(n):
v += p[i]*t[i][0]
w += p[i]*t[i][1]
if v > v_best and w < w_max:
v_best = v
w_best = w
elif v == v_best and w < w_best:
v_best = v
w_best = w
print("Case:",case)
print(v_best)
print(w_best)
| s651325012 | Accepted | 1,060 | 18,132 | 653 | case = 0
while True:
case += 1
w_max = int(input())
if w_max == 0:
break
n = int(input())
w = [0 for i in range(n)]
v = [0 for i in range(n)]
for i in range(n):
a, b = map(int, input().split(","))
v[i] = a
w[i] = b
dp = [[0 for j in range(w_max + 1)] for i in range(n + 1)]
for i in range(n)[::-1]:
for j in range(w_max + 1):
if j < w[i]:
dp[i][j] = dp[i + 1][j]
else:
dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i])
print("Case ",case,":",sep="")
print(max(dp[0]))
print(dp[0].index(max(dp[0])))
|
s722842247 | p02260 | u698762975 | 1,000 | 131,072 | Wrong Answer | 20 | 5,592 | 251 | Write a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: SelectionSort(A) 1 for i = 0 to A.length-1 2 mini = i 3 for j = i to A.length-1 4 if A[j] < A[mini] 5 mini = j 6 swap A[i] and A[mini] Note that, indices for array elements are based on 0-origin. Your program should also print the number of swap operations defined in line 6 of the pseudocode in the case where i ≠ mini. | def inserrtionsort(l,n):
for i in range(1,n):
print(" ".join(l))
v=l[i]
j=i-1
while int(v)<int(l[j]) and j>=0:
l[j+1]=l[j]
j-=1
l[j+1]=v
print(" ".join(l))
m=int(input())
n=list(input().split())
inserrtionsort(n,m)
| s724279406 | Accepted | 20 | 5,600 | 323 | def selectionsort(l,n):
c=0
for i in range(n):
minj=i
for j in range(i,n):
if int(l[j])<int(l[minj]):
minj=j
l[i],l[minj]=l[minj],l[i]
if i!=minj:
c+=1
print(" ".join(l))
print(c)
n=int(input())
l=list(input().split())
selectionsort(l,n)
|
s284312787 | p03493 | u853900545 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 50 | 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. | s=list(map(int,input().split()))
print(s.count(1)) | s344288444 | Accepted | 17 | 2,940 | 29 | s=input()
print(s.count('1')) |
s026987989 | p03719 | u641460756 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 83 | 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>=a and c>=b:
print("Yes")
else:
print("No") | s389688763 | Accepted | 17 | 2,940 | 77 | a,b,c=map(int,input().split())
if a<=c<=b:
print("Yes")
else:
print("No") |
s826275955 | p03609 | u305965165 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 60 | We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds? | x, t = (int(i) for i in input().split())
print(min(x-t, 0)) | s607305428 | Accepted | 18 | 2,940 | 60 | x, t = (int(i) for i in input().split())
print(max(x-t, 0)) |
s131983047 | p03694 | u214380782 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 68 | 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. | x=input().split()
maxX=max(x)
minX=min(x)
print(int(maxX)-int(minX)) | s500175454 | Accepted | 17 | 2,940 | 105 | n = int(input())
x= [int(i) for i in input().split()]
maxX=max(x)
minX=min(x)
print(int(maxX)-int(minX)) |
s325209081 | p02741 | u812587837 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 170 | Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 | a = list(map(int, '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'.split(',')))
print(a)
k = int(input())
print(a[k-1]) | s411629132 | Accepted | 17 | 2,940 | 161 | a = list(map(int, '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'.split(',')))
k = int(input())
print(a[k-1]) |
s783094335 | p03547 | u642012866 | 2,000 | 262,144 | Wrong Answer | 28 | 9,040 | 95 | In programming, hexadecimal notation is often used. In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters `A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12, 13, 14 and 15, respectively. In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`, `C`, `D`, `E` or `F`. When X and Y are seen as hexadecimal numbers, which is larger? | X, Y = input().split()
if X > Y:
print(">")
elif Y < X:
print("<")
else:
print("=") | s593113588 | Accepted | 27 | 9,032 | 95 | X, Y = input().split()
if X > Y:
print(">")
elif Y > X:
print("<")
else:
print("=") |
s215584786 | p03486 | u062691227 | 2,000 | 262,144 | Wrong Answer | 26 | 9,032 | 304 | You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order. | aa, bb = open(0).read().splitlines()
aa = sorted(aa)
bb = sorted(bb, reverse=True)
for a, b in zip(aa, bb):
if a == b:
continue
else:
if a<b:
print('Yes')
else:
print('No')
break
if len(aa)<len(bb):
print('Yes')
else:
print('No') | s444783879 | Accepted | 28 | 9,132 | 361 | aa, bb = open(0).read().splitlines()
aa = sorted(aa)
bb = sorted(bb, reverse=True)
import sys
for a, b in zip(aa, bb):
if a == b:
continue
else:
if a<b:
print('Yes')
sys.exit()
else:
print('No')
sys.exit()
break
if len(aa)<len(bb):
print('Yes')
else:
print('No') |
s749557344 | p02613 | u972991614 | 2,000 | 1,048,576 | Wrong Answer | 171 | 9,152 | 357 | 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())
i = 1
AC = 0
WA = 0
TLE = 0
RE = 0
while i < N+1:
a = str(input())
if a == "AC":
AC = AC + 1
elif a == "WA":
WA = WA + 1
elif a == "TLE":
TLE = TLE + 1
elif a == "RE":
RE = RE + 1
i = i + 1
print("AC×"+str(AC))
print("WA×" +str(WA))
print("TLE×" + str(TLE))
print("RE×"+str(RE)) | s287925726 | Accepted | 161 | 16,132 | 260 | N = int(input())
x = []
for _ in range(N):
s = input()
x.append(s)
print('AC'+ ' '+ 'x'+ ' '+str(x.count('AC')))
print('WA'+ ' '+ 'x'+ ' '+str(x.count('WA')))
print('TLE'+ ' '+ 'x'+ ' '+str(x.count('TLE')))
print('RE'+ ' '+ 'x'+ ' '+str(x.count('RE'))) |
s350953204 | p03486 | u521866787 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 67 | You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order. | a= input()
b=input()
print("No" if sorted(a)>=sorted(b) else "Yes") | s051525679 | Accepted | 17 | 2,940 | 80 | a= input()
b=input()
print("Yes" if sorted(a)<sorted(b, reverse=True) else "No") |
s749321690 | p03779 | u268516119 | 2,000 | 262,144 | Wrong Answer | 24 | 2,940 | 120 | 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. | import math
X=int(input())
for t in range(math.ceil(math.sqrt(X))):
if t*(t+1)//2>=X:
print(t)
break | s526661373 | Accepted | 26 | 2,940 | 100 | import math
X=int(input())
for t in range(X+1):
if t*(t+1)//2>=X:
print(t)
break |
s586482012 | p02612 | u153955689 | 2,000 | 1,048,576 | Wrong Answer | 29 | 8,992 | 42 | 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())
ans = N % 1000
print(ans) | s208130554 | Accepted | 28 | 8,996 | 86 | N = int(input())
if N % 1000 == 0:
ans = 0
else:
ans = 1000 - N % 1000
print(ans) |
s148568672 | p03351 | u143509139 | 2,000 | 1,048,576 | Wrong Answer | 18 | 2,940 | 96 | 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())
print('YNeos'[abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d)::2]) | s251099525 | Accepted | 17 | 2,940 | 97 | a,b,c,d=map(int,input().split())
print('NYoe s'[abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d)::2]) |
s351230570 | p03778 | u835482198 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 54 | AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved. | w, a, b = map(int, input().split())
print(abs(b - a))
| s045510658 | Accepted | 18 | 2,940 | 101 | w, a, b = map(int, input().split())
if abs(a - b) <= w:
print(0)
else:
print(abs(a - b) - w)
|
s137053473 | p03564 | u382639013 | 2,000 | 262,144 | Wrong Answer | 30 | 9,084 | 206 | Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value: * Operation A: The displayed value is doubled. * Operation B: The displayed value increases by K. Square1001 needs to perform these operations N times in total. Find the minimum possible value displayed in the board after N operations. | N = int(input())
K = int(input())
i = 0
ans = 1
while True:
print(ans)
if i == N:
break
if ans < K:
ans *= 2
i += 1
else:
ans += K
i += 1
print(ans) | s324577703 | Accepted | 30 | 9,180 | 191 | N = int(input())
K = int(input())
i = 0
ans = 1
while True:
if i == N:
break
if ans < K:
ans *= 2
i += 1
else:
ans += K
i += 1
print(ans) |
s715866543 | p03170 | u884077550 | 2,000 | 1,048,576 | Wrong Answer | 1,879 | 5,872 | 280 | There is a set A = \\{ a_1, a_2, \ldots, a_N \\} consisting of N positive integers. Taro and Jiro will play the following game against each other. Initially, we have a pile consisting of K stones. The two players perform the following operation alternately, starting from Taro: * Choose an element x in A, and remove exactly x stones from the pile. A player loses when he becomes unable to play. Assuming that both players play optimally, determine the winner. | n,k = map(int,input().split())
arr = list(map(int,input().split()))
dp = [False]*(k+1)
for stones in range(k+1):
for x in arr:
if stones >= x and dp[stones-x] == False:
dp[stones] = True
print(dp)
if dp[k]:
print("First")
else:
print("Second")
| s963356136 | Accepted | 1,874 | 3,956 | 269 | n,k = map(int,input().split())
arr = list(map(int,input().split()))
dp = [False]*(k+1)
for stones in range(k+1):
for x in arr:
if stones >= x and dp[stones-x] == False:
dp[stones] = True
if dp[k]:
print("First")
else:
print("Second")
|
s322144240 | p03494 | u405328424 | 2,000 | 262,144 | Wrong Answer | 27 | 9,252 | 262 | 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(map(int,input().split()))
cnt = 0
print(N)
print(len(A))
while(1):
exit = False
for i in range(len(A)):
if(A[i]%2 == 1):
exit = True
if(exit == True): break
for i in range(len(A)):
A[i] /= 2
cnt += 1
print(cnt) | s874350289 | Accepted | 27 | 9,116 | 238 | N = int(input())
A = list(map(int,input().split()))
cnt = 0
while(1):
exit = False
for i in range(len(A)):
if(A[i]%2 == 1):
exit = True
if(exit == True): break
for i in range(len(A)):
A[i] /= 2
cnt += 1
print(cnt) |
s700501518 | p02275 | u130834228 | 1,000 | 131,072 | Wrong Answer | 20 | 7,512 | 412 | Counting sort can be used for sorting elements in an array which each of the n input elements is an integer in the range 0 to k. The idea of counting sort is to determine, for each input element x, the number of elements less than x as C[x]. This information can be used to place element x directly into its position in the output array B. This scheme must be modified to handle the situation in which several elements have the same value. Please see the following pseudocode for the detail: Counting-Sort(A, B, k) 1 for i = 0 to k 2 do C[i] = 0 3 for j = 1 to length[A] 4 do C[A[j]] = C[A[j]]+1 5 /* C[i] now contains the number of elements equal to i */ 6 for i = 1 to k 7 do C[i] = C[i] + C[i-1] 8 /* C[i] now contains the number of elements less than or equal to i */ 9 for j = length[A] downto 1 10 do B[C[A[j]]] = A[j] 11 C[A[j]] = C[A[j]]-1 Write a program which sorts elements of given array ascending order based on the counting sort. | def CountingSort(A, B, k):
for i in range(k+1):
C[i] = 0
for j in range(1, n+1):
C[A[j]] += 1
for i in range(1, k+1):
C[i] = C[i] + C[i-1]
for j in range(1, n+1)[::-1]:
B[C[A[j]]] = A[j]
C[A[j]] -= 1
n = int(input())
A = list(map(int, input().split())) | s645127154 | Accepted | 2,740 | 229,448 | 495 | def CountingSort(A, B, k):
C = [0 for i in range(k+1)]
n = len(A)
for j in range(n):
C[A[j]] += 1
for i in range(1, k+1):
C[i] = C[i] + C[i-1]
for j in range(n)[::-1]:
B[C[A[j]]-1] = A[j]
#print(C[A[j]])
C[A[j]] -= 1
n = int(input())
A = list(map(int, input().split()))
B = [0 for i in range(n)]
CountingSort(A, B, max(A))
print(*B) |
s068644588 | p02612 | u415053349 | 2,000 | 1,048,576 | Wrong Answer | 27 | 9,076 | 28 | 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) | s083204242 | Accepted | 34 | 9,176 | 76 | n = int(input())
if n%1000==0:
print(0)
else:
x = n%1000
print(1000-x) |
s766302750 | p03679 | u216631280 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 133 | Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache. | x, a, b = map(int, input().split())
if a <= b:
print('delicious')
elif a + x <= b:
print('safe')
else:
print('dagerous') | s953118625 | Accepted | 17 | 2,940 | 134 | x, a, b = map(int, input().split())
if a >= b:
print('delicious')
elif a + x >= b:
print('safe')
else:
print('dangerous') |
s361111642 | p03544 | u252964975 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 147 | 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) | N=int(input())
L1 = 2
L2 = 1
if N==1:print(L1)
if N==2:print(L2)
if N>3:
N=N-2
for i in range(N):
L=L1+L2
L1 = L2
L2 = L
print(L) | s849181806 | Accepted | 18 | 3,060 | 153 | N=int(input())
N=N+1
L1 = 2
L2 = 1
if N==1:print(L1)
if N==2:print(L2)
if N>2:
N=N-2
for i in range(N):
L=L1+L2
L1 = L2
L2 = L
print(L) |
s882300214 | p03612 | u905582793 | 2,000 | 262,144 | Wrong Answer | 81 | 14,008 | 268 | You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two **adjacent** elements in the permutation. You want to have p_i ≠ i for all 1≤i≤N. Find the minimum required number of operations to achieve this. | n=int(input())
p=list(map(int,input().split()))
p.append(0)
ansls=[0]
if p[0]==1:
ansls[0]=1
for i in range(1,n):
if p[i] ==i+1:
if p[i-1] == i:
ansls[-1]+=1
else:
ansls.append(1)
ans=0
for i in range(len(ansls)):
ans+= (ansls[i]+1)//2
print(ans) | s689032542 | Accepted | 80 | 14,008 | 272 | n=int(input())
p=list(map(int,input().split()))
p.append(0)
ansls=[0]
if p[0]==1:
ansls[0]=1
for i in range(1,n):
if p[i] ==i+1:
if p[i-1] == i:
ansls[-1]+=1
else:
ansls.append(1)
ans=0
for i in range(len(ansls)):
ans+= (ansls[i]+1)//2
print(ans) |
s274217340 | p02694 | u806403461 | 2,000 | 1,048,576 | Wrong Answer | 22 | 9,100 | 105 | 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())
sm = 100
count = 0
while sm >= x:
count += 1
sm += int(0.01*sm)
print(count)
| s815827431 | Accepted | 22 | 8,988 | 104 | x = int(input())
sm = 100
count = 0
while sm < x:
count += 1
sm += int(0.01*sm)
print(count)
|
s130971922 | p02659 | u688203790 | 2,000 | 1,048,576 | Wrong Answer | 22 | 9,092 | 54 | Compute A \times B, truncate its fractional part, and print the result as an integer. | a,b = map(float, input().split())
print(round(a * b)) | s015210753 | Accepted | 23 | 9,164 | 74 | a,b =input().split()
a = int(a)
b = b.replace('.','')
print(a*int(b)//100) |
s556308104 | p03598 | u652081898 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 272 | There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N. In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he placed the i-th type-A robot at coordinates (0, i), and the i-th type-B robot at coordinates (K, i). Thus, now we have one type-A robot and one type-B robot on each of the N lines y = 1, y = 2, ..., y = N. When activated, each type of robot will operate as follows. * When a type-A robot is activated at coordinates (0, a), it will move to the position of the ball on the line y = a, collect the ball, move back to its original position (0, a) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything. * When a type-B robot is activated at coordinates (K, b), it will move to the position of the ball on the line y = b, collect the ball, move back to its original position (K, b) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything. Snuke will activate some of the 2N robots to collect all of the balls. Find the minimum possible total distance covered by robots. |
K = int( input() )
list = map( int, input().split() )
x = 0
for num in list:
a = num * 2
b = (K - num) * 2
if b <= a:
x += b
elif b > a:
x += a
print( x ) | s689957546 | Accepted | 17 | 3,060 | 341 | # -*- coding: utf-8 -*-
N = int( input() )
K = int( input() )
list = map( int, input().split() )
x = 0
for num in list:
a = num * 2
b = (K - num) * 2
if b <= a:
x += b
elif b > a:
x += a
print( x ) |
s184167798 | p03957 | u703890795 | 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. | S = input()
f = 0
for s in S:
if f==0:
if s=="C":
f = 1
elif f==1:
if s=="C":
f = 2
if f == 2:
print("Yes")
else:
print("No") | s015718023 | Accepted | 17 | 2,940 | 153 | S = input()
f = 0
for s in S:
if f==0:
if s=="C":
f = 1
elif f==1:
if s=="F":
f = 2
if f == 2:
print("Yes")
else:
print("No") |
s673955017 | p03377 | u492749916 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 112 | 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:
print("No")
elif X - A <= B:
print("Yes")
else:
print("No") | s002619501 | Accepted | 17 | 2,940 | 101 | A, B, X = list(map(int, input().split()))
if X < A or A + B < X:
print("NO")
else:
print("YES") |
s019660304 | p04043 | u897328029 | 2,000 | 262,144 | Wrong Answer | 20 | 2,940 | 120 | 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. | a, b, c = list(map(int, input().split()))
s = tuple(sorted([a, b, c]))
ans = 'YES' if s == (7,7,5) else 'NO'
print(ans)
| s090969979 | Accepted | 17 | 2,940 | 120 | a, b, c = list(map(int, input().split()))
s = tuple(sorted([a, b, c]))
ans = 'YES' if s == (5,5,7) else 'NO'
print(ans)
|
s888075775 | p03485 | u531599639 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 87 | 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())
if (a+b)%2==0:
print((a+b)/2)
else:
print((a+b)//2+1) | s524194168 | Accepted | 17 | 2,940 | 92 | a,b=map(int, input().split())
if (a+b)%2==0:
print(int((a+b)/2))
else:
print((a+b)//2+1) |
s152426392 | p04029 | u017719431 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 33 | 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*(N+1)/2) | s623351652 | Accepted | 17 | 2,940 | 38 | N = int(input())
print(int(N*(N+1)/2)) |
s397448006 | p02742 | u011276976 | 2,000 | 1,048,576 | Wrong Answer | 29 | 9,024 | 197 | We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move: | h,w = map(int, input().split())
total = h * w
if w % 2:
if h % 2: #both wide, high = odd
ans = (total + 1)/2
print(ans)
exit()
ans = total/2
print(ans) | s920487902 | Accepted | 28 | 9,160 | 170 | h,w = map(int, input().split())
total = h * w
if h == 1 or w == 1:
print(1)
exit()
if total % 2:
ans = (total + 1)//2
else:
ans = total//2
print(ans)
|
s883826439 | p03434 | u623735583 | 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. | n = int(input())
card = list(map(int,input().split()))
a = 0
b = 0
card.sort(reverse=True)
#print(card)
for i in range(1,n+1):
print(a,b)
if i % 2 == 0:
b = b + card[i-1]
else:
a += card[i-1]
#print(a,b)
print(a - b) | s972596177 | Accepted | 17 | 2,940 | 167 | n = int(input())
c = list(map(int,input().split()))
a,b = 0,0
c.sort(reverse=True)
for i,j in enumerate(c):
if i % 2 == 0:
a += j
else:
b += j
print(a-b) |