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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s691672112
|
p00113
|
u319725914
| 1,000
| 131,072
|
Wrong Answer
| 40
| 5,604
| 448
|
2 つの正の整数 p, q を入力し、 p / q を小数として正確に表現することを考えます。(ただし、0 < p < q < 106とします。) このとき、結果は * 有限の桁で正確に表現できる。 * ある桁の範囲を繰り返す循環小数となる。 のいずれかとなります。筆算と同じ手順で1桁ずつ小数部を求めていくと、 * 割り切れた(余りが 0 になった)なら、そこまでの桁で正確に表現できた。 * 1度出てきた余りが、再び現れたなら、循環した。 と区別できます。 2 つの整数 p, q を入力すると、 p / q を小数で表した時の、小数部を出力するプログラムを作成してください。 ただし、 * 結果が有限の桁で正確に表現できる時は、数値だけを 1 行に出力してください。 * 結果が循環小数になる時は次のように 2 行に出力してください。 * 最初の行に、循環する部分までの数字を出力してください。 * 次の行には、循環しない部分の下には空白を出力し、循環する部分の下には「^」を出力してください。 * いずれの場合も数字列は 80 文字を超えることはないものとします。
|
while(True):
checked = []
try: p,q = map(int,input().split())
except: break
ansstr = ""
while(True):
p *= 10
ans,p = p//q, p%q
ansstr += str(ans)
if p == 0:
print(ansstr)
break
if p in checked:
ansind = checked.index(p)
print(ansstr)
print(" "*ansind+"^"*(len(checked)-ansind))
break
else: checked.append(p)
|
s781283639
|
Accepted
| 30
| 5,604
| 443
|
while(True):
try: p,q = map(int,input().split())
except: break
ansstr = ""
checked = [p%q]
while(True):
ans,p = divmod(p*10,q)
ansstr += str(ans)
if p == 0:
print(ansstr)
break
if p in checked:
ansind = checked.index(p)
print(ansstr)
print(" "*(ansind)+"^"*(len(checked)-ansind))
break
else: checked.append(p)
|
s009519378
|
p03673
|
u135116520
| 2,000
| 262,144
|
Wrong Answer
| 147
| 25,540
| 313
|
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b. The i-th operation is as follows: 1. Append a_i to the end of b. 2. Reverse the order of the elements in b. Find the sequence b obtained after these n operations.
|
from collections import deque
n=int(input())
a=list(map(int,input().split()))
b=deque()
if n%2==0:
for x in range(n):
if x%2==0:
b.append(a[x])
else:
b.appendleft(a[x])
if n%2==1:
for y in range(n):
if y%2==0:
b.appendleft(a[y])
else:
b.append(a[y])
print(b)
|
s204615140
|
Accepted
| 216
| 25,412
| 303
|
from collections import deque
n=int(input())
a=list(map(int,input().split()))
b=deque()
if n%2==0:
for x in range(n):
if x%2==0:
b.append(a[x])
else:
b.appendleft(a[x])
if n%2==1:
for y in range(n):
if y%2==0:
b.appendleft(a[y])
else:
b.append(a[y])
print(*b)
|
s832696610
|
p02392
|
u987236471
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,584
| 82
|
Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No".
|
a,b,c = map(int, input().split())
if a > b > c:
print("Yes")
else:
print("No")
|
s045174704
|
Accepted
| 20
| 5,588
| 82
|
a,b,c = map(int, input().split())
if a < b < c:
print("Yes")
else:
print("No")
|
s831256586
|
p03473
|
u844123804
| 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()))
|
s209163068
|
Accepted
| 23
| 3,316
| 25
|
print(24+24-int(input()))
|
s765886988
|
p03493
|
u910536093
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 106
|
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.
|
a = input()
masu = list(a)
ans = 0
for i in range(len(masu)):
if (masu[i] == 1):
ans += 1
print(ans)
|
s173568209
|
Accepted
| 17
| 2,940
| 108
|
a = input()
masu = list(a)
ans = 0
for i in range(len(masu)):
if (masu[i] == "1"):
ans += 1
print(ans)
|
s021290123
|
p03048
|
u227082700
| 2,000
| 1,048,576
|
Wrong Answer
| 1,440
| 3,060
| 136
|
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes. How many triples of non-negative integers (r,g,b) achieve this?
|
r,g,b,n=map(int,input().split())
ans=0
for i in range(n//r+1):
for j in range((n-r*i)//g+1):
if (n-i*r-b*j)%b==0:ans+=1
print(ans)
|
s016090376
|
Accepted
| 1,622
| 2,940
| 137
|
r,g,b,n=map(int,input().split())
ans=0
for i in range(n//r+1):
for j in range((n-r*i)//g+1):
if (n-i*r-g*j)%b==0:ans+=1
print(ans)
|
s576769875
|
p02612
|
u478312272
| 2,000
| 1,048,576
|
Wrong Answer
| 30
| 9,028
| 80
|
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.
|
import math
n = int(input())
n = n/1000
ceil = math.ceil(n)
print((ceil-n)*1000)
|
s555552715
|
Accepted
| 29
| 9,100
| 84
|
import math
n = int(input())
n=(n/1000)
c=math.ceil(n)
a=round((c-n)*1000)
print(a)
|
s831495169
|
p03377
|
u455696302
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 117
|
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.
|
N = [int(i) for i in input().split()]
if N[0] + N[1] <= N[2] or N[0] >= N[2]:
print('NO')
else:
print('Yes')
|
s049752357
|
Accepted
| 17
| 2,940
| 118
|
N = [int(i) for i in input().split()]
if N[0] + N[1] >= N[2] and N[0] <= N[2]:
print('YES')
else:
print('NO')
|
s345157928
|
p02928
|
u122195031
| 2,000
| 1,048,576
|
Wrong Answer
| 393
| 3,188
| 177
|
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()))
cnt = 0
for i in range(n):
for j in range(i+1,n):
if a[i] > a[j]:
cnt += 1
print((cnt*k)%(10**9+7))
|
s735169298
|
Accepted
| 1,060
| 3,188
| 321
|
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = a
cnt = 0
for i in range(n):
for j in range(n):
if i < j:
if a[i] > a[j]:
cnt += 1
tmp = 0
for i in a:
for j in b:
if i > j:
tmp += 1
ans = cnt*k + ((k-1)*k*tmp)//2
print(ans%(10**9+7))
|
s785196134
|
p02612
|
u101113363
| 2,000
| 1,048,576
|
Wrong Answer
| 25
| 9,072
| 67
|
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.
|
"""while True:
break"""
N=int(input())
print(N%1000)
|
s785607974
|
Accepted
| 30
| 9,156
| 129
|
"""while True:
break"""
N=int(input())
s=N//1000
s=(s+1)*1000
if N-s == -1000:
print(0)
else:
print(-(N-s))
|
s502940995
|
p03730
|
u580362735
| 2,000
| 262,144
|
Wrong Answer
| 21
| 2,940
| 95
|
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(A,A*B+1):
if i%B == C:
print(i)
break
|
s208923516
|
Accepted
| 17
| 2,940
| 119
|
A,B,C = map(int,input().split())
for i in range(A,B*A,A):
if i%B == C:
print('YES')
break
else:
print('NO')
|
s431655322
|
p00027
|
u024715419
| 1,000
| 131,072
|
Wrong Answer
| 30
| 6,032
| 251
|
Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29.
|
import datetime
date_list = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
while True:
m, d = map(int, input().split())
if m == d == 0:
break
print(date_list[datetime.date(2014, m, d).weekday()])
|
s924066018
|
Accepted
| 20
| 6,032
| 257
|
import datetime
date_list = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
while True:
m, d = map(int, input().split())
if m == 0 and d == 0:
break
print(date_list[datetime.date(2004, m, d).weekday()])
|
s992507622
|
p03943
|
u432356156
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 107
|
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
a,b,c=[int(x) for x in input().split()]
if(a+b==c or a+c==c or b+c==a):
print("yes")
else:
print("No")
|
s334029154
|
Accepted
| 17
| 2,940
| 107
|
a,b,c=[int(x) for x in input().split()]
if(a==b+c or b==a+c or c==a+b):
print("Yes")
else:
print("No")
|
s300104579
|
p03814
|
u952968889
| 2,000
| 262,144
|
Wrong Answer
| 43
| 8,860
| 111
|
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.
|
s = [i for i in input()]
index_Z = [i for i, x in enumerate(s) if x == 'Z']
print(max(index_Z) - s.index('A'))
|
s351842815
|
Accepted
| 43
| 8,860
| 115
|
s = [i for i in input()]
index_Z = [i for i, x in enumerate(s) if x == 'Z']
print(max(index_Z) - s.index('A') + 1)
|
s529271095
|
p04045
|
u729535891
| 2,000
| 262,144
|
Wrong Answer
| 81
| 6,148
| 403
|
Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money. Find the amount of money that she will hand to the cashier.
|
from collections import deque
n, k = map(int, input().split())
D = list(map(int, input().split()))
ok_lst = [x for x in range(0, 10) if x not in D]
stack = deque([x for x in ok_lst if x != 0])
while len(stack) > 0:
now_num = stack.popleft()
print('now', now_num)
if now_num >= n:
break
for x in ok_lst:
next_num = str(now_num) + str(x)
stack.append(int(next_num))
|
s731761318
|
Accepted
| 99
| 5,812
| 744
|
from collections import deque
n, k = map(int, input().split())
D = list(map(int, input().split()))
ok_lst = [x for x in range(0, 10) if x not in D]
ok_lst.sort(reverse = True)
stack = deque([x for x in ok_lst if x != 0])
ans_list = []
while len(stack) > 0:
now_num = stack.pop()
if now_num >= n:
ans_list.append(now_num)
continue
for x in ok_lst:
next_num = str(now_num) + str(x)
next_num = int(next_num)
stack.append(next_num)
print(min(ans_list))
|
s223960997
|
p03730
|
u607563136
| 2,000
| 262,144
|
Wrong Answer
| 28
| 9,108
| 120
|
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(1,b+1):
if (a*i)%b==c:
print("Yes")
exit()
print("No")
|
s140145921
|
Accepted
| 29
| 9,104
| 94
|
a,b,c=map(int,input().split())
print("YES" if any((a*i)%b==c for i in range(1,b+1)) else "NO")
|
s265471565
|
p02936
|
u970267139
| 2,000
| 1,048,576
|
Wrong Answer
| 2,227
| 300,748
| 613
|
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.
|
import sys
sys.setrecursionlimit(10**8)
n, q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n-1)]
px = [list(map(int, input().split())) for _ in range(q)]
#n = 2*10**5
#px = [[1, 10] for _ in range(q)]
t = dict()
for i in range(1, n+1):
t[i] = [[], 0]
for a, b in ab:
t[a][0].append(b)
def solve(p, x):
if t[p][0] == []:
t[p][1] += x
return
t[p][1] += x
print(t[p][0])
for c in t[p][0]:
solve(c, x)
for p, x in px:
solve(p, x)
print(*[a[1] for a in t.values()], sep=' ')
|
s861740142
|
Accepted
| 1,901
| 346,988
| 504
|
import sys
sys.setrecursionlimit(10**8)
n, q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n-1)]
px = [list(map(int, input().split())) for _ in range(q)]
t = dict()
for i in range(1, n+1):
t[i] = set()
for a, b in ab:
t[a].add(b)
t[b].add(a)
cnt = [0] * n
s = set()
for p, x in px:
cnt[p-1] += x
def solve(p):
s.add(p)
for c in t[p]:
if c not in s:
cnt[c-1] += cnt[p-1]
solve(c)
solve(1)
print(*cnt, sep=' ')
|
s580054004
|
p03401
|
u930705402
| 2,000
| 262,144
|
Wrong Answer
| 2,084
| 13,536
| 386
|
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.
|
from collections import deque
N=int(input())
A=deque(map(int,input().split()))
A.appendleft(0)
A.append(0)
s=0
for i in range(1,N+2):
s+=abs(A[i]-A[i-1])
print(s)
for i in range(1,N+1):
if(A[i-1]<=A[i]<=A[i+1] or A[i-1]>=A[i]>=A[i+1]):
print(s)
elif(A[i-1]>A[i]<A[i+1] or A[i-1]<A[i]>A[i+1]):
print(s-((abs(A[i-1]-A[i])+abs(A[i]-A[i+1]))-abs(A[i-1]-A[i+1])))
|
s399132030
|
Accepted
| 227
| 14,296
| 249
|
from collections import deque
N=int(input())
A=list(map(int,input().split()))
A.insert(0,0)
A.extend([0])
s=0
for i in range(1,N+2):
s+=abs(A[i]-A[i-1])
for i in range(1,N+1):
print(s-((abs(A[i-1]-A[i])+abs(A[i]-A[i+1]))-abs(A[i-1]-A[i+1])))
|
s731209526
|
p03351
|
u022763817
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 137
|
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())
ab = abs(a-b)
bc = abs(b-c)
if (abs(a-c)<d)or(ab<d and bc <d):
print("Yes")
else:
print("No")
|
s817350413
|
Accepted
| 17
| 2,940
| 144
|
a,b,c,d = map(int,input().split())
ab = abs(a-b)
bc = abs(b-c)
if (abs(a-c)<= d)or(ab <= d and bc <= d):
print("Yes")
else:
print("No")
|
s924468344
|
p03962
|
u777394984
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,316
| 100
|
AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive. Since he is forgetful, he might have bought more than one paint can in the same color. Count the number of different kinds of colors of these paint cans and tell him.
|
a,b,c = map(int,input().split())
num = 3
if a==b:
num -= 1
if a==c:
num -= 1
if b==c:
num -= 1
|
s096116687
|
Accepted
| 17
| 2,940
| 54
|
s = list(set(map(int,input().split())))
print(len(s))
|
s178527752
|
p02390
|
u726978687
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,656
| 349
|
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
|
import math as m
def solve(s):
print("suusii")
hours = m.floor(s/3600)
mod_hour = s%3600
minutes = m.floor(mod_hour/60)
seconds = mod_hour%60
answer_format = "{0}:{1}:{2}".format(hours,minutes,seconds)
print(answer_format)
def answer():
s = int(input())
solve(s)
if __name__ == '__main__':
answer()
|
s835379901
|
Accepted
| 20
| 5,660
| 330
|
import math as m
def solve(s):
hours = m.floor(s/3600)
mod_hour = s%3600
minutes = m.floor(mod_hour/60)
seconds = mod_hour%60
answer_format = "{0}:{1}:{2}".format(hours,minutes,seconds)
print(answer_format)
def answer():
s = int(input())
solve(s)
if __name__ == '__main__':
answer()
|
s490462795
|
p03671
|
u830162518
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 66
|
Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
|
a,b,c=map(int,input().split())
L=[a,b,c]
L.sort()
print(L[1]+L[2])
|
s362467085
|
Accepted
| 17
| 2,940
| 66
|
a,b,c=map(int,input().split())
L=[a,b,c]
L.sort()
print(L[1]+L[0])
|
s675035319
|
p02972
|
u294385082
| 2,000
| 1,048,576
|
Wrong Answer
| 49
| 7,148
| 62
|
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)
|
s871305220
|
Accepted
| 235
| 21,676
| 411
|
n = int(input())
a = [0]+list(map(int,input().split()))
N = [i for i in range(1,n+1)]
N.reverse()
ans = [0]*(n+1)
b = []
for i in N:
if i*2 > n:
if a[i] == 1:
ans[i] = 1
else:
if a[i] == 1:
if sum(ans[i::i])%2 == 0:
ans[i] = 1
else:
if sum(ans[i::i])%2 == 1:
ans[i] = 1
for i in range(1,n+1):
if ans[i] == 1:
b.append(i)
print(len(b))
print(*b)
|
s261464844
|
p03729
|
u185037583
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 79
|
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=input().split()
print('Yes' if a[-1:]==b[0:] and b[-1:]==c[0:] else 'No')
|
s753874656
|
Accepted
| 17
| 2,940
| 80
|
a,b,c=input().split()
print('YES' if a[-1:]==b[:1] and b[-1:]==c[:1] else 'NO')
|
s128294448
|
p03400
|
u235084192
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,060
| 147
|
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 = []
for _ in range(N):
A.append(int(input()))
print(X + sum((D-1)//A[i] for i in range(N)))
|
s271042595
|
Accepted
| 18
| 2,940
| 151
|
N = int(input())
D, X = map(int, input().split())
A = []
for _ in range(N):
A.append(int(input()))
print(X + sum((D-1)//A[i] + 1 for i in range(N)))
|
s601083811
|
p03129
|
u656643475
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 96
|
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
|
N, K = list(map(int, input().split()))
re = 'No'
if (N+1)/2 >= K:
re = 'Yes'
print(re)
|
s734138426
|
Accepted
| 17
| 2,940
| 96
|
N, K = list(map(int, input().split()))
re = 'NO'
if (N+1)/2 >= K:
re = 'YES'
print(re)
|
s334099259
|
p03697
|
u089376182
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 67
|
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())
'error' if a + b >= 10 else a + b
|
s179589963
|
Accepted
| 17
| 2,940
| 75
|
a, b = map(int, input().split())
print('error' if a + b >= 10 else a + b)
|
s554847271
|
p03377
|
u347134705
| 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.
|
import sys
A,B,X = map(int,input().split())
if A > X:
print('No')
sys.exit()
if A+B < X:
print('No')
sys.exit()
print('Yes')
|
s766346832
|
Accepted
| 17
| 2,940
| 136
|
import sys
A,B,X = map(int,input().split())
if A > X:
print('NO')
sys.exit()
if A+B < X:
print('NO')
sys.exit()
print('YES')
|
s485126227
|
p03963
|
u284102701
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 48
|
There are N balls placed in a row. AtCoDeer the deer is painting each of these in one of the K colors of his paint cans. For aesthetic reasons, any two adjacent balls must be painted in different colors. Find the number of the possible ways to paint the balls.
|
n,k=map(int,input().split())
print(k*pow(k,n-1))
|
s845683073
|
Accepted
| 17
| 2,940
| 51
|
n,k=map(int,input().split())
print(k*pow(k-1,n-1))
|
s647836041
|
p03470
|
u359787029
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 272
|
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?
|
i = 0
N = int(input())
list = [int(input()) for i in range(N)]
print("before sort",list)
list.sort(reverse = True)
print("after sort",list)
j = 0
cnt = 1
temp = list[0]
for j in range(N):
if(temp > list[j]):
temp = list[j]
cnt = cnt + 1
print(cnt)
|
s840207073
|
Accepted
| 18
| 3,060
| 222
|
#i = 0
N = int(input())
list = [int(input()) for i in range(N)]
list.sort(reverse = True)
j = 0
cnt = 1
temp = list[0]
for j in range(N):
if(temp > list[j]):
temp = list[j]
cnt = cnt + 1
print(cnt)
|
s957693014
|
p03471
|
u979362546
| 2,000
| 262,144
|
Wrong Answer
| 2,104
| 15,304
| 216
|
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())
for i in range(0, n+1):
for j in range(0, n+1-i):
for k in range(0, n+1-i- j):
if 10000*i+5000*j+1000*k == y:
print(i, j, k)
else:
print(-1, -1, -1)
|
s132099456
|
Accepted
| 719
| 3,060
| 203
|
n, y = map(int, input().split())
ans = (-1, -1, -1)
for i in range(0, n+1):
for j in range(0, n+1-i):
if 10000*i+5000*j+1000*(n-i-j) == y:
ans = (i, j, n-i-j)
print(ans[0], ans[1], ans[2])
|
s273992187
|
p03943
|
u940061594
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 190
|
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
a,b,c = map(int,input().split())
if a + b != c:
if b + c != a:
if c + a != b:
print("No")
else:
pass
else:
pass
else:
print("Yes")
|
s245099631
|
Accepted
| 17
| 2,940
| 206
|
a,b,c = map(int,input().split())
if a + b != c:
if b + c != a:
if c + a != b:
print("No")
else:
print("Yes")
else:
print("Yes")
else:
print("Yes")
|
s141395497
|
p02389
|
u435226340
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,580
| 68
|
Write a program which calculates the area and perimeter of a given rectangle.
|
p = input().split()
a = int(p[0])
b = int(p[1])
print(2*(a+b), a*b)
|
s302280840
|
Accepted
| 20
| 5,584
| 53
|
a,b = map(int, input().split())
print(a*b, 2*(a+b))
|
s469241934
|
p03545
|
u527454768
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 303
|
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.
|
n=[int(x) for x in input()]
for i in range((len(n)-1)**2):
result=n[0]
a=["-"]*len(n)
for j in range(len(n)-1):
if (i>>j &1)==1:
result+=n[1]
a[j]="+"
else:
result-=0
if result==7:
print(n[0],a[0],n[1],a[1],n[2],a[2],n[3],"=7")
|
s623611030
|
Accepted
| 18
| 3,064
| 384
|
n=[int(x) for x in input()]
for i in range(2**(len(n)-1)):
s=n[0]
result=[str(n[0])]
for j in range(len(n)-1):
if (i>>j &1)==1:
s+=n[j+1]
result.append("+")
else:
s-=n[j+1]
result.append("-")
result.append(str(n[j+1]))
result.append("=7")
if s==7:
print("".join(result))
break
|
s078905737
|
p03944
|
u757274384
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 308
|
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i). Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows: * If a_i = 1, he painted the region satisfying x < x_i within the rectangle. * If a_i = 2, he painted the region satisfying x > x_i within the rectangle. * If a_i = 3, he painted the region satisfying y < y_i within the rectangle. * If a_i = 4, he painted the region satisfying y > y_i within the rectangle. Find the area of the white region within the rectangle after he finished painting.
|
# -*- coding : utf-8 -*-
w,h,n = map(int, input().split())
l,r,u,d = 0,w,h,0
for i in range(n) :
x,y,a = map(int, input().split())
if a == 1:
l = min(l,x)
elif a == 2:
r = max(r,x)
elif a == 3:
d = min(d,y)
elif a == 4:
u = max(u,y)
S = max(0, u-d) * max(0,l-d)
print(int(S))
|
s849993816
|
Accepted
| 18
| 3,060
| 309
|
# -*- coding : utf-8 -*-
w,h,n = map(int, input().split())
l,r,u,d = 0,w,h,0
for i in range(n) :
x,y,a = map(int, input().split())
if a == 1:
l = max(l,x)
elif a == 2:
r = min(r,x)
elif a == 3:
d = max(d,y)
elif a == 4:
u = min(u,y)
S = max(0, u-d) * max(0,r-l)
print(int(S))
|
s125637389
|
p04043
|
u461996061
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 190
|
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=input().split()
b=0
for i in a:
if i in ['5','7']:
b=b+int(i)
re='Yes'
else:
b=b+int(i)
re='No'
break
if b==17 and re!='No':
print('Yes')
else:
print('No')
|
s825975774
|
Accepted
| 17
| 3,060
| 190
|
a=input().split()
b=0
for i in a:
if i in ['5','7']:
b=b+int(i)
re='Yes'
else:
b=b+int(i)
re='No'
break
if b==17 and re!='No':
print('YES')
else:
print('NO')
|
s086170199
|
p02613
|
u826138795
| 2,000
| 1,048,576
|
Wrong Answer
| 154
| 17,348
| 173
|
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=[]
#print(type(N))
for i in range(N):
s.append(input())
print(s)
aa=["AC","WA","TLE","RE"]
for a in aa:
print("{} × {}".format(a,str(s.count(a))))
|
s937984118
|
Accepted
| 153
| 16,196
| 147
|
N=int(input())
s=[]
for i in range(N):
s.append(input())
aa=["AC","WA","TLE","RE"]
for a in aa:
print("{} x {}".format(a,str(s.count(a))))
|
s274397717
|
p03303
|
u163320134
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 93
|
You are given a string S consisting of lowercase English letters. We will write down this string, starting a new line after every w letters. Print the string obtained by concatenating the letters at the beginnings of these lines from top to bottom.
|
s=input()
n=int(input())
ans=''
for i in range(n):
if i%n==0:
ans+=s[i]
print(ans)
|
s541560600
|
Accepted
| 17
| 2,940
| 93
|
s=input()
n=int(input())
ans=''
for i in range(len(s)):
if i%n==0:
ans+=s[i]
print(ans)
|
s473579470
|
p03845
|
u353919145
| 2,000
| 262,144
|
Wrong Answer
| 21
| 3,316
| 332
|
Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her.
|
n = int(input())
a = list(map(int, input().split()))
m = 10 ** 9 + 7
from collections import Counter
ca = Counter(a)
d = n % 2
if d == 1:
z = ca.pop(0) if 0 in ca else 0
if z != 1:
print(0)
exit()
for i in range(1 + d, n + d, 2):
if ca[i] != 2:
print(0)
exit()
print(pow(2,n//2, m))
|
s508563094
|
Accepted
| 18
| 3,064
| 332
|
import sys
n=int(input())
lineas=sys.stdin.readline()
arr=[]
arr=lineas.split()
arr=list(map(int,arr))
arr.insert(0,0)
m=int(input())
suma=0
lineas2=sys.stdin.readlines()
for i in range(m):
arr2=lineas2[i].split()
p=int(arr2[0])
x=int(arr2[1])
arr3=arr[:]
arr3[p]=x
for i in arr3:
suma=suma+i
print(suma)
suma=0
|
s765052574
|
p04043
|
u307418002
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 152
|
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.
|
def main():
l = list(map(int,(input().split())))
if l.count(5)==2 and l.count(7) == 1:
print("Yes")
else:
print("No")
main()
|
s895828269
|
Accepted
| 17
| 2,940
| 152
|
def main():
l = list(map(int,(input().split())))
if l.count(5)==2 and l.count(7) == 1:
print("YES")
else:
print("NO")
main()
|
s892215664
|
p03493
|
u393229280
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 84
|
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.
|
a = input()
count = 0
for i in a.split():
if i == 1:
count += 1
print(count)
|
s543979529
|
Accepted
| 17
| 2,940
| 90
|
a = input()
count = 0
for i in list(a):
if i == '1':
count += 1
print(count)
|
s111606333
|
p00008
|
u584777171
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,604
| 221
|
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).
|
user = input()
n = int(user)
num = 0
for a in range(10):
for b in range(10):
for c in range(10):
for d in range(10):
if(n == a + b + c + d):
num += 1
print(num)
|
s679404238
|
Accepted
| 200
| 7,540
| 277
|
import sys
for user in sys.stdin:
n = int(user)
num = 0
for a in range(10):
for b in range(10):
for c in range(10):
for d in range(10):
if(n == a + b + c + d):
num += 1
print(num)
|
s740385143
|
p03471
|
u602972961
| 2,000
| 262,144
|
Wrong Answer
| 617
| 2,940
| 273
|
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.
|
def f04():
n, y=map(int, input().split())
answer=-1,-1,-1
for x in range(n+1):
for y in range(n-x+1):
z=n-x-y
if 0<=z<=2000 and 10000*x+5000*y+1000*z==y:
answer=x,y,z
break
print(*answer)
f04()
|
s639426150
|
Accepted
| 623
| 3,060
| 323
|
def f04():
N,Y=map(int,input().split())
answer=-1,-1,-1
for x in range(N+1):
for y in range(N-x+1):
z=N-x-y
if 0<=z<=2000 and 10000*x+5000*y+1000*z==Y:
answer=x,y,z
break
else:
continue
# break
print(*answer)
f04()
|
s746692121
|
p02645
|
u634359243
| 2,000
| 1,048,576
|
Wrong Answer
| 24
| 9,096
| 23
|
When you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters. You have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nickname for him.
|
s=input()
print(s[0:2])
|
s135760561
|
Accepted
| 24
| 8,920
| 23
|
s=input()
print(s[0:3])
|
s692468839
|
p03129
|
u240630407
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 89
|
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 (N/2 + 1) >= K:
print("Yes")
else:
print("No")
|
s327582710
|
Accepted
| 17
| 2,940
| 197
|
N, K = map(int,input().split())
if N % 2 != 0:
if (N/2 + 1) >= K:
print("YES")
else:
print("NO")
else:
if (N/2) >= K:
print("YES")
else:
print("NO")
|
s198903193
|
p02601
|
u962423738
| 2,000
| 1,048,576
|
Wrong Answer
| 33
| 9,176
| 160
|
M-kun has the following three cards: * A red card with the integer A. * A green card with the integer B. * A blue card with the integer C. He is a genius magician who can do the following operation at most K times: * Choose one of the three cards and multiply the written integer by 2. His magic is successful if both of the following conditions are satisfied after the operations: * The integer on the green card is **strictly** greater than the integer on the red card. * The integer on the blue card is **strictly** greater than the integer on the green card. Determine whether the magic can be successful.
|
a,b,c=map(int,input().split())
k=int(input())
cnt=0
for i in range(k):
b*=2
cnt+=1
for i in range(k-cnt):
c*=2
if a<b<c:
print("Yes")
else:
print("No")
|
s947727079
|
Accepted
| 32
| 9,176
| 176
|
a,b,c=map(int,input().split())
k=int(input())
cnt=0
for i in range(k):
if b>a:
break
b*=2
cnt+=1
for i in range(k-cnt):
c*=2
if a<b<c:
print("Yes")
else:
print("No")
|
s186914114
|
p00001
|
u337016727
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,652
| 141
|
There is a data which provides heights (in meter) of mountains. The data is only for ten mountains. Write a program which prints heights of the top three mountains in descending order.
|
# coding: utf-8
list = []
for i in range(10):
list.append(int(input()))
slist = sorted(list)
for i in range(3):
print(slist[i+1])
|
s219413688
|
Accepted
| 30
| 7,620
| 141
|
# coding: utf-8
list = []
for i in range(10):
list.append(int(input()))
slist = sorted(list)
for i in range(3):
print(slist[9-i])
|
s225994521
|
p04043
|
u008323723
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 99
|
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 = map(int,input().split())
d = [a,b,c]
d = sorted(d)
#print(d)
if d ==[5,5,7]:
print('Yes')
|
s370513645
|
Accepted
| 17
| 3,060
| 119
|
a,b,c=list(map(int,input().split()))
s=[a,b,c]
if s.count(5)==2 and s.count(7)==1:
print("YES")
else:
print("NO")
|
s968634881
|
p03836
|
u788068140
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 798
|
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 = 0, 0, 1, 2
sx, sy, tx, ty = map(int,input().split())
def calculate(sx, sy, tx, ty):
width = abs(sx-tx)
height = abs(sy-ty)
if tx - sx > 0:
if ty - sy > 0:
Up = 'U'
Down = 'D'
Left = 'L'
Right = 'R'
else:
Up = 'D'
Down = 'U'
Left = 'L'
Right = 'R'
else:
if ty - sy > 0:
Up = 'U'
Down = 'D'
Left = 'R'
Right = 'L'
else:
Up = 'D'
Down = 'U'
Left = 'R'
Right = 'L'
print(Up*height + Right*width + Down*height + Left*width + Left + Up*(height+1) + Right*(width+2) + Down * (height + 2) + Left * (width + 1) + Up)
calculate(sx,sy,tx,ty)
|
s130789058
|
Accepted
| 21
| 3,316
| 690
|
def calculate(cx1, cy1, cx2, cy2):
Up = 'U'
Right = 'R'
Left = 'L'
Down = 'D'
h = abs(cy2 - cy1)
w = abs(cx2 - cx1)
if cx2 > cx1:
if cy2 < cy1:
Down = 'U'
Up = 'D'
else:
if cy2 > cy1:
Left = 'R'
Right = 'L'
else:
Left = 'R'
Right = 'L'
Down = 'U'
Up = 'D'
return h * Up + w * Right + h * Down + (w + 1) * Left + (h + 1) * Up + (w + 1) * Right + Down + Right + (
h + 1) * Down + (w + 1) * Left + Up
cx1, cy1, cx2, cy2 = -2, -2, 1, 1
cx1, cy1, cx2, cy2 = map(int,input().split())
print(calculate(cx1, cy1, cx2, cy2))
|
s212656430
|
p03997
|
u024612773
| 2,000
| 262,144
|
Wrong Answer
| 23
| 3,064
| 49
|
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.
|
print((int(input())+int(input()))*int(input())/2)
|
s013005771
|
Accepted
| 23
| 3,064
| 50
|
print((int(input())+int(input()))*int(input())//2)
|
s805972102
|
p03044
|
u780420070
| 2,000
| 1,048,576
|
Wrong Answer
| 2,105
| 28,312
| 284
|
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.
|
n=int(input())
a=[[] for i in range(n-1)]
for i in range(n-1):
u,v,w=map(int,input().split())
a[i]=u,v,w
print(a)
b=[0 for i in range(n)]
for i in range(n):
for j in range(n-1):
u,v,w=a[j]
if u==i:
b[v-1]+=w
for i in range(n):
print(b[i]%2)
|
s447000510
|
Accepted
| 723
| 79,488
| 447
|
import sys
sys.setrecursionlimit(10**7)
n=int(input())
a=[[] for i in range(n)]
for i in range(n-1):
u,v,w=map(int,input().split())
a[u-1].append((v-1,w))
a[v-1].append((u-1,w))
b=[None for i in range(n)]
def k(v,dis):
b[v]=dis
for next_v,w in a[v]:
if b[next_v]!=None:
continue
if w%2==0:
k(next_v,dis)
else:
k(next_v,1-dis)
k(0,0)
for i in range(n):
print(b[i])
|
s489283513
|
p00075
|
u350064373
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,516
| 111
|
肥満は多くの成人病の原因として挙げられています。過去においては、一部の例外を除けば、高校生には無縁なものでした。しかし、過度の受験勉強等のために運動不足となり、あるいはストレスによる過食症となることが、非現実的なこととはいえなくなっています。高校生にとっても十分関心を持たねばならない問題になるかもしれません。 そこで、あなたは、保健室の先生の助手となって、生徒のデータから肥満の疑いのある生徒を探し出すプログラムを作成することになりました。 方法は BMI (Body Mass Index) という数値を算出する方法です。BMIは次の式で与えられます。 BMI = 22 が標準的で、25 以上だと肥満の疑いがあります。 各々の生徒の体重、身長の情報から BMI を算出し、25 以上の生徒の学籍番号を出力するプログラムを作成してください。
|
try:
s, w, h = map(float, input().split(','))
if w / h**2 >= 25:
print(int(s))
except:
pass
|
s651672010
|
Accepted
| 30
| 7,448
| 140
|
try:
while True:
s, w, h = map(float, input().split(','))
if w / h**2 >= 25:
print(int(s))
except:
pass
|
s913225654
|
p03456
|
u849401762
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 121
|
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(' ')
N=a+b
N = int(N)
print(N)
for i in range(316):
if (i*i) == N:
print('Yes')
quit()
print('No')
|
s642285480
|
Accepted
| 17
| 2,940
| 112
|
a,b=input().split(' ')
N=a+b
N = int(N)
for i in range(316):
if (i*i) == N:
print('Yes')
quit()
print('No')
|
s370246237
|
p02646
|
u970760882
| 2,000
| 1,048,576
|
Wrong Answer
| 22
| 9,136
| 226
|
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
|
a = input().split()
b = input().split()
c = input()
length = int(a[0]) - int(b[0])
v = int(a[1]) - int(b[1])
if(a[1] == b[1]):
print("no")
else:
times = length / v
if(times <= int(c)):
print("yes")
else:
print("no")
|
s215507818
|
Accepted
| 25
| 9,216
| 369
|
a = input().split()
b = input().split()
c = input()
A = int(a[0])
V = int(a[1])
B = int(b[0])
W = int(b[1])
T = int(c)
if (B>A):
if(W>=V):
print("NO")
else:
times = (B-A) / (V-W)
if(times <= T):
print("YES")
else:
print("NO")
else:
if(W>=V):
print("NO")
else:
times = (A-B) / (V-W)
if(abs(times) <= T):
print("YES")
else:
print("NO")
|
s087580570
|
p03944
|
u677842374
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 380
|
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i). Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows: * If a_i = 1, he painted the region satisfying x < x_i within the rectangle. * If a_i = 2, he painted the region satisfying x > x_i within the rectangle. * If a_i = 3, he painted the region satisfying y < y_i within the rectangle. * If a_i = 4, he painted the region satisfying y > y_i within the rectangle. Find the area of the white region within the rectangle after he finished painting.
|
W, H, N = map(int, input().split())
lis = []
xi = 0
yi = 0
xj = 0
yj = 0
for i in range(N):
#lis.append(list(map(int, input().split())))
x, y, a = map(int, input().split())
if a==1:
xi += x
elif a==2:
xj += x
elif a==3:
yi += y
elif a==4:
yj += y
x = (W-xj)-xi
if x<0:
x = 0
y = (H-yj)-yi
if y<0:
y = 0
print(x*y)
|
s641444735
|
Accepted
| 18
| 3,064
| 431
|
W, H, N = map(int, input().split())
lis = []
xi = 0
yi = 0
xj = W
yj = H
for i in range(N):
#lis.append(list(map(int, input().split())))
x, y, a = map(int, input().split())
if (a==1) and (x>xi):
xi = x
elif (a==2) and (x<xj):
xj = x
elif (a==3) and (y>yi):
yi = y
elif (a==4) and (y<yj):
yj = y
x = W-xi-(W-xj)
if x<0:
x = 0
y = H-(H-yj)-yi
if y<0:
y = 0
print(x*y)
|
s518791402
|
p02741
|
u981864683
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 132
|
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
|
arr = [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]
K = int(input())
arr[K-1]
|
s982761120
|
Accepted
| 17
| 3,060
| 139
|
arr = [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]
K = int(input())
print(arr[K-1])
|
s183173516
|
p03495
|
u808373096
| 2,000
| 262,144
|
Wrong Answer
| 276
| 51,940
| 183
|
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them.
|
from collections import Counter
N, K = map(int, input().split())
A = Counter([int(_) for _ in input().split()])
print(A)
print(sum(A.values()) - sum(dict(A.most_common(K)).values()))
|
s991218550
|
Accepted
| 146
| 32,516
| 173
|
from collections import Counter
N, K = map(int, input().split())
A = Counter([int(_) for _ in input().split()])
print(sum(A.values()) - sum(dict(A.most_common(K)).values()))
|
s451195666
|
p03110
|
u228223940
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 207
|
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())
xu = [[int(i) for i in range(2)] for j in range(n)]
ans = 0
for i in range(n):
if xu[i][1] == 'JPY':
ans += xu[i][0]
else:
ans += 1000*xu[i][0]
print(ans)
|
s412993234
|
Accepted
| 17
| 3,060
| 223
|
n = int(input())
xu = [[i for i in input().split()] for j in range(n)]
ans = 0
for i in range(n):
if xu[i][1] == 'JPY':
ans += int(xu[i][0])
else:
ans += 380000*float(xu[i][0])
print(ans)
|
s447731169
|
p03485
|
u687574784
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 110
|
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.
|
# -*- coding: utf-8 -*-
import math
a, b = list(map(int, input().split()))
a,b = 5,5
print(math.ceil((a+b)/2))
|
s530425051
|
Accepted
| 17
| 2,940
| 102
|
# -*- coding: utf-8 -*-
import math
a, b = list(map(int, input().split()))
print(math.ceil((a+b)/2))
|
s998338614
|
p03657
|
u019578976
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 113
|
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("Possible")
else:
print("Impossible")
|
s569592632
|
Accepted
| 18
| 2,940
| 115
|
a,b=map(int,input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
print("Possible")
else:
print("Impossible")
|
s780788047
|
p03610
|
u602863587
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,188
| 71
|
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
|
s=str(input())
print(i for i in range(len(s)) if index(s[i]) % 2 != 0)
|
s254063624
|
Accepted
| 28
| 3,188
| 77
|
s=str(input())
ans=str('')
for i in range(0,len(s),2):
ans+=s[i]
print(ans)
|
s928204986
|
p03434
|
u709630872
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 212
|
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
|
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
print(a)
alice = 0
bob = 0
for i in range(0, N):
if i%2 == 0:
alice += a[i]
else:
bob += a[i]
print(alice - bob)
|
s331777013
|
Accepted
| 17
| 3,060
| 203
|
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
alice = 0
bob = 0
for i in range(0, N):
if i%2 == 0:
alice += a[i]
else:
bob += a[i]
print(alice - bob)
|
s708053262
|
p03251
|
u882359130
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 3,064
| 258
|
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 = [int(nmxy) for nmxy in input().split()]
x = [int(xx) for xx in input().split()]
y = [int(yy) for yy in input().split()]
x_Z = max(x) + 1
Z_y = min(y)
for Z in range(X+1, Y):
if x_Z < Z <= Z_y:
print("No War")
break
else:
print("War")
|
s399213645
|
Accepted
| 17
| 3,064
| 254
|
N, M, X, Y = [int(nmxy) for nmxy in input().split()]
x = [int(xx) for xx in input().split()]
y = [int(yy) for yy in input().split()]
x_Z = max(x)
Z_y = min(y)
for Z in range(X+1, Y):
if x_Z < Z <= Z_y:
print("No War")
break
else:
print("War")
|
s590822939
|
p03502
|
u776781549
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 85
|
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number.
|
n = input()
if int(n) % sum(list(map(int, n))) == 0:
print("YES")
else:
print("NO")
|
s228727173
|
Accepted
| 17
| 2,940
| 85
|
n = input()
if int(n) % sum(list(map(int, n))) == 0:
print("Yes")
else:
print("No")
|
s888127515
|
p02645
|
u382169668
| 2,000
| 1,048,576
|
Wrong Answer
| 21
| 9,016
| 34
|
When you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters. You have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nickname for him.
|
n = input().split();
print(n[0:3])
|
s937941725
|
Accepted
| 23
| 9,012
| 27
|
n = input();
print(n[0:3])
|
s481083828
|
p02612
|
u004482945
| 2,000
| 1,048,576
|
Wrong Answer
| 30
| 9,156
| 65
|
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 = input()
if len(n) >= 4:
print(int(n[-3:]))
else:
print(n)
|
s507370985
|
Accepted
| 26
| 9,148
| 50
|
n = int(input())
while n > 0:
n -=1000
print(-n)
|
s980672973
|
p03305
|
u884982181
| 2,000
| 1,048,576
|
Wrong Answer
| 2,109
| 90,376
| 839
|
Kenkoooo is planning a trip in Republic of Snuke. In this country, there are n cities and m trains running. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Any city can be reached from any city by changing trains. Two currencies are used in the country: yen and snuuk. Any train fare can be paid by both yen and snuuk. The fare of the i-th train is a_i yen if paid in yen, and b_i snuuk if paid in snuuk. In a city with a money exchange office, you can change 1 yen into 1 snuuk. However, when you do a money exchange, you have to change all your yen into snuuk. That is, if Kenkoooo does a money exchange when he has X yen, he will then have X snuuk. Currently, there is a money exchange office in every city, but the office in City i will shut down in i years and can never be used in and after that year. Kenkoooo is planning to depart City s with 10^{15} yen in his pocket and head for City t, and change his yen into snuuk in some city while traveling. It is acceptable to do the exchange in City s or City t. Kenkoooo would like to have as much snuuk as possible when he reaches City t by making the optimal choices for the route to travel and the city to do the exchange. For each i=0,...,n-1, find the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i years. You can assume that the trip finishes within the year.
|
n,m,s,t = map(int,input().split())
en = []
su = []
for i in range(m):
x1,y1,z1,a1=[int(i) for i in input().split()]
en.append([x1-1,y1-1,z1])
en.append([y1-1,x1-1,z1])
su.append([x1-1,y1-1,a1])
su.append([y1-1,x1-1,a1])
def shortest_path(edge,num_v,start):
inf = float("inf")
d = [inf for f in range(num_v)]
d[start] = 0;
while True:
update = False
for e in edge:
if d[e[0]] != inf and d[e[1]] > d[e[0]] + e[2]:
d[e[1]] = d[e[0]] + e[2]
update = True
if not update:
break
return d
from collections import deque
ans = deque([])
tori = shortest_path(en,n,s-1)
kae = shortest_path(su,n,t-1)
for i in range(n):
ans.appendleft(kae[i]+tori[i])
moti = 10**15
for i in range(n):
c = min(ans)
print(moti-c)
ans.popleft()
|
s954509030
|
Accepted
| 1,829
| 77,620
| 1,139
|
import heapq
n,m,s,t = map(int,input().split())
en = []
su = []
for i in range(m):
x1,y1,z1,a1=[int(i) for i in input().split()]
en.append([x1-1,y1-1,z1])
su.append([x1-1,y1-1,a1])
def shortest_path(edge,num_v,start):
inf = float("inf")
cost = [[] for i in range(n+1)]
for path in edge:
cost[path[0]].append((path[1],path[2]))
cost[path[1]].append((path[0],path[2]))
d = [inf for j in range(num_v)]
q = []
heapq.heappush(q, (0, start))
d[start] = 0
while len(q) != 0:
prov_cost, src = heapq.heappop(q)
if d[src] < prov_cost:
continue
for dest,weight in cost[src]:
if weight != float('inf') and d[dest] > d[src] + weight:
d[dest] = d[src] + weight
heapq.heappush(q, (d[dest], dest))
return d
from collections import deque
ans = deque([])
tori = shortest_path(en,n,s-1)
kae = shortest_path(su,n,t-1)
sai = float("inf")
for i in range(n-1,-1,-1):
kon = kae[i]+tori[i]
if sai > kon:
ans.appendleft(kon)
sai = kon
else:
ans.appendleft(sai)
moti = 10**15
for i in range(n):
print(moti-ans[i])
|
s510216655
|
p03605
|
u933129390
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 74
|
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?
|
n = input()
if n[0]==9 or n[1]==9:
print("Yes")
else:
print("No")
|
s597041501
|
Accepted
| 17
| 2,940
| 78
|
n = input()
if n[0]=='9' or n[1]=='9':
print("Yes")
else:
print("No")
|
s222087161
|
p02850
|
u095562538
| 2,000
| 1,048,576
|
Wrong Answer
| 2,104
| 125,412
| 494
|
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.
|
# coding: utf-8
# Here your code !
import sys
sys.setrecursionlimit(10**6)
N = int(input())
v = [[] for i in range(N)]
for i in range(N-1):
a,b = map(int,input().split())
a,b = a-1,b-1
v[a].append([b,i])
print(v)
ans = [None] * (N-1)
def decide_colord(cur,color):
cnt = 1
for (to,j)in v[cur]:
if cnt == color:
cnt += 1
ans[j] = cnt
decide_colord(to,cnt)
cnt += 1
decide_colord(0,0)
print(max(ans))
[print(a) for a in ans]
|
s290437269
|
Accepted
| 555
| 70,944
| 481
|
# coding: utf-8
# Here your code !
import sys
sys.setrecursionlimit(10**6)
N = int(input())
v = [[] for i in range(N)]
for i in range(N-1):
a,b = map(int,input().split())
a,b = a-1,b-1
v[a].append([b,i])
ans = [None] * (N-1)
def decide_colord(cur,color):
cnt = 1
for (to,j)in v[cur]:
if cnt == color:
cnt += 1
ans[j] = cnt
decide_colord(to,cnt)
cnt += 1
decide_colord(0,0)
print(max(ans))
[print(a) for a in ans]
|
s964733100
|
p04044
|
u784341473
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 74
|
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())
print(sorted([input() for _ in[0]*n]),sep='')
|
s245939638
|
Accepted
| 17
| 3,064
| 72
|
n=int(input().split()[0])
print(''.join(sorted([input()for _ in[0]*n])))
|
s114361493
|
p02841
|
u830829488
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,064
| 361
|
In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019. Integers M_1, D_1, M_2, and D_2 will be given as input. It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1. Determine whether the date 2019-M_1-D_1 is the last day of a month.
|
a = input()
b = input()
month_a = int(a.split(" ")[0])
day_a = int(a.split(" ")[1])
month_b = int(b.split(" ")[0])
day_b = int(b.split(" ")[1])
last_day = [31,28,31,30,31,30,31,31,30,31,30,31]
if month_a - month_b == 0 and day_b - day_a == 1:
val = 1
elif month_b-month_a == 1 and day_a == last_day[month_a-1] and day_b == 1:
val = 1
else:
val = 0
print(val)
|
s623550608
|
Accepted
| 17
| 2,940
| 143
|
a = input()
b = input()
month_a = int(a.split(" ")[0])
month_b = int(b.split(" ")[0])
if month_a != month_b:
val = 1
else:
val = 0
print(val)
|
s511790815
|
p02866
|
u021548497
| 2,000
| 1,048,576
|
Wrong Answer
| 2,104
| 81,172
| 691
|
Given is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition: * For every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.
|
import sys
n = int(input())
d = list(int(x) for x in input().split())
if d[0] != 0:
print(0)
sys.exit()
d.sort()
print(d)
ans = 1
key = 1
value = 1
for i in range(1, n):
if i == 1 and d[i] != 1:
print(0)
sys.exit()
else:
pass
if d[i] == d[i-1]:
key += 1
else:
if d[i] == d[i-1] + 1:
if d[i-1] == 1:
value = key
key = 1
else:
print(value, key)
ans *= pow(value, key)
print(ans)
value = key
key = 1
else:
print(0)
sys.exit()
ans *= pow(value, key)
print(ans)
|
s244996594
|
Accepted
| 236
| 14,396
| 651
|
import sys
n = int(input())
d = list(int(x) for x in input().split())
if d[0] != 0:
print(0)
sys.exit()
d.sort()
ans = 1
key = 1
value = 1
for i in range(1, n):
if i == 1 and d[i] != 1:
print(0)
sys.exit()
else:
pass
if d[i] == d[i-1]:
key += 1
else:
if d[i] == d[i-1] + 1:
if d[i-1] == 1:
value = key
key = 1
else:
ans *= pow(value, key)%998244353
value = key
key = 1
else:
print(0)
sys.exit()
t = pow(value, key)
ans = ans*t%998244353
print(ans)
|
s779081359
|
p03827
|
u172147273
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 127
|
You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).
|
s=input()
ans=0
k=0
for i in s:
if i=='I':
k+=1
ans=max(ans,k)
elif i=='D':
k-=1
print(ans)
|
s765698338
|
Accepted
| 18
| 2,940
| 135
|
n=int(input())
s=input()
ans=0
k=0
for i in s:
if i=='I':
k+=1
ans=max(ans,k)
else:
k-=1
print(ans)
|
s610330269
|
p04025
|
u230117534
| 2,000
| 262,144
|
Wrong Answer
| 38
| 3,064
| 301
|
Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2). Find the minimum total cost to achieve his objective.
|
import sys
S = input().strip()
for i in range(3,len(S)+1):
for j in range(0,len(S)+1-i):
s = S[j:j+i]
for k in set(s):
if s.count(k)*2 > len(s):
print(k)
print(s)
print(j+1,j+i)
sys.exit(0)
print(-1,-1)
|
s900244192
|
Accepted
| 40
| 3,064
| 238
|
import math
N = int(input())
a = [int(i) for i in input().strip().split(" ")]
a_h = math.ceil(sum(a) / len(a))
a_l = math.floor(sum(a) / len(a))
d_h = sum([(a_h-i)**2 for i in a])
d_l = sum([(a_l-i)**2 for i in a])
print(min(d_h,d_l))
|
s885666443
|
p02741
|
u310245677
| 2,000
| 1,048,576
|
Wrong Answer
| 28
| 9,024
| 35
|
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
|
s=input()
print(s[0:4]+' '+s[4:12])
|
s838585249
|
Accepted
| 29
| 9,192
| 130
|
k=int(input())
a=[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]
print(a[k-1])
|
s427469892
|
p03400
|
u551692187
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 214
|
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)]
ans = 0
for i in A:
if D % i == 0:
ans += D // i
else:
ans += D // i + 1
print(ans)
print(ans + X)
|
s680500630
|
Accepted
| 18
| 3,060
| 199
|
N = int(input())
D,X = map(int, input().split())
A = [int(input()) for i in range(N)]
ans = 0
for i in A:
if D % i == 0:
ans += D // i
else:
ans += D // i + 1
print(ans + X)
|
s115130521
|
p02260
|
u865220118
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,596
| 564
|
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.
|
A = []
LENGTH =int(input())
A = input().split()
i = 0
j = 1
CHANGE = 0
while i <= LENGTH -1 :
j = i + 1
mini = i
while j <= LENGTH -1:
if int(A[j]) < int(A[mini]) :
tmp = A[j]
A[j] = A[mini]
A[mini] = tmp
CHANGE += 1
j += 1
i += 1
CHANGE += 1
print(" ".join(map(str,A)))
print (CHANGE)
|
s005348240
|
Accepted
| 20
| 5,600
| 758
|
# SelectionSort(A)
#3 for j = i to A.length-1
#4 if A[j] < A[mini]
#6 swap A[i] and A[mini]
A = []
LENGTH =int(input())
A = input().split()
i = 0
CHANGE_COUNT = 0
while i <= LENGTH -1:
j = i + 1
mini = i
while j <= LENGTH -1:
if int(A[j]) < int(A[mini]) :
mini = j
j += 1
if mini != i:
tmp = A[i]
A[i] = A[mini]
A[mini] = tmp
CHANGE_COUNT += 1
i += 1
print(" ".join(map(str,A)))
print (CHANGE_COUNT)
|
s966501068
|
p02612
|
u229156891
| 2,000
| 1,048,576
|
Wrong Answer
| 32
| 9,152
| 72
|
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.
|
import math
N = int(input())
ans = math.ceil(N / 1000)
print(ans - N)
|
s084644323
|
Accepted
| 25
| 9,140
| 80
|
import math
N = int(input())
ans = math.ceil(N / 1000)
print(ans * 1000 - N)
|
s740576943
|
p03545
|
u052746401
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 344
|
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.
|
#!/usr/bin/env python
import itertools
input_str = input()
print(input_str)
A = input_str[0]
B = input_str[1]
C = input_str[2]
D = input_str[3]
ops = ['+', '-']
all_ops = list(itertools.product(A, ops, B, ops, C, ops, D))
for tmp in all_ops:
result = eval(''.join(tmp))
if result == 7:
print(''.join(tmp) + "=7")
break
|
s112800679
|
Accepted
| 17
| 3,060
| 327
|
#!/usr/bin/env python
import itertools
input_str = input()
A = input_str[0]
B = input_str[1]
C = input_str[2]
D = input_str[3]
ops = ['+', '-']
all_ops = list(itertools.product(A, ops, B, ops, C, ops, D))
for tmp in all_ops:
result = eval(''.join(tmp))
if result == 7:
print(''.join(tmp) + "=7")
break
|
s833607758
|
p03740
|
u059262067
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 125
|
Alice and Brown loves games. Today, they will play the following game. In this game, there are two piles initially consisting of X and Y stones, respectively. Alice and Bob alternately perform the following operation, starting from Alice: * Take 2i stones from one of the piles. Then, throw away i of them, and put the remaining i in the other pile. Here, the integer i (1≤i) can be freely chosen as long as there is a sufficient number of stones in the pile. The player who becomes unable to perform the operation, loses the game. Given X and Y, determine the winner of the game, assuming that both players play optimally.
|
a = list(map(int,input().split(" ")))
if (a[0] < 2 and a[1] < 2) or a[0] == a[1]:
print("Brown")
else:
print("Alice")
|
s963658989
|
Accepted
| 17
| 2,940
| 106
|
a = list(map(int,input().split(" ")))
if abs(a[0] - a[1]) < 2:
print("Brown")
else:
print("Alice")
|
s735446439
|
p03575
|
u653005308
| 2,000
| 262,144
|
Wrong Answer
| 29
| 3,064
| 774
|
You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges. The i-th edge (1 \leq i \leq M) connects Vertex a_i and Vertex b_i. An edge whose removal disconnects the graph is called a _bridge_. Find the number of the edges that are bridges among the M edges.
|
n,m=map(int,input().split())
path=[[0]*n for i in range(n)]
for i in range(m):
a,b=map(int,input().split())
path[a-1][b-1]=1
path[b-1][a-1]=1
def connected(v,visited):
visited[v]=1
if sum(visited)==n:
visited=[0]*n
return 1
count=0
for i in range(n):
if path[v][i]==1 and visited[i]==0:
visited[i]=1
count+=connected(i,visited)
visited=[0]*n
return count
bridge=0
for x in range(n):
for y in range(x+1,n):
if path[x][y]==1:
visited=[0]*n
path[x][y]=0
if not connected(x,visited):
print(x,y)
bridge+=1
path[x][y]=1
print(bridge)
|
s896370331
|
Accepted
| 29
| 3,064
| 746
|
n,m=map(int,input().split())
path=[[0]*n for i in range(n)]
for i in range(m):
a,b=map(int,input().split())
path[a-1][b-1]=1
path[b-1][a-1]=1
def connected(v,visited):
visited[v]=1
if sum(visited)==n:
visited=[0]*n
return 1
count=0
for i in range(n):
if path[v][i]==1 and visited[i]==0:
visited[i]=1
count+=connected(i,visited)
visited=[0]*n
return count
bridge=0
for x in range(n):
for y in range(x+1,n):
if path[x][y]==1:
visited=[0]*n
path[x][y]=0
if not connected(x,visited):
bridge+=1
path[x][y]=1
print(bridge)
|
s501618982
|
p02614
|
u167908302
| 1,000
| 1,048,576
|
Wrong Answer
| 49
| 9,196
| 523
|
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.
|
# coding:utf-8
h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]
# print(c)
black = 0
H = []
W = []
ans = 0
for bit_h in range(2**h):
for bit_w in range(2**w):
black = 0
for i in range(h):
if not ((bit_h >> 1) & 1):
continue
for j in range(w):
if not ((bit_w >> 1) & 1):
continue
if c[i][j] == '#':
black += 1
if black == k:
ans += 1
print(ans)
|
s029089765
|
Accepted
| 60
| 9,200
| 418
|
# coding:utf-8
h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]
# print(c)
black = 0
ans = 0
for bit_h in range(2**h):
for bit_w in range(2**w):
black = 0
for i in range(h):
for j in range(w):
if ((bit_h >> i) & 1) and ((bit_w >> j) & 1) and c[i][j] == '#':
black += 1
if black == k:
ans += 1
print(ans)
|
s028277951
|
p03599
|
u687044304
| 3,000
| 262,144
|
Wrong Answer
| 27
| 3,064
| 1,060
|
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.
|
# -*- coding:utf-8 -*-
def solve():
A, B, C, D, E, F = list(map(int, input().split()))
dp= [0]*(F+1)
for i in range(1, F+1):
if i+100*A <= F:
concent = (dp[i]*i)/(i+100*A)
concent = concent if concent <= E/(100+E) else 0
dp[i+100*A] = max(dp[i+100*A], concent)
if i+100*B <= F:
concent = (dp[i]*i)/(i+100*B)
concent = concent if concent <= E/(100+E) else 0
dp[i+100*B] = max(dp[i+100*B], concent)
if i+C <= F:
concent = (dp[i]*i+C)/(i+C)
concent = concent if concent <= E/(100+E) else 0
dp[i+C] = max(dp[i+C], concent)
if i+D <= F:
concent = (dp[i]*i+D)/(i+D)
concent = concent if concent <= E/(100+E) else 0
dp[i+D] = max(dp[i+D], concent)
max_concent = max(dp)
print(dp.index(max_concent), round(dp.index(max_concent)*max_concent))
if __name__ == "__main__":
solve()
|
s947719707
|
Accepted
| 2,884
| 13,392
| 2,088
|
# -*- coding:utf-8 -*-
def solve2():
A, B, C, D, E, F = list(map(int, input().split()))
sugars = []
for i in range(0, F+1):
for j in range(0, F+1):
y = i*C + j*D
if y <= F:
sugars.append(y)
water = []
for i in range(0, F+1):
for j in range(0, F+1):
x = 100*A*i + 100*B*j
if x <= F:
water.append(x)
sugars.sort()
water.sort()
concent = 0
for x in water:
for y in sugars:
if x+y > F:
break
if x+y > 0 and y/(x+y) <= E/(100+E):
if y/(x+y) >= concent:
concent = y/(x+y)
ans = "{} {}".format(x+y, y)
print(ans)
def solve():
""" WA """
A, B, C, D, E, F = list(map(int, input().split()))
dp= [0]*(F+1)
for i in range(0, F+1):
if i+100*A <= F:
concent = (dp[i]*i)/(i+100*A)
concent = concent if concent <= E/(100+E) else 0
dp[i+100*A] = max(dp[i+100*A], concent)
if i+100*B <= F:
concent = (dp[i]*i)/(i+100*B)
concent = concent if concent <= E/(100+E) else 0
dp[i+100*B] = max(dp[i+100*B], concent)
if i+C <= F:
concent = (dp[i]*i+C)/(i+C)
concent = concent if concent <= E/(100+E) else 0
dp[i+C] = max(dp[i+C], concent)
if i+D <= F:
concent = (dp[i]*i+D)/(i+D)
concent = concent if concent <= E/(100+E) else 0
dp[i+D] = max(dp[i+D], concent)
print(dp)
return
max_concent = max(dp)
print(dp.index(max_concent), round(dp.index(max_concent)*max_concent))
if __name__ == "__main__":
solve2()
|
s746825411
|
p03494
|
u076996519
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 150
|
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.
|
import math
n = input()
a = list(map(int, input().split()))
ans = float("inf")
for i in a:
ans = min(ans, bin(i).rfind("1") - 1)
print(round(ans))
|
s478759003
|
Accepted
| 18
| 3,060
| 164
|
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))
|
s488883141
|
p03478
|
u071416928
| 2,000
| 262,144
|
Wrong Answer
| 33
| 3,060
| 201
|
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())
rslt = 0
for i in range(1,n+1):
s = str(i)
sum = 0
for j in s:
sum = sum + int(j)
if sum >= a and sum <= b:
rslt += sum
print(rslt)
|
s662154876
|
Accepted
| 34
| 3,060
| 223
|
n, a, b = map(int, input().split())
rslt = 0
for i in range(1,n+1):
s = str(i)
sum = 0
for j in s:
sum = sum + int(j)
if sum >= a and sum <= b:
rslt += i
print(rslt)
|
s062335693
|
p03644
|
u268792407
| 2,000
| 262,144
|
Wrong Answer
| 147
| 12,500
| 62
|
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())
from numpy import log
print(int(log(n)/log(2)))
|
s644004203
|
Accepted
| 151
| 12,500
| 70
|
n=int(input())
from numpy import log
print(pow(2,int(log(n)/log(2))))
|
s727851237
|
p03759
|
u740767776
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 88
|
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
|
a, b, c = map(int,input().split())
if b - a == c - a:
print("YES")
else:
print("NO")
|
s167667108
|
Accepted
| 17
| 2,940
| 88
|
a, b, c = map(int,input().split())
if b - a == c - b:
print("YES")
else:
print("NO")
|
s502974201
|
p03730
|
u401487574
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 127
|
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(a,a*b,a):
if i%b == c:
print("Yes")
break
else:print("No")
|
s586618127
|
Accepted
| 17
| 2,940
| 127
|
a,b,c = map(int,input().split())
for i in range(a,a*b,a):
if i%b == c:
print("YES")
break
else:print("NO")
|
s886819133
|
p03997
|
u557136512
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 77
|
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
print(s)
|
s811866731
|
Accepted
| 17
| 2,940
| 88
|
a = int(input())
b = int(input())
h = int(input())
s = (a + b) * h / 2
print(int(s))
|
s253392306
|
p02694
|
u085329544
| 2,000
| 1,048,576
|
Wrong Answer
| 25
| 9,192
| 85
|
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())
d = 100
i = 0
while d <= x:
d += d//100
i += 1
else:
print(i)
|
s144720727
|
Accepted
| 24
| 9,152
| 84
|
x = int(input())
d = 100
i = 0
while d < x:
d += d//100
i += 1
else:
print(i)
|
s265836645
|
p00271
|
u350064373
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,568
| 280
|
選手の皆さん、パソコン甲子園にようこそ。イベントに参加するには体調管理が大切です。気温が大きく変動する季節の変わり目には体に負担がかかり、風邪をひきやすいと言われています。一番気を付けなければいけない日は、最高気温と最低気温の差が最も大きい日です。1日の最高気温と最低気温が7日分与えられたとき、それぞれの日について最高気温から最低気温を引いた値を出力するプログラムを作成してください。
|
for i in range(7):
ls = list(map(int, input().split()))
if max(ls) > 0 and min(ls) > 0:
print(max(ls) - min(ls))
elif max(ls) > 0 and min(ls) < 0:
print(max(ls) + min(ls))
elif max(ls) < 0 and min(ls) < 0:
print(abs(max(ls)) - abs(min(ls)))
|
s050388529
|
Accepted
| 20
| 7,640
| 70
|
for i in range(7):
a, b = map(int, input().split())
print(a-b)
|
s568480676
|
p03050
|
u813102292
| 2,000
| 1,048,576
|
Wrong Answer
| 310
| 3,060
| 331
|
Snuke received a positive integer N from Takahashi. A positive integer m is called a _favorite number_ when the following condition is satisfied: * The quotient and remainder of N divided by m are equal, that is, \lfloor \frac{N}{m} \rfloor = N \bmod m holds. Find all favorite numbers and print the sum of those.
|
def main():
n = int(input())
res = 0
if n<=8:
for i in range(1,n):
if n//i == n%i:
res += n%i
else:
for i in range(1,int(n**(1/2))+1):
if (n-i)/i == (n-i)//i and (n-i)//i>0:
res += (n-i)//i
print(res)
if __name__ == '__main__':
main()
|
s021217803
|
Accepted
| 323
| 3,060
| 327
|
def main():
n = int(input())
res = 0
if n<=8:
for i in range(1,n):
if n//i == n%i:
res += i
else:
for i in range(1,int(n**(1/2))):
if (n-i)/i == (n-i)//i and (n-i)//i>0:
res += (n-i)//i
print(res)
if __name__ == '__main__':
main()
|
s079583716
|
p03971
|
u593567568
| 2,000
| 262,144
|
Wrong Answer
| 67
| 5,800
| 415
|
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these. Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests. * A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B. * An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students. A string S is assigned indicating attributes of all participants. If the i-th character of string S is `a`, this means the participant ranked i-th in the Qualification contests is a Japanese student; `b` means the participant ranked i-th is an overseas student; and `c` means the participant ranked i-th is neither of these. Write a program that outputs for all the participants in descending rank either `Yes` if they passed the Qualification contests or `No` if they did not pass.
|
N,A,B = map(int,input().split())
S = list(input())
ans = []
df = 0
f = 0
for i in range(N):
s = S[i]
if s == 'c':
ans.append('No')
continue
elif s == 'a':
df += 1
if df <= A:
ans.append('Yes')
else:
ans.append('No')
elif s == 'b':
df += 1
f += 1
if df <= A and f <= B:
ans.append('Yes')
else:
ans.append('No')
print('\n'.join(ans))
|
s099574582
|
Accepted
| 75
| 5,924
| 440
|
N,A,B = map(int,input().split())
S = list(input())
C = A + B
ans = []
df = 0
f = 0
for i in range(N):
s = S[i]
if s == 'c':
ans.append('No')
continue
elif s == 'a':
df += 1
if df <= C:
ans.append('Yes')
else:
ans.append('No')
elif s == 'b':
df += 1
f += 1
if df <= C and f <= B:
ans.append('Yes')
else:
df -= 1
ans.append('No')
print('\n'.join(ans))
|
s123439426
|
p03693
|
u867848444
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 78
|
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?
|
r,g,b=map(int,input().split())
a=r*100+g*10+b
print('Yes' if a%4==0 else 'No')
|
s993264819
|
Accepted
| 17
| 2,940
| 80
|
r,g,b=map(str,input().split())
ans=int(r+g+b)
print('YES' if ans%4==0 else 'NO')
|
s284206678
|
p03377
|
u497046426
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 96
|
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 in range(B):
print("Yes")
else:
print("No")
|
s865148976
|
Accepted
| 18
| 2,940
| 96
|
A, B, X = map(int, input().split())
if X - A in range(B):
print("YES")
else:
print("NO")
|
s706270606
|
p03829
|
u210440747
| 2,000
| 262,144
|
Wrong Answer
| 85
| 14,252
| 289
|
There are N towns on a line running east-west. The towns are numbered 1 through N, in order from west to east. Each point on the line has a one- dimensional coordinate, and a point that is farther east has a greater coordinate value. The coordinate of town i is X_i. You are now at town 1, and you want to visit all the other towns. You have two ways to travel: * Walk on the line. Your _fatigue level_ increases by A each time you travel a distance of 1, regardless of direction. * Teleport to any location of your choice. Your fatigue level increases by B, regardless of the distance covered. Find the minimum possible total increase of your fatigue level when you visit all the towns in these two ways.
|
if __name__=="__main__":
[N, A, B] = map(int,input().split())
xs = list(map(int,input().split()))
d_xs = [xs[i] - xs[i-1] for i in range(1,len(xs))]
print(d_xs)
s = 0
for d in d_xs:
if(d*A < B):
s+=d*A
else:
s+=B
print(s)
|
s446507008
|
Accepted
| 79
| 15,020
| 273
|
if __name__=="__main__":
[N, A, B] = map(int,input().split())
xs = list(map(int,input().split()))
d_xs = [xs[i] - xs[i-1] for i in range(1,len(xs))]
s = 0
for d in d_xs:
if(d*A < B):
s+=d*A
else:
s+=B
print(s)
|
s395910207
|
p02612
|
u115877451
| 2,000
| 1,048,576
|
Wrong Answer
| 28
| 9,044
| 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.
|
a=int(input())
print(a%1000)
|
s147045204
|
Accepted
| 26
| 9,156
| 52
|
a=int(input())
print((a//1000+min(a%1000,1))*1000-a)
|
s822267295
|
p03693
|
u141642872
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 112
|
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?
|
[r,g,b] = list(map(int, input().split()))
num = r*100+g*10+b
if num % 4 == 0:
print("Yes")
else:
print("No")
|
s779576933
|
Accepted
| 18
| 2,940
| 115
|
[r,g,b] = list(map(int, input().split()))
x = r*100 + g*10 + b
if x % 4 == 0:
print("YES")
else:
print("NO")
|
s290351460
|
p03455
|
u614320306
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 97
|
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())
c = (a*b)%2
if c == 0:
print("even")
else:
print("odd")
|
s327064222
|
Accepted
| 17
| 2,940
| 97
|
a, b = map(int, input().split())
c = (a*b)%2
if c == 0:
print("Even")
else:
print("Odd")
|
s053397448
|
p03738
|
u796060588
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 328
|
You are given two positive integers A and B. Compare the magnitudes of these numbers.
|
# vim: set fileencoding=utf-8:
def main():
O = input()
E = input()
ans = ''
for o, e in zip(O, E):
ans += o + e
if len(O) > len(E):
ans += O[-1]
elif len(O) < len(E):
ans += E[-1]
elif len(O) == len(E):
pass
print(ans)
if __name__ == "__main__":
main()
|
s732716133
|
Accepted
| 17
| 2,940
| 244
|
# vim: set fileencoding=utf-8:
def main():
A = int(input())
B = int(input())
if A == B:
print('EQUAL')
elif A > B:
print('GREATER')
elif A < B:
print('LESS')
if __name__ == "__main__":
main()
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.