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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s816283823
|
p02409
|
u256678932
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,708 | 310 |
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left. Assume that initially no person lives in the building.
|
bldgs = []
for k in range(4):
bldgs.append([[0 for i in range(10)] for j in range(3)])
n = int(input())
for i in range(n):
b,f,r,v = map(int, input().split(' '))
bldgs[b-1][f-1][r-1] += v
for bldg in bldgs:
for floor in bldg:
print(' '.join([str(f) for f in floor]))
print('#'*20)
|
s121807184
|
Accepted
| 20 | 5,608 | 368 |
buildings = [ [
[ 0 for _ in range(10) ] for _ in range(3)
] for _ in range(4) ]
n = int(input())
for _ in range(n):
b, f, r, v = map(int, input().split())
buildings[b-1][f-1][r-1] += v
sep = ''
for building in buildings:
if sep:
print(sep)
for floor in building:
print(" "+" ".join([str(x) for x in floor]))
sep = '#'*20
|
s072755022
|
p03765
|
u648212584
| 2,000 | 262,144 |
Wrong Answer
| 908 | 6,648 | 647 |
Let us consider the following operations on a string consisting of `A` and `B`: 1. Select a character in a string. If it is `A`, replace it with `BB`. If it is `B`, replace with `AA`. 2. Select a substring that is equal to either `AAA` or `BBB`, and delete it from the string. For example, if the first operation is performed on `ABA` and the first character is selected, the string becomes `BBBA`. If the second operation is performed on `BBBAAAA` and the fourth through sixth characters are selected, the string becomes `BBBA`. These operations can be performed any number of times, in any order. You are given two string S and T, and q queries a_i, b_i, c_i, d_i. For each query, determine whether S_{a_i} S_{{a_i}+1} ... S_{b_i}, a substring of S, can be made into T_{c_i} T_{{c_i}+1} ... T_{d_i}, a substring of T.
|
def main():
S = list(str(input()))
T = list(str(input()))
q = int(input())
S_cum = [0]
T_cum = [0]
for i in S:
if i == "A":
S_cum.append((S_cum[-1]+1)%3)
else:
S_cum.append((S_cum[-1]+2)%3)
for i in T:
if i == "A":
T_cum.append((T_cum[-1]+1)%3)
else:
T_cum.append((T_cum[-1]+2)%3)
for i in range(q):
a,b,c,d = map(int,input().split())
s_ = S_cum[b]-S_cum[a-1]
t_ = T_cum[d]-T_cum[c-1]
if s_%3 == t_%3:
print("Yes")
else:
print("No")
if __name__ == "__main__":
main()
|
s314580817
|
Accepted
| 912 | 6,648 | 647 |
def main():
S = list(str(input()))
T = list(str(input()))
q = int(input())
S_cum = [0]
T_cum = [0]
for i in S:
if i == "A":
S_cum.append((S_cum[-1]+1)%3)
else:
S_cum.append((S_cum[-1]+2)%3)
for i in T:
if i == "A":
T_cum.append((T_cum[-1]+1)%3)
else:
T_cum.append((T_cum[-1]+2)%3)
for i in range(q):
a,b,c,d = map(int,input().split())
s_ = S_cum[b]-S_cum[a-1]
t_ = T_cum[d]-T_cum[c-1]
if s_%3 == t_%3:
print("YES")
else:
print("NO")
if __name__ == "__main__":
main()
|
s210707546
|
p03448
|
u268792407
| 2,000 | 262,144 |
Wrong Answer
| 843 | 3,064 | 224 |
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())
l=x//50
m=x//100
n=x//500
ans=0
for i in range(n+1):
for j in range(m+1):
for k in range(l+1):
if l*50 + m*100 + n*500 == x:
ans += 1
print(ans)
|
s772772662
|
Accepted
| 48 | 3,060 | 199 |
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans=0
for i in range(a+1):
for j in range(b+1):
for k in range(c+1):
if k*50 + j*100 + i*500 == x:
ans += 1
print(ans)
|
s079811953
|
p00506
|
u724548524
| 8,000 | 131,072 |
Wrong Answer
| 20 | 5,604 | 456 |
入力ファイルの1行目に正整数 n が書いてあり, 2行目には半角空白文字1つを区切りとして, n 個の正整数が書いてある. n は 2 または 3 であり, 2行目に書かれているどの整数も値は 108 以下である. これら2個または3個の数の公約数をすべて求め, 小さい方から順に1行に1個ずつ出力せよ. 自明な公約数(「1」)も出力すること. 出力ファイルにおいては, 出力の最後行にも改行コードを入れること.
|
n = int(input())
a = list(map(int,input().split()))
a.sort()
if n == 3:
while a[1] % a[2] != 0:
r = a[1] % a[2]
a[1] = a[2]
a[2] = r
a[1] = a[2]
while a[0] % a[1] != 0:
r = a[0] % a[1]
a[0] = a[1]
a[1] = r
if a[1] == 1:
print(1)
else:
y = [1]
i = 2
while len(y) == 1 or i <= int(a[1] / y[1] + 1):
if a[1] % i == 0:
y.append(i)
i += 1
for i in y:
print(i)
|
s139854537
|
Accepted
| 70 | 5,608 | 472 |
n = int(input())
a = list(map(int,input().split()))
a.sort()
if n == 3:
while a[1] % a[2] != 0:
r = a[1] % a[2]
a[1] = a[2]
a[2] = r
a[1] = a[2]
while a[0] % a[1] != 0:
r = a[0] % a[1]
a[0] = a[1]
a[1] = r
if a[1] == 1:
print(1)
else:
y = [1]
i = 2
while len(y) == 1 or i <= int(a[1] / y[1] + 1):
if a[1] % i == 0:
y.append(i)
i += 1
for i in y:
print(i)
print(a[1])
|
s270967672
|
p03680
|
u157020659
| 2,000 | 262,144 |
Wrong Answer
| 55 | 7,856 | 193 |
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i. When Button i is not lighten up, nothing will happen by pressing it. Initially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up. Determine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.
|
n = int(input())
switch = [i - 1 for i in range(n)]
flag = [False] * n
i = 0
cnt = 0
while not flag[i]:
cnt += 1
flag[i] = True
i = switch[i]
if i == 1:
print(cnt)
else:
print(-1)
|
s503597971
|
Accepted
| 218 | 7,852 | 238 |
n = int(input())
a = []
for _ in range(n):
a.append(int(input()) - 1)
cnt = 0
i = 0
flag = [False] * n
while not flag[i]:
cnt += 1
flag[i] = True
i = a[i]
if i == 1:
print(cnt)
break
else:
print(-1)
|
s377441151
|
p03472
|
u297045966
| 2,000 | 262,144 |
Wrong Answer
| 2,105 | 21,984 | 720 |
You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, …, Katana N, and can perform the following two kinds of attacks in any order: * Wield one of the katana you have. When you wield Katana i (1 ≤ i ≤ N), the monster receives a_i points of damage. The same katana can be wielded any number of times. * Throw one of the katana you have. When you throw Katana i (1 ≤ i ≤ N) at the monster, it receives b_i points of damage, and you lose the katana. That is, you can no longer wield or throw that katana. The monster will vanish when the total damage it has received is H points or more. At least how many attacks do you need in order to vanish it in total?
|
N, H = input().strip().split(' ')
N, H =[int(N),int(H)]
L =list()
for i in range(0,N):
X, Y = input().strip().split(' ')
X, Y =[int(X), int(Y)]
L.append([X,Y])
L0 = list()
for i in range(0,N):
L0.append(L[i][0])
L1 = list()
for i in range(0,N):
L1.append(L[i][1])
M = max(L0)
L2 = list()
for i in range(0,N):
if L1[i] > M:
L2.append(L1[i])
for i in range(0,len(L2)):
for j in range(i, len(L2)-1):
if L2[j] < L2[j+1]:
Y = L2[j+1]
L2[j+1] = L2[j]
L2[j] = Y
count = 0
for i in range(0,len(L2)):
if H > 0:
H -= L2[i]
count += 1
if H <= 0:
print(count)
if H > 0:
count += H//M
print(count)
|
s436163767
|
Accepted
| 418 | 23,076 | 679 |
N, H = input().strip().split(' ')
N, H =[int(N),int(H)]
L =list()
for i in range(0,N):
X, Y = input().strip().split(' ')
X, Y =[int(X), int(Y)]
L.append([X,Y])
L0 = list()
for i in range(0,N):
L0.append(L[i][0])
L1 = list()
for i in range(0,N):
L1.append(L[i][1])
M = max(L0)
L2 = list()
for i in range(0,N):
if L1[i] > M:
L2.append(L1[i])
L2 = sorted(L2)
L2 = L2[::-1]
count = 0
for i in range(0,len(L2)):
if H > 0:
H -= L2[i]
count += 1
if H <= 0:
print(count)
if H > 0:
if H % M == 0:
count += H//M
print(count)
else:
count = count + H//M + 1
print(count)
|
s071661190
|
p02612
|
u318127926
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 8,968 | 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)
|
s342063896
|
Accepted
| 26 | 9,124 | 42 |
n = int(input())
print((1000-n%1000)%1000)
|
s382015844
|
p02412
|
u494314211
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,456 | 180 |
Write a program which identifies the number of combinations of three integers which satisfy the following conditions: * You should select three distinct integers from 1 to n. * A total sum of the three integers is x. For example, there are two combinations for n = 5 and x = 9. * 1 + 3 + 5 = 9 * 2 + 3 + 4 = 9
|
while(True):
a,b=list(map(int,input().split()))
if a==0 and b==0:
break
c=0
for i in range(a):
for j in range(i):
for k in range(j):
if i+j+k==b:
c+=1
print(c)
|
s846442204
|
Accepted
| 540 | 7,600 | 188 |
while(True):
a,b=list(map(int,input().split()))
if a==0 and b==0:
break
c=0
for i in range(1,a+1):
for j in range(1,i):
for k in range(1,j):
if i+j+k==b:
c+=1
print(c)
|
s260076914
|
p03598
|
u371467115
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 138 |
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.
|
n=int(input())
k=int(input())
a=list(map(int,input().split()))
total=0
for i in range(n):
total+=min(abs(k-a[i]),abs(a[i]))
print(total)
|
s383538176
|
Accepted
| 19 | 3,060 | 140 |
n=int(input())
k=int(input())
a=list(map(int,input().split()))
total=0
for i in range(n):
total+=min(abs(k-a[i]),abs(a[i]))
print(total*2)
|
s750351501
|
p02422
|
u427088273
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,740 | 401 |
Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-th character of $str$ with p Note that the indices of $str$ start with 0.
|
string = [str(i) for i in input()]
for _ in range(int(input())):
n = input().split()
order = n.pop(0)
if order == 'replace':
string = string[:int(n[0])] + \
[i for i in n[2]] + string[int(n[1])+1:]
elif order == 'reverse':
string = string[:int(n[1])] + \
string[int(n[0]):int(n[1])+1][::-1] + \
string[int(n[1])+1:]
else :
out = string[ int(n[0]) : int(n[1])+1 ]
print(''.join(out))
|
s109749536
|
Accepted
| 20 | 7,752 | 402 |
string = [str(i) for i in input()]
for _ in range(int(input())):
n = input().split()
order = n.pop(0)
if order == 'replace':
string = string[:int(n[0])] + \
[i for i in n[2]] + string[int(n[1])+1:]
elif order == 'reverse':
string = string[:int(n[0])] + \
string[int(n[0]):int(n[1])+1][::-1] + \
string[int(n[1])+1:]
else :
out = string[ int(n[0]) : int(n[1])+1 ]
print(''.join(out))
|
s074676130
|
p02601
|
u667024514
| 2,000 | 1,048,576 |
Wrong Answer
| 28 | 9,160 | 136 |
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())
ans = 0
while a >= b:
b *= 2
ans += 1
while b >= c:
c *= 2
ans += 1
print(ans)
|
s563037294
|
Accepted
| 27 | 9,156 | 173 |
a,b,c = map(int,input().split())
k = int(input())
ans = 0
while a >= b:
b *= 2
ans += 1
while b >= c:
c *= 2
ans += 1
if ans > k:
print("No")
else:
print("Yes")
|
s619081402
|
p04029
|
u427984570
| 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?
|
a=int(input())
print(0.5*a*(a+1))
|
s462204361
|
Accepted
| 17 | 2,940 | 34 |
n = int(input())
print(n*(n+1)//2)
|
s291273004
|
p03160
|
u992767140
| 2,000 | 1,048,576 |
Wrong Answer
| 146 | 14,104 | 272 |
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.
|
import math
n = int(input())
h = list(map(int, input().split()))
res = [0]*n
for i in range(n):
if i == 1:
res[1] = abs(h[0] - h[1])
temp1 = abs(h[i] - h[i-2])
temp2 = abs(h[i] - h[i-1])
res[i] = min(res[i-2] + temp1, res[i-1] + temp2)
print(res[n-1])
|
s120711486
|
Accepted
| 138 | 14,104 | 294 |
import math
n = int(input())
h = list(map(int, input().split()))
res = [0]*n
for i in range(1, n):
if i == 1:
res[1] = abs(h[0] - h[1])
else:
temp1 = abs(h[i] - h[i-2])
temp2 = abs(h[i] - h[i-1])
res[i] = min(res[i-2] + temp1, res[i-1] + temp2)
print(res[n-1])
|
s958421439
|
p03469
|
u928784113
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 65 |
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.
|
# -*- coding: utf-8 -*-
S = str(input())
S.replace("2017","2018")
|
s461550171
|
Accepted
| 17 | 2,940 | 78 |
# -*- coding: utf-8 -*-
S = str(input())
T = S.replace("2017","2018")
print(T)
|
s471977321
|
p03110
|
u393693918
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 194 |
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative. For example, if x_1 = `10000` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins. If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?
|
n = int(input())
ans = 0
for _ in range(n):
a = list(map(str, input().split()))
if a[1] == "JPY":
ans += int(a[0])
else:
ans += float(a[0]) * 380000
print(int(ans))
|
s014225214
|
Accepted
| 17 | 2,940 | 199 |
n = int(input())
ans = 0
for _ in range(n):
a = list(map(str, input().split()))
if a[1] == "JPY":
ans += float(a[0])
else:
ans += float(a[0]) * 380000
print(float(ans))
|
s195753034
|
p02271
|
u574649773
| 5,000 | 131,072 |
Wrong Answer
| 20 | 5,644 | 746 |
Write a program which reads a sequence _A_ of _n_ elements and an integer _M_ , and outputs "yes" if you can make _M_ by adding elements in _A_ , otherwise "no". You can use an element only once. You are given the sequence _A_ and _q_ questions where each question contains _M i_.
|
# -*- coding=utf-8 -*-
import itertools
count = int(input())
_list = list(map(int, input().split(" ")))
count2 = int(input())
_answers = list(map(int, input().split(" ")))
desc = []
for answer in _answers:
tmp = [i for i in _list if answer >= i]
if answer > sum(tmp):
desc.append("no")
else:
for i in range(len(tmp)):
tmp2 = list(itertools.combinations(tmp, i))
for tmp3 in tmp2:
if sum(tmp3) == answer:
desc.append("yes")
break
print(desc)
|
s899805224
|
Accepted
| 13,980 | 58,496 | 951 |
# -*- coding=utf-8 -*-
import itertools
count = int(input())
_list = list(map(int, input().split(" ")))
count2 = int(input())
_answers = list(map(int, input().split(" ")))
desc = []
checked = False
for answer in _answers:
checked = False
tmp = [i for i in _list if answer >= i]
if answer > sum(tmp):
desc.append("no")
else:
for i in range(len(tmp) + 1):
if checked == True:
break
tmp2 = list(itertools.combinations(tmp, i))
for tmp3 in tmp2:
if sum(tmp3) == answer:
desc.append("yes")
checked = True
break
if checked != True:
desc.append("no")
for i in desc:
print(i)
|
s861170563
|
p03860
|
u095094246
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 29 |
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
|
print(input().split()[1][0])
|
s437741035
|
Accepted
| 17 | 2,940 | 40 |
s=input().split()[1]
print('A'+s[0]+'C')
|
s120007154
|
p02844
|
u373047809
| 2,000 | 1,048,576 |
Wrong Answer
| 673 | 3,060 | 110 |
AtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code. The company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code. How many different PIN codes can he set this way? Both the lucky number and the PIN code may begin with a 0.
|
_,j=open(0)
a=set(),set(),set(),{""}
for s in j:
for b,c in zip(a,a[1:]):b|={t+s for t in c}
print(len(a[0]))
|
s115655500
|
Accepted
| 24 | 3,060 | 134 |
_,s=open(0)
c=0
for i in range(1000):
p=0;F=1
for j in str(i).zfill(3):
q=s[p:].find(j)
if q<0:F=0;break
p+=q+1
c+=F
print(c)
|
s047812315
|
p00023
|
u618637847
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,612 | 306 |
You are given circle $A$ with radius $r_a$ and with central coordinate $(x_a, y_a)$ and circle $B$ with radius $r_b$ and with central coordinate $(x_b, y_b)$. Write a program which prints: * "2" if $B$ is in $A$, * "-2" if $A$ is in $B$, * "1" if circumference of $A$ and $B$ intersect, and * "0" if $A$ and $B$ do not overlap. You may assume that $A$ and $B$ are not identical.
|
import math
num = int(input())
for i in range(num):
ax,ay,ar,bx,by,br = map(float,input().split(' '))
d = (ax - bx)*(ax - bx) + (ay * by)
if d < (br - ar):
print(2)
if d < (ar - br):
print(-2)
elif d <= (ar + br):
print(1)
else:
print(0)
|
s853368534
|
Accepted
| 30 | 7,532 | 370 |
import math
num = int(input())
for i in range(num):
ax,ay,ar,bx,by,br=map(float,input().split())
d = ((ax-bx)* (ax - bx))+((ay-by)*(ay-by))
r1 = (ar+br)*(ar+br)
r2 = (ar-br)*(ar-br)
if d <= r1 and d >= r2:
print(1);
elif d<r2 and ar>=br:
print(2)
elif d < r2 and ar <= br:
print(-2)
else:
print(0)
|
s726007492
|
p02866
|
u376642400
| 2,000 | 1,048,576 |
Wrong Answer
| 2,108 | 34,664 | 466 |
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 numpy as np
import collections
import sys
N = int(input())
Ds = np.array(list(map(int, input().split(' '))))
if Ds[0] != 0:
print(0)
sys.exit()
if np.any(Ds[1:] == 0):
print(0)
sys.exit()
uniq = np.unique(Ds)
uniq.sort()
if not np.all(uniq == np.arange(uniq.min(), uniq.max() + 1)):
print(0)
sys.exit()
C = collections.Counter(Ds)
counts = 1
for i in range(1, uniq.max() + 1):
counts *= C[i-1] ** C[i]
print(counts // 998244353)
|
s656370002
|
Accepted
| 489 | 25,912 | 466 |
import numpy as np
import collections
import sys
N = int(input())
Ds = np.array(list(map(int, input().split(' '))))
if Ds[0] != 0:
print(0)
sys.exit()
if np.any(Ds[1:] == 0):
print(0)
sys.exit()
uniq = np.unique(Ds)
uniq.sort()
if not np.all(uniq == np.arange(uniq.min(), uniq.max() + 1)):
print(0)
sys.exit()
C = collections.Counter(Ds)
counts = 1
for i in range(1, uniq.max() + 1):
counts *= C[i-1] ** C[i]
print(counts % 998244353)
|
s820013098
|
p02612
|
u547613087
| 2,000 | 1,048,576 |
Wrong Answer
| 26 | 9,060 | 71 |
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.
|
number = 1000
input_number = int(input())
print(number - input_number)
|
s284526667
|
Accepted
| 25 | 9,084 | 115 |
input_number = int(input())
number = 1000
n = input_number % number
if n > 0:
print(number - n)
else:
print(n)
|
s764030400
|
p03943
|
u582243208
| 2,000 | 262,144 |
Wrong Answer
| 22 | 3,064 | 212 |
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())
sm=a+b+c
half=sm//2
if sm%2==0:
print("No")
else:
if a==half or b==half or c==half or a+b==half or b+c==half or c+a==half:
print("Yes")
else:
print("No")
|
s639668791
|
Accepted
| 23 | 3,064 | 163 |
a = sorted([int(i) for i in input().split()])
suma = sum(a) / 2
if sum(a) % 2 == 0 and suma == a[2] or suma == a[0] + a[1]:
print("Yes")
else:
print("No")
|
s852536614
|
p03711
|
u781025961
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 195 |
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.
|
x,y = map(int,input().split())
lst1 = [1,3,5,7,8,10,12]
lst2 = [4,6,9,11]
if (x in lst1) and (y in lst1):
print("YES")
elif (x in lst2) and (y in lst2):
print("YES")
else:
print("NO")
|
s687276894
|
Accepted
| 17 | 3,060 | 196 |
x,y = map(int,input().split())
lst1 = [1,3,5,7,8,10,12]
lst2 = [4,6,9,11]
if (x in lst1) and (y in lst1):
print("Yes")
elif (x in lst2) and (y in lst2):
print("Yes")
else:
print("No")
|
s532796384
|
p03672
|
u166636976
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 233 |
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input.
|
char = input()
char = char[0:-1]
print(char)
while(1):
#print(char[:(len(char)//2)]+" "+char[len(char)//2:])
if char[:(len(char)//2)] == char[len(char)//2:]:
break
else :
char = char[0:-1]
print(len(char))
|
s486725841
|
Accepted
| 17 | 2,940 | 163 |
char = input()
char = char[0:-1]
while(1):
if char[:(len(char)//2)] == char[len(char)//2:]:
break
else :
char = char[0:-1]
print(len(char))
|
s127944824
|
p03471
|
u005960309
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 3,064 | 314 |
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
|
import sys
N, Y = map(int, input().split())
if 10000 * N < Y:
print(-1, -1, -1)
for x in range(0, N+1):
for y in range(0, N-x+1):
for z in range(0, N-x-y+1):
if (10000*x)+(5000*y)+(1000*z) == Y:
print(x, y, x)
sys.exit()
print(-1, -1, -1)
|
s889166850
|
Accepted
| 758 | 3,060 | 236 |
N, Y = map(int, input().split())
for x in range(N, -1, -1):
for y in range(N-x, -1, -1):
z = N - x- y
if (10000*x)+(5000*y)+(1000*z) == Y:
print(x, y, z)
exit()
print(-1, -1, -1)
|
s518055408
|
p03573
|
u593227551
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 93 |
You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
|
l = input().split()
print(l)
l.sort()
if l[0] == l[1]:
print(l[2])
else:
print(l[0])
|
s824141105
|
Accepted
| 18 | 2,940 | 84 |
l = input().split()
l.sort()
if l[0] == l[1]:
print(l[2])
else:
print(l[0])
|
s606173055
|
p03854
|
u813569174
| 2,000 | 262,144 |
Time Limit Exceeded
| 2,104 | 3,188 | 327 |
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
|
S = input()
S = S[::-1]
t = ['maerd','remaerd','esare','resare']
i = 0
frag = 0
while i <= len(S)-1 and frag == 0:
k = 0
for j in range(4):
d = t[j]
if S[i:len(d)+i] == d:
break
i = i + len(d)
else:
k = k + 1
if k == 4:
frag = 1
print('NO')
if i == len(S):
print('YES')
|
s342109785
|
Accepted
| 47 | 3,188 | 315 |
S = input()
S = S[::-1]
t = ['maerd','remaerd','esare','resare']
i = 0
frag = 0
while i <= len(S)-1 and frag == 0:
k = 0
for j in range(4):
d = t[j]
if S[i:len(d)+i] == d:
i = i + len(d)
else:
k = k + 1
if k == 4:
frag = 1
print('NO')
if i == len(S):
print('YES')
|
s611441298
|
p03957
|
u500297289
| 1,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 65 |
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()
if 'CF' in S:
print("Yes")
else:
print("No")
|
s018906963
|
Accepted
| 17 | 2,940 | 119 |
S = input()
if 'C' in S[:-1]:
a = S.index('C')
if 'F' in S[a:]:
print("Yes")
exit()
print("No")
|
s841431770
|
p03418
|
u652081898
| 2,000 | 262,144 |
Wrong Answer
| 66 | 2,940 | 245 |
Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had.
|
n, k = map(int, input().split())
ans = 0
for b in range(1, n+1):
if b <= k:
continue
ans += (b-k)*(n//b)
if n%b >= k:
if k != 0:
ans += n%b - k + 1
else:
ans += n%b - k
print(ans)
|
s317159906
|
Accepted
| 90 | 3,060 | 241 |
n, k = map(int, input().split())
ans = 0
for b in range(1, n+1):
if b <= k:
continue
ans += (b-k)*(n//b)
if n%b >= k:
if k != 0:
ans += n%b - k + 1
else:
ans += n%b - k
print(ans)
|
s383083599
|
p03386
|
u589381719
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 175 |
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
|
A,B,K=map(int,input().split())
ans=[]
for i in range(A,min(A+K,B)):
ans.append(i)
for i in range(max(A+1,B-K+1),B+1):
ans.append(i)
ans=set(ans)
for i in ans: print(i)
|
s996770993
|
Accepted
| 18 | 3,064 | 205 |
A,B,K=map(int,input().split())
ans=[]
for i in range(A,min(A+K,B)):
ans.append(i)
for i in range(max(A+1,B-K+1),B+1):
ans.append(i)
if A==B:ans.append(A)
ans=sorted(set(ans))
for i in ans: print(i)
|
s093939566
|
p03591
|
u243492642
| 2,000 | 262,144 |
Wrong Answer
| 20 | 3,064 | 387 |
Ringo is giving a present to Snuke. Ringo has found out that Snuke loves _yakiniku_ (a Japanese term meaning grilled meat. _yaki_ : grilled, _niku_ : meat). He supposes that Snuke likes grilled things starting with `YAKI` in Japanese, and does not like other things. You are given a string S representing the Japanese name of Ringo's present to Snuke. Determine whether S starts with `YAKI`.
|
# coding: utf-8
def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def read():
S = str(input())
return (S,)
def solve(S):
if len(S) < 4:
return "No"
if "".join(S[0:3]) == "YAKI":
return "Yes"
else:
return "No"
def main():
params = read()
print(solve(*params))
if __name__ == "__main__":
main()
|
s432755032
|
Accepted
| 17 | 3,060 | 387 |
# coding: utf-8
def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def read():
S = str(input())
return (S,)
def solve(S):
if len(S) < 4:
return "No"
if "".join(S[0:4]) == "YAKI":
return "Yes"
else:
return "No"
def main():
params = read()
print(solve(*params))
if __name__ == "__main__":
main()
|
s909706581
|
p03469
|
u165268875
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 34 |
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.
|
S = input()
S[0:4]==2017
print(S)
|
s369549473
|
Accepted
| 18 | 2,940 | 33 |
S = input()
print("2018"+S[4:])
|
s854261343
|
p02678
|
u036104576
| 2,000 | 1,048,576 |
Wrong Answer
| 668 | 39,012 | 979 |
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
|
import sys
import itertools
# import numpy as np
import time
sys.setrecursionlimit(10 ** 7)
from collections import defaultdict
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n, m = map(int, readline().split())
adj = [[] for _ in range(n)]
for i in range(m):
a, b = map(int, readline().split())
adj[a - 1].append(b - 1)
adj[b - 1].append(a - 1)
import heapq
MAX = 10 ** 9 + 5
visited = [False for _ in range(n)]
dist = [MAX for _ in range(n)]
def dji(start):
dist[start] = 0
q = [(0, 0)]
while len(q) > 0:
v = heapq.heappop(q)
if visited[v[1]]:
continue
visited[v[1]] = True
for u in adj[v[1]]:
if dist[v[1]] + 1 < dist[u]:
dist[u] = dist[v[1]] + 1
heapq.heappush(q, (dist[u], u))
dji(0)
print(dist)
if all(visited):
print("Yes")
for i in dist[1:]:
print(i)
else:
print("No")
|
s324440450
|
Accepted
| 697 | 41,192 | 1,051 |
import sys
import itertools
# import numpy as np
import time
import math
sys.setrecursionlimit(10 ** 7)
from collections import defaultdict
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n, m = map(int, readline().split())
adj = [[] for _ in range(n)]
for i in range(m):
a, b = map(int, readline().split())
adj[a - 1].append(b - 1)
adj[b - 1].append(a - 1)
import heapq
MAX = 10 ** 9 + 5
visited = [False for _ in range(n)]
dist = [MAX for _ in range(n)]
path = [0 for _ in range(n)]
def dji(start):
dist[start] = 0
q = [(0, 0)]
while len(q) > 0:
v = heapq.heappop(q)
if visited[v[1]]:
continue
visited[v[1]] = True
for u in adj[v[1]]:
if dist[v[1]] + 1 < dist[u]:
dist[u] = dist[v[1]] + 1
path[u] = v[1] + 1
heapq.heappush(q, (dist[u], u))
dji(0)
if all(visited):
print("Yes")
for i in path[1:]:
print(i)
else:
print("No")
|
s610237766
|
p03998
|
u856169020
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 229 |
Alice, Bob and Charlie are playing _Card Game for Three_ , as below: * At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged. * The players take turns. Alice goes first. * If the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says `a`, Alice takes the next turn.) * If the current player's deck is empty, the game ends and the current player wins the game. You are given the initial decks of the players. More specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way. Determine the winner of the game.
|
sa = list(str(input()))
sb = list(str(input()))
sc = list(str(input()))
m = {'a': sa, 'b': sb, 'c': sc}
turn = 'a'
while True:
if len(m[turn]) == 0:
break
turn = m[turn][0]
tmp = m[turn][1:]
m[turn] = tmp
print(turn)
|
s865241576
|
Accepted
| 18 | 3,064 | 301 |
sa = list(str(input()))
sb = list(str(input()))
sc = list(str(input()))
m = {'a': sa, 'b': sb, 'c': sc}
ans = {'a': 'A', 'b': 'B', 'c': 'C'}
turn = 'a'
while True:
if len(m[turn]) == 0:
break
next_turn = m[turn][0]
next_l = m[turn][1:]
m[turn] = next_l
turn = next_turn
print(ans[turn])
|
s639935713
|
p03503
|
u010090035
| 2,000 | 262,144 |
Wrong Answer
| 94 | 3,064 | 421 |
Joisino is planning to open a shop in a shopping street. Each of the five weekdays is divided into two periods, the morning and the evening. For each of those ten periods, a shop must be either open during the whole period, or closed during the whole period. Naturally, a shop must be open during at least one of those periods. There are already N stores in the street, numbered 1 through N. You are given information of the business hours of those shops, F_{i,j,k}. If F_{i,j,k}=1, Shop i is open during Period k on Day j (this notation is explained below); if F_{i,j,k}=0, Shop i is closed during that period. Here, the days of the week are denoted as follows. Monday: Day 1, Tuesday: Day 2, Wednesday: Day 3, Thursday: Day 4, Friday: Day 5. Also, the morning is denoted as Period 1, and the afternoon is denoted as Period 2. Let c_i be the number of periods during which both Shop i and Joisino's shop are open. Then, the profit of Joisino's shop will be P_{1,c_1}+P_{2,c_2}+...+P_{N,c_N}. Find the maximum possible profit of Joisino's shop when she decides whether her shop is open during each period, making sure that it is open during at least one period.
|
n=int(input())
f=[0 for i in range(n)]
for i in range(n):
fi=int("".join(list(input().split())),2)
f[i] = fi
print(f)
p=[[] for i in range(n)]
for i in range(n):
pi=list(map(int,input().split()))
p[i] = pi
print(p)
ans=-9999999999999
for i in range(1,1024):
bene=0
for j in range(n):
c = str(bin(i & f[j])).count("1")
bene+=p[j][c]
if(ans < bene):
ans = bene
print(ans)
|
s547879393
|
Accepted
| 92 | 3,064 | 403 |
n=int(input())
f=[0 for i in range(n)]
for i in range(n):
fi=int("".join(list(input().split())),2)
f[i] = fi
p=[[] for i in range(n)]
for i in range(n):
pi=list(map(int,input().split()))
p[i] = pi
ans=-9999999999999
for i in range(1,1024):
bene=0
for j in range(n):
c = str(bin(i & f[j])).count("1")
bene+=p[j][c]
if(ans < bene):
ans = bene
print(ans)
|
s419244312
|
p02393
|
u715990255
| 1,000 | 131,072 |
Wrong Answer
| 30 | 6,724 | 63 |
Write a program which reads three integers, and prints them in ascending order.
|
l = input().split(' ')
l = [int(i) for i in l]
print(sorted(l))
|
s577100706
|
Accepted
| 30 | 6,724 | 103 |
l = input().split(' ')
l = [int(i) for i in l]
l = sorted(l)
print('{} {} {}'.format(l[0], l[1], l[2]))
|
s918034093
|
p02927
|
u718401738
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 272 |
Today is August 24, one of the five Product Days in a year. A date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and d_1 is the ones digit of the day): * d_1 \geq 2 * d_{10} \geq 2 * d_1 \times d_{10} = m Takahashi wants more Product Days, and he made a new calendar called Takahashi Calendar where a year consists of M month from Month 1 to Month M, and each month consists of D days from Day 1 to Day D. In Takahashi Calendar, how many Product Days does a year have?
|
m,d=map(int,input().split())
a=0
if d>=22:
for i in range(d-21):
day=d-i
d1=int(str(day)[1])
d10=int(str(day)[0])
if int(str(day)[1])!=1:
if d1*d10<=m and d1!=0:
print(d10,d1)
a+=1
print(a)
|
s384033749
|
Accepted
| 17 | 3,060 | 273 |
m,d=map(int,input().split())
a=0
if d>=22:
for i in range(d-21):
day=d-i
d1=int(str(day)[1])
d10=int(str(day)[0])
if int(str(day)[1])!=1:
if d1*d10<=m and d1!=0:
#print(d10,d1)
a+=1
print(a)
|
s954127411
|
p03730
|
u841531687
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 100 |
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())
if a % b == 0 and c != 0:
print('No')
else:
print('Yes')
|
s597307467
|
Accepted
| 17 | 2,940 | 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")
|
s376109135
|
p03494
|
u537722973
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 219 |
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()))
for i in a:
if i%2 == 1:
print(0)
exit()
r = 0
while True:
for i in range(n):
r += 1
a[i] //= 2
if a[i]%2 == 1:
print(r)
exit()
|
s086816456
|
Accepted
| 18 | 2,940 | 164 |
n = int(input())
a = list(map(int,input().split()))
r = 0
while True:
for i in range(n):
if a[i]%2 == 1:
print(r)
exit()
a[i] //= 2
r += 1
|
s148826907
|
p03636
|
u113255362
| 2,000 | 262,144 |
Wrong Answer
| 24 | 8,924 | 54 |
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 = input()
n = str(len(S)-2)
res = S[0]+n+S[len(S)-1]
|
s021753284
|
Accepted
| 30 | 8,928 | 65 |
S = input()
n = str(len(S)-2)
res = S[0]+n+S[len(S)-1]
print(res)
|
s259189232
|
p00423
|
u078042885
| 1,000 | 131,072 |
Wrong Answer
| 100 | 7,552 | 230 |
A と B の 2 人のプレーヤーが, 0 から 9 までの数字が書かれたカードを使ってゲームを行う.最初に, 2 人は与えられた n 枚ずつのカードを,裏向きにして横一列に並べる.その後, 2 人は各自の左から 1 枚ずつカードを表向きにしていき,書かれた数字が大きい方のカードの持ち主が,その 2 枚のカードを取る.このとき,その 2 枚のカードに書かれた数字の合計が,カードを取ったプレーヤーの得点となるものとする.ただし,開いた 2 枚のカードに同じ数字が書かれているときには,引き分けとし,各プレーヤーが自分のカードを 1 枚ずつ取るものとする. 例えば, A,B の持ち札が,以下の入力例 1 から 3 のように並べられている場合を考えよう.ただし,入力ファイルは n + 1 行からなり, 1 行目には各プレーヤのカード枚数 n が書かれており, i + 1 行目(i = 1,2,... ,n)には A の左から i 枚目のカードの数字と B の左から i 枚目の カードの数字が,空白を区切り文字としてこの順で書かれている.すなわち,入力ファイルの 2 行目以降は,左側の列が A のカードの並びを,右側の列が B のカードの並びを,それぞれ表している.このとき,ゲーム終了後の A と B の得点は,それぞれ,対応する出力例に示したものとなる. 入力ファイルに対応するゲームが終了したときの A の得点と B の得点を,この順に空白を区切り文字として 1 行に出力するプログラムを作成しなさい.ただし, n ≤ 10000 とする. 入力例1 | 入力例2 | 入力例3 ---|---|--- 3| 3| 3 9 1| 9 1| 9 1 5 4| 5 4| 5 5 0 8| 1 0| 1 8 出力例1 | 出力例2 | 出力例3 19 8| 20 0| 15 14
|
while 1:
n=int(input())
if n==0: break
a=b=0
while n:
c,d=map(int,input().split())
if c<b:b+=c+d
elif c>d:a+=c+d
else:
a+=c
b+=c
n-=1
print(a,b)
|
s135795949
|
Accepted
| 110 | 7,596 | 230 |
while 1:
n=int(input())
if n==0: break
a=b=0
while n:
c,d=map(int,input().split())
if c<d:b+=c+d
elif c>d:a+=c+d
else:
a+=c
b+=c
n-=1
print(a,b)
|
s048248646
|
p02603
|
u943057856
| 2,000 | 1,048,576 |
Wrong Answer
| 31 | 9,208 | 1,038 |
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 sys
n=int(input())
a=list(map(int,input().split()))
money=1000
kabu=0
flg=0
first=True
if a[1]-a[0]>=0:
flg="+"
else:
flg="-"
x=a[1]
if len(a)==2:
if a[1]>a[0]:
kabu+=money//a[0]
money-=a[0]*(money//a[0])
money+=kabu*a[1]
print(money)
sys.exit()
for i , y in enumerate(a[2:],2):
if flg=="+" and y-x>=0:
x=y
elif flg=="-" and y-x<=0:
x=y
elif flg=="+" and y-x<0:
if first:
kabu+=money//a[0]
money-=a[0]*(money//a[0])
first=False
flg="-"
money+=kabu*a[i-1]
kabu=0
elif flg=="-" and y-x>0:
if first:
first=False
flg="+"
kabu+=money//a[i-1]
money-=a[i-1]*(money//a[i-1])
print(flg,money,kabu)
if kabu!=0:
if flg=="+":
money+=kabu*a[-1]
elif flg=="-":
X=a[-1]
for Y in a.reverse()[1:]:
if X<=Y:
X=Y
else:
money+=kabu*Y
break
print(money)
|
s104430898
|
Accepted
| 32 | 9,332 | 1,182 |
import sys
n=int(input())
a=list(map(int,input().split()))
money=1000
kabu=0
flg=0
first=True
if a[1]-a[0]>=0:
flg="+"
else:
flg="-"
x=a[1]
if len(a)==2:
if a[1]>a[0]:
kabu+=money//a[0]
money-=a[0]*(money//a[0])
money+=kabu*a[1]
print(money)
sys.exit()
for i , y in enumerate(a[2:],2):
if flg=="+" and y-x>=0:
x=y
elif flg=="-" and y-x<=0:
x=y
elif flg=="+" and y-x<0:
x=y
if first:
kabu+=money//a[0]
money-=a[0]*(money//a[0])
first=False
flg="-"
money+=kabu*a[i-1]
kabu=0
elif flg=="-" and y-x>0:
x=y
if first:
first=False
flg="+"
kabu+=money//a[i-1]
money-=a[i-1]*(money//a[i-1])
if kabu!=0:
if flg=="+":
money+=kabu*a[-1]
elif flg=="-":
X=a[-1]
for Y in a.reverse()[1:]:
if X<=Y:
X=Y
else:
money+=kabu*Y
break
if first:
if a[-1]>a[0]:
kabu+=money//a[0]
money-=a[0]*(money//a[0])
money+=kabu*a[-1]
print(money)
|
s864488715
|
p03131
|
u118211443
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 144 |
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the maximum possible number of biscuits in Snuke's pocket after K operations.
|
k,a,b=map(int,input().split())
k+=1
mouke=b-a
j=0
if mouke>1:
j=(k-a)//2
print(j)
cnt=j*(b-a)+a+(k-2*j-a)
else:
cnt=k
print(cnt)
|
s375567883
|
Accepted
| 20 | 2,940 | 132 |
k,a,b=map(int,input().split())
mouke=b-a
j=0
if mouke>1:
j=(k+1-a)//2
cnt=j*(b-a)+a+(k-2*j-a)+1
else:
cnt=k+1
print(cnt)
|
s837313409
|
p03795
|
u790048565
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 104 |
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
|
import math
N = int(input())
power = math.factorial(N)
result = power % (pow(10, 9) + 7)
print(result)
|
s678014806
|
Accepted
| 17 | 2,940 | 75 |
N = int(input())
th = N // 15
result = N * 800 - th * 200
print(result)
|
s543220014
|
p02406
|
u123669391
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,592 | 147 |
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto. Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements. void call(int n){ int i = 1; CHECK_NUM: int x = i; if ( x % 3 == 0 ){ cout << " " << i; goto END_CHECK_NUM; } INCLUDE3: if ( x % 10 == 3 ){ cout << " " << i; goto END_CHECK_NUM; } x /= 10; if ( x ) goto INCLUDE3; END_CHECK_NUM: if ( ++i <= n ) goto CHECK_NUM; cout << endl; }
|
n = int(input())
for i in range(n+1):
if i > n:
break
if i % 3 == 0:
print(" ", i, end="")
else:
if i % 10 ==3:
print(" ", i, end="")
|
s373833540
|
Accepted
| 20 | 5,872 | 223 |
n = int(input())
for i in range(1 , n+1):
if "3" in str(i):
print(" {}".format(i), end="")
else:
if i % 3 == 0:
print(" {}".format(i), end="")
else:
if i % 10 == 3:
print(" {}".format(i), end="")
print()
|
s752703290
|
p02408
|
u017523606
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,600 | 200 |
Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers). The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.
|
number = int(input())
dict = {}
for x in ["S","H","C","D"]:
dict[x] = [i for i in range(1,14)]
for i in range(number):
x,y = map(str,input().split())
dict[x].remove(int(y))
print(dict)
|
s348570072
|
Accepted
| 20 | 5,604 | 257 |
number = int(input())
dict = {}
for x in ["S","H","C","D"]:
dict[x] = [i for i in range(1,14)]
for i in range(number):
x,y = map(str,input().split())
dict[x].remove(int(y))
for x in ["S","H","C","D"]:
for i in dict[x]:
print(x,i)
|
s879329079
|
p00016
|
u724548524
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,712 | 242 |
When a boy was cleaning up after his grand father passing, he found an old paper: In addition, other side of the paper says that "go ahead a number of steps equivalent to the first integer, and turn clockwise by degrees equivalent to the second integer". His grand mother says that Sanbonmatsu was standing at the center of town. However, now buildings are crammed side by side and people can not walk along exactly what the paper says in. Your task is to write a program which hunts for the treature on the paper. For simplicity, 1 step is equivalent to 1 meter. Input consists of several pairs of two integers d (the first integer) and t (the second integer) separated by a comma. Input ends with "0, 0". Your program should print the coordinate (x, y) of the end point. There is the treature where x meters to the east and y meters to the north from the center of town. You can assume that d ≤ 100 and -180 ≤ t ≤ 180\.
|
import math
x = y = 0
h = math.radians(90)
while True:
d, t = map(int, input().split(","))
if d == t == 0:
break
x += d * math.cos(h)
y += d * math.sin(h)
h -= math.radians(t)
print("{} {}".format(int(x), int(y)))
|
s156137625
|
Accepted
| 20 | 5,712 | 232 |
import math
x = y = 0
h = math.radians(90)
while True:
d, t = map(int, input().split(","))
if d == t == 0:
break
x += d * math.cos(h)
y += d * math.sin(h)
h -= math.radians(t)
print(int(x))
print(int(y))
|
s942499808
|
p03998
|
u853185302
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 91 |
Alice, Bob and Charlie are playing _Card Game for Three_ , as below: * At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged. * The players take turns. Alice goes first. * If the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says `a`, Alice takes the next turn.) * If the current player's deck is empty, the game ends and the current player wins the game. You are given the initial decks of the players. More specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way. Determine the winner of the game.
|
S={c:list(input()) for c in "abc"}
print(S)
s="a"
while S[s]:s=S[s].pop(0)
print(s.upper())
|
s339998022
|
Accepted
| 17 | 2,940 | 82 |
S={c:list(input()) for c in "abc"}
s="a"
while S[s]:s=S[s].pop(0)
print(s.upper())
|
s175801635
|
p03721
|
u368796742
| 2,000 | 262,144 |
Wrong Answer
| 478 | 27,872 | 181 |
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())
l = [list(map(int,input().split())) for i in range(n)]
l.sort()
count = 0
for i,j in l:
if j < count:
count += j
else:
print(i)
exit()
|
s061080929
|
Accepted
| 513 | 27,872 | 174 |
n,k = map(int,input().split())
l = [list(map(int,input().split())) for i in range(n)]
l.sort()
count = 0
for i,j in l:
if j < k:
k -= j
else:
print(i)
exit()
|
s408935239
|
p03407
|
u111202730
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 91 |
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
|
a, b, c = map(int, input().split())
if (a + b) <= c:
print("Yes")
else:
print("No")
|
s156049364
|
Accepted
| 17 | 2,940 | 93 |
a, b, c = map(int, input().split())
if (a + b) >= c:
print("Yes")
else:
print("No")
|
s632162685
|
p03556
|
u859897687
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,188 | 83 |
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
|
n=int(input())
for i in range(int(n**.5)+1):
if n>i**2:
print(i**2)
break
|
s185398454
|
Accepted
| 18 | 3,064 | 89 |
n=int(input())
for i in range(int(n**.5)+1,0,-1):
if n>=i**2:
print(i**2)
break
|
s941395524
|
p03487
|
u681444474
| 2,000 | 262,144 |
Wrong Answer
| 130 | 25,512 | 203 |
You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a **good sequence**. Here, an sequence b is a **good sequence** when the following condition holds true: * For each element x in b, the value x occurs exactly x times in b. For example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not. Find the minimum number of elements that needs to be removed so that a will be a good sequence.
|
# coding: utf-8
import collections
N = int(input())
A= list(map(int,input().split()))
A.sort()
c = collections.Counter(A)
A_ = list(set(A))
ans = 0
for a in A_:
ans += min(a-c[a],c[a])
print(ans)
|
s698875940
|
Accepted
| 114 | 25,464 | 267 |
# coding: utf-8
import collections
N = int(input())
A= list(map(int,input().split()))
A.sort()
c = collections.Counter(A)
A_ = list(set(A))
ans = 0
for a in A_:
#print(c[a],a)
if a > c[a]:
ans += c[a]
else:
ans += c[a]-a
print(ans)
|
s807889141
|
p02865
|
u663438907
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 91 |
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
|
N = int(input())
ans = 0
if N % 2 == 0:
print((N/2)-1)
else:
print(int(((N-1)/2)))
|
s158461612
|
Accepted
| 17 | 2,940 | 96 |
N = int(input())
ans = 0
if N % 2 == 0:
print(int((N/2)-1))
else:
print(int(((N-1)/2)))
|
s626004254
|
p03854
|
u030749892
| 2,000 | 262,144 |
Wrong Answer
| 67 | 3,188 | 267 |
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
|
x = input()
x = x[::-1]
while True:
if x[:5] == "maerd":
x = x[5:]
elif x[:7] == "remaerd":
x = x[7:]
elif x[:5] == "esare":
x = x[5:]
elif x[:6] == "resare":
x = x[6:]
else:
break
if len(x) == 0:
print("Yes")
else:
print("No")
|
s254969801
|
Accepted
| 67 | 3,188 | 267 |
x = input()
x = x[::-1]
while True:
if x[:5] == "maerd":
x = x[5:]
elif x[:7] == "remaerd":
x = x[7:]
elif x[:5] == "esare":
x = x[5:]
elif x[:6] == "resare":
x = x[6:]
else:
break
if len(x) == 0:
print("YES")
else:
print("NO")
|
s112654166
|
p03997
|
u550895180
| 2,000 | 262,144 |
Wrong Answer
| 17 | 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)
|
s599959938
|
Accepted
| 17 | 2,940 | 72 |
a = int(input())
b = int(input())
h = int(input())
print(int((a+b)*h/2))
|
s014604166
|
p03862
|
u282657760
| 2,000 | 262,144 |
Wrong Answer
| 133 | 14,252 | 346 |
There are N boxes arranged in a row. Initially, the i-th box from the left contains a_i candies. Snuke can perform the following operation any number of times: * Choose a box containing at least one candy, and eat one of the candies in the chosen box. His objective is as follows: * Any two neighboring boxes contain at most x candies in total. Find the minimum number of operations required to achieve the objective.
|
N, x = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
for i in range(N):
if i == 0 and A[i] <= x:
continue
elif i == 0 and A[i] > x:
ans += (A[i]-x)
A[i] = x
continue
else:
if A[i] + A[i-1] <= x:
print(i)
continue
else:
ans += (A[i]+A[i-1]-x)
A[i] = x-A[i-1]
print(ans)
|
s614300267
|
Accepted
| 112 | 14,132 | 331 |
N, x = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
for i in range(N):
if i == 0 and A[i] <= x:
continue
elif i == 0 and A[i] > x:
ans += (A[i]-x)
A[i] = x
continue
else:
if A[i] + A[i-1] <= x:
continue
else:
ans += (A[i]+A[i-1]-x)
A[i] = x-A[i-1]
print(ans)
|
s182786517
|
p03720
|
u062189367
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 261 |
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())
a = []
b = []
for i in range(M):
a1 , b1 = [int(i) for i in input().split()]
a.append(a1)
b.append(b1)
nm = a+b
ans = [0 for i in range(N)]
for j in range(0,(len(nm))):
i = nm[j]
ans[i-1] += 1
print(ans)
|
s161816621
|
Accepted
| 18 | 3,064 | 295 |
N, M = map(int, input().split())
a = []
b = []
for i in range(M):
a1 , b1 = [int(i) for i in input().split()]
a.append(a1)
b.append(b1)
nm = a+b
ans = [0 for i in range(N)]
for j in range(0,(len(nm))):
i = nm[j]
ans[i-1] += 1
for i in range(0,len(ans)):
print(ans[i])
|
s912351815
|
p03860
|
u589726284
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 36 |
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[0] + 'C')
|
s338801151
|
Accepted
| 17 | 2,940 | 96 |
s = input().split(' ')
result = ''
for i in range(len(s)):
result += s[i][0]
print(result)
|
s447957873
|
p03401
|
u450904670
| 2,000 | 262,144 |
Wrong Answer
| 332 | 22,988 | 443 |
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.
|
import math
import numpy as np
N = int(input())
A = list(map(int, input().split()))
A_abs = [abs(A[0]-0)]
A_abs.extend([abs(A[i] - A[i-1]) for i in range(1, N)])
A_abs.append(abs(0 - A[-1]))
print(A_abs)
hoge = sum(A_abs)
for i in range(N):
if(i == 0):
print(hoge)
elif(i==N-1):
print(hoge - abs(A_abs[i] + A_abs[i+1]) + (A_abs[i] - A_abs[i+1]))
else:
print(hoge - abs(A_abs[i] + A_abs[i+1]) + abs(A_abs[i] - A_abs[i+1]))
|
s348810679
|
Accepted
| 222 | 14,048 | 256 |
import math
N = int(input())
A = [0]
A.extend(list(map(int, input().split())))
A.append(0)
hoge = sum([abs(A[i] - A[i-1]) for i in range(1, N+2)])
for i in range(1, N+1):
print(hoge + abs(A[i-1] - A[i+1]) - (abs(A[i-1] - A[i]) + abs(A[i] - A[i+1])))
|
s295478412
|
p01981
|
u805464373
| 8,000 | 262,144 |
Wrong Answer
| 20 | 5,596 | 486 |
平成31年4月30日をもって現行の元号である平成が終了し,その翌日より新しい元号が始まることになった.平成最後の日の翌日は新元号元年5月1日になる. ACM-ICPC OB/OGの会 (Japanese Alumni Group; JAG) が開発するシステムでは,日付が和暦(元号とそれに続く年数によって年を表現する日本の暦)を用いて "平成 _y_ 年 _m_ 月 _d_ 日" という形式でデータベースに保存されている.この保存形式は変更することができないため,JAGは元号が変更されないと仮定して和暦で表した日付をデータベースに保存し,出力の際に日付を正しい元号を用いた形式に変換することにした. あなたの仕事はJAGのデータベースに保存されている日付を,平成または新元号を用いた日付に変換するプログラムを書くことである.新元号はまだ発表されていないため,"?" を用いて表すことにする.
|
ls_g=[]
ls_y=[]
ls_m=[]
ls_d=[]
cnt = 0
while True:
try:
g=input()
y,m,d=map(int,input().split())
ls_g.append(g)
ls_y.append(y)
ls_m.append(m)
ls_d.append(d)
cnt += 1
except:
break;
for _ in range(cnt):
if ls_y[cnt]>31:
ls_g[cnt]="?"
elif ls_y[cnt]==31:
if ls_m[cnt]>=5:
ls_g[cnt]="?"
for _ in range(cnt):
print(ls_[g]+" "+ls_y[cnt]+" "+ls_m[cnt]+" "+ls_d[cnt])
|
s589844318
|
Accepted
| 20 | 5,616 | 518 |
ls_g=[]
ls_y=[]
ls_m=[]
ls_d=[]
cnt = -1
while True:
try:
ls=input().split()
ls_g.append(ls[0])
ls_y.append(int(ls[1]))
ls_m.append(int(ls[2]))
ls_d.append(int(ls[3]))
cnt += 1
except:
break;
for _ in range(cnt+1):
if ls_y[_]>31:
ls_g[_]="?"
ls_y[_]-=30
elif ls_y[_]==31 and ls_m[_]>=5:
ls_g[_]="?"
ls_y[_]-=30
for i in range(cnt+1):
print(ls_g[i]+" "+str(ls_y[i])+" "+str(ls_m[i])+" "+str(ls_d[i]))
|
s845947357
|
p02262
|
u928329738
| 6,000 | 131,072 |
Wrong Answer
| 4,870 | 16,616 | 631 |
Shell Sort is a generalization of [Insertion Sort](http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A) to arrange a list of $n$ elements $A$. 1 insertionSort(A, n, g) 2 for i = g to n-1 3 v = A[i] 4 j = i - g 5 while j >= 0 && A[j] > v 6 A[j+g] = A[j] 7 j = j - g 8 cnt++ 9 A[j+g] = v 10 11 shellSort(A, n) 12 cnt = 0 13 m = ? 14 G[] = {?, ?,..., ?} 15 for i = 0 to m-1 16 insertionSort(A, n, G[i]) A function shellSort(A, n) performs a function insertionSort(A, n, g), which considers every $g$-th elements. Beginning with large values of $g$, it repeats the insertion sort with smaller $g$. Your task is to complete the above program by filling ?. Write a program which reads an integer $n$ and a sequence $A$, and prints $m$, $G_i (i = 0, 1, ..., m − 1)$ in the pseudo code and the sequence $A$ in ascending order. The output of your program must meet the following requirements: * $1 \leq m \leq 100$ * $0 \leq G_i \leq n$ * cnt does not exceed $\lceil n^{1.5}\rceil$
|
g_m=0
g_G=[]
g_cnt=0
A=[]
n = int(input())
for i in range(n):
A.append(int(input()))
def insertionSort(A,n,g):
global g_cnt
for i in range(g,n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j-g
g_cnt += 1
A[j+g]=v
def shellSort(A,n):
cnt = 0
m = int(n**0.5)
g_m=m
G=[]
for i in range(m,0,-1):
G.append(i**2)
g_G=G
for i in range(0,m):
insertionSort(A,n,G[i])
return A,m,G
A,g_m,g_G=shellSort(A,n)
print(g_m)
print(" ".join(map(str,g_G)))
print(g_cnt)
print(" ".join(map(str,A)))
|
s531730370
|
Accepted
| 20,000 | 53,288 | 662 |
g_m=0
g_G=[]
g_cnt=0
A=[]
n = int(input())
for i in range(n):
A.append(int(input()))
def insertionSort(A,n,g):
global g_cnt
for i in range(g,n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j-g
g_cnt += 1
A[j+g]=v
def shellSort(A,n):
m=1
G=[]
j=1
for i in range(0,100):
G.append(j)
j=3*j+1
while G[m]<=n:
m+=1
G=G[:m]
G.reverse()
for i in range(0,m):
insertionSort(A,n,G[i])
return A,m,G
A,g_m,g_G=shellSort(A,n)
print(g_m)
print(" ".join(map(str,g_G)))
print(g_cnt)
print(*A,sep="\n")
|
s602763554
|
p03944
|
u806403461
| 2,000 | 262,144 |
Wrong Answer
| 23 | 9,208 | 286 |
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())
X = Y = 0
for i in range(0, n):
x, y, a = map(int, input().split())
if a == 1:
X = max(X, x)
if a == 2:
W = min(w, x)
if a == 3:
Y = max(Y, y)
else:
h = min(h, y)
print(max(w-X, 0)*max(h-Y, 0))
|
s351457853
|
Accepted
| 23 | 9,140 | 290 |
W, H, N = map(int, input().split())
X = Y = 0
for i in range(0, N):
x, y, a = map(int, input().split())
if a == 1:
X = max(X, x)
elif a == 2:
W = min(W, x)
elif a == 3:
Y = max(Y, y)
else:
H = min(H, y)
print(max(W-X, 0)*max(H-Y, 0))
|
s461759390
|
p03796
|
u556589653
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 3,456 | 67 |
Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
|
N = int(input())
for i in range(1,N+1):
N *= i
print(N%(10**9+7))
|
s639561215
|
Accepted
| 231 | 3,976 | 71 |
import math
N = int(input())
mod = 10**9+7
print(math.factorial(N)%mod)
|
s971193210
|
p03795
|
u666964944
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 40 |
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
|
n = int(input())
print(n*800-(n%15)*200)
|
s289420835
|
Accepted
| 17 | 2,940 | 45 |
n = int(input())
print((n*800)-((n//15)*200))
|
s818582837
|
p02255
|
u183079216
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,600 | 176 |
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
|
N=int(input())
A=[int(x) for x in input().split()]
for i in range(N):
v=A[i]
j=i-1
while j>=0 and v<A[j]:
A[j+1]=A[j]
j-=1
A[j+1]=v
print(A)
|
s891015299
|
Accepted
| 20 | 5,604 | 195 |
N=int(input())
A=[int(x) for x in input().split()]
for i in range(N):
v=A[i]
j=i-1
while j>=0 and v<A[j]:
A[j+1]=A[j]
j-=1
A[j+1]=v
print(' '.join(map(str,A)))
|
s880283879
|
p03110
|
u672794510
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 212 |
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?
|
RATE = 380000.0;
N = int(input());
sum = 0;
for i in range(N):
s = input().split(" ");
if s[1] == "BTC":
sum = sum + float(s[0])*RATE;
else:
sum = sum + float(s[0]);
print(int(sum))
|
s686567599
|
Accepted
| 17 | 2,940 | 206 |
RATE = 380000.0;
N = int(input());
sum = 0;
for i in range(N):
s = input().split(" ");
if s[1] == "BTC":
sum = sum + float(s[0])*RATE;
else:
sum = sum + float(s[0]);
print(sum)
|
s837793956
|
p03160
|
u666198201
| 2,000 | 1,048,576 |
Wrong Answer
| 132 | 14,692 | 205 |
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())
A = list(map(int, input().split()))
dp=[100000]*N
dp[0]=0
dp[1]=abs(A[1]-A[0])
for i in range(2,N):
dp[i]=min(dp[i-1]+abs(A[i-1]-A[i]),dp[i-2]+abs(A[i-2]-A[i]))
print(dp)
print(dp[N-1])
|
s737934652
|
Accepted
| 133 | 13,976 | 206 |
N=int(input())
A = list(map(int, input().split()))
dp=[100000]*N
dp[0]=0
dp[1]=abs(A[1]-A[0])
for i in range(2,N):
dp[i]=min(dp[i-1]+abs(A[i-1]-A[i]),dp[i-2]+abs(A[i-2]-A[i]))
#print(dp)
print(dp[N-1])
|
s346473792
|
p04043
|
u392480256
| 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.
|
inp = input().split()
print(inp)
if inp.count('7') == 2 and inp.count('5') == 1:
print("YES")
else:
print("NO")
|
s828269939
|
Accepted
| 17 | 2,940 | 105 |
inp = input().split()
if inp.count('7') == 1 and inp.count('5') == 2:
print("YES")
else:
print("NO")
|
s813452209
|
p03448
|
u649591440
| 2,000 | 262,144 |
Wrong Answer
| 46 | 3,188 | 1,063 |
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()) #500
atani=500
b=int(input())
btani=100
c=int(input())
ctani=50
x=int(input())
asum=0
bsum=0
csum=0
cnt=0
for aa in range(0, a):
#print(asum)
if asum > x:
break
elif asum == x:
cnt += 1
bsum=0
for bb in range(0, b):
#print('bsum:{}'.format(asum + bsum))
if asum + bsum > x:
break
elif asum + bsum == x:
cnt += 1
csum=0
for cc in range(0, c):
if asum + bsum + csum > x:
break
elif asum + bsum + csum == x:
cnt += 1
csum += ctani
bsum += btani
asum += atani
bsum=0
for bb in range(0, b):
#print('bsum:{}'.format(asum + bsum))
if bsum > x:
break
elif bsum == x:
cnt += 1
csum=0
for cc in range(0, c):
if bsum + csum > x:
break
elif bsum + csum == x:
cnt += 1
csum += ctani
bsum += btani
csum=0
for cc in range(0, c):
if csum > x:
break
elif csum == x:
cnt += 1
csum += ctani
print(cnt)
|
s375721608
|
Accepted
| 46 | 3,064 | 828 |
a=int(input()) #500
atani=500
b=int(input())
btani=100
c=int(input())
ctani=50
x=int(input())
asum=0
bsum=0
csum=0
cnt=0
for aa in range(0, a+1):
if asum > x:
break
elif asum == x:
cnt += 1
break
bsum=0
for bb in range(0, b+1):
if asum + bsum > x:
break
elif asum + bsum == x:
cnt += 1
break
csum=0
for cc in range(0, c+1):
if asum + bsum + csum > x:
break
elif asum + bsum + csum == x:
cnt += 1
csum += ctani
bsum += btani
asum += atani
print(cnt)
|
s735503768
|
p03478
|
u970809473
| 2,000 | 262,144 |
Wrong Answer
| 47 | 3,060 | 175 |
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())
res = 0
for i in range(1,n+1):
tmp = 0
for j in range(len(str(i))):
tmp += int(str(i)[j])
if a <= tmp <= b:
res += 1
print(res)
|
s172754668
|
Accepted
| 48 | 2,940 | 176 |
n,a,b = map(int, input().split())
res = 0
for i in range(1,n+1):
tmp = 0
for j in range(len(str(i))):
tmp += int(str(i)[j])
if a <= tmp <= b:
res += i
print(res)
|
s862388745
|
p03359
|
u838651937
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 96 |
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi. How many days from 2018-1-1 through 2018-a-b are Takahashi?
|
i = list(map(int, input().split()))
a = i[0]
b = i[1]
if b > a:
print(a)
else:
print(a - 1)
|
s243866784
|
Accepted
| 17 | 2,940 | 97 |
i = list(map(int, input().split()))
a = i[0]
b = i[1]
if b >= a:
print(a)
else:
print(a - 1)
|
s364801659
|
p03545
|
u798731634
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,188 | 335 |
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.
|
a = list(input())
for i in range(8):
b = []
for j in range(4):
b.append(a[j])
if j == 3:
pass
else:
if((i>>j)&1):
b.append('+')
else:
b.append('-')
c = ''.join(b)
if eval == 7:
break
else:
pass
print(c+'=4')
|
s187443081
|
Accepted
| 18 | 3,060 | 338 |
a = list(input())
for i in range(8):
b = []
for j in range(4):
b.append(a[j])
if j == 3:
pass
else:
if((i>>j)&1):
b.append('+')
else:
b.append('-')
c = ''.join(b)
if eval(c) == 7:
break
else:
pass
print(c+'=7')
|
s980742224
|
p03457
|
u717763253
| 2,000 | 262,144 |
Wrong Answer
| 451 | 32,912 | 443 |
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 = 2
# a = [[3,1,2],[6,1,1]]
N = input()
N = int(N)
a = [input().split() for _ in range(N)]
b = [[0,0,0]]
b.extend(a)
rtn = 'YES'
for i in range(N):
t1 = int(b[i][0])
x1 = int(b[i][1])
y1 = int(b[i][2])
t2 = int(b[i+1][0])
x2 = int(b[i+1][1])
y2 = int(b[i+1][2])
td = t2-t1
xyd = (x2+y2) - (x1+y1)
if((td%2==xyd%2) & (td>=xyd)):
rtn = rtn
else:
rtn = 'NO'
print(rtn)
|
s435400231
|
Accepted
| 442 | 32,912 | 443 |
# N = 2
# a = [[3,1,2],[6,1,1]]
N = input()
N = int(N)
a = [input().split() for _ in range(N)]
b = [[0,0,0]]
b.extend(a)
rtn = 'Yes'
for i in range(N):
t1 = int(b[i][0])
x1 = int(b[i][1])
y1 = int(b[i][2])
t2 = int(b[i+1][0])
x2 = int(b[i+1][1])
y2 = int(b[i+1][2])
td = t2-t1
xyd = (x2+y2) - (x1+y1)
if((td%2==xyd%2) & (td>=xyd)):
rtn = rtn
else:
rtn = 'No'
print(rtn)
|
s157954481
|
p03486
|
u164261323
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 72 |
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.
|
n = sorted(input())
s = sorted(input())
print("Yes" if n < s else "No")
|
s823215614
|
Accepted
| 19 | 3,060 | 69 |
print("Yes" if sorted((input())) < sorted((input()))[::-1] else "No")
|
s387581148
|
p03574
|
u551437236
| 2,000 | 262,144 |
Wrong Answer
| 34 | 9,224 | 594 |
You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process.
|
h,w = map(int, input().split())
sl = []
bl = [[0 for _ in range(w)] for _ in range(h)]
for i in range(h):
s = input()
sl.append(s)
def scheck(s):
if s == "#":
return 1
else:
return 0
def check(i,j,sl):
cnt = 0
for k in range(-1,2):
for l in range(-1,2):
if h > i+k >= 0 and w > j+l >= 0:
cnt += scheck(sl[i+k][j+l])
return cnt
for i in range(h):
for j in range(w):
if sl[i][j] == ".":
bl[i][j] = check(i,j,sl)
else:
bl[i][j] = "#"
for b in bl:
print(*b)
|
s972080326
|
Accepted
| 29 | 9,280 | 618 |
h,w = map(int, input().split())
sl = []
bl = [["" for _ in range(w)] for _ in range(h)]
for i in range(h):
s = input()
sl.append(s)
def scheck(s):
if s == "#":
return 1
else:
return 0
def check(i,j,sl):
cnt = 0
for k in range(-1,2):
for l in range(-1,2):
if h > i+k >= 0 and w > j+l >= 0:
cnt += scheck(sl[i+k][j+l])
return str(cnt)
for i in range(h):
for j in range(w):
if sl[i][j] == ".":
bl[i][j] = check(i,j,sl)
else:
bl[i][j] = "#"
for b in bl:
t = ''.join(b)
print(t)
|
s702140520
|
p03567
|
u507116804
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 67 |
Snuke built an online judge to hold a programming contest. When a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string S as a contiguous substring. (The judge can return any two-character substring of S.) Determine whether the judge can return the string `AC` as the verdict to a program.
|
s=input()
if s.count("AC") >=1:
print("YES")
else:
print("NO")
|
s886091409
|
Accepted
| 18 | 2,940 | 67 |
s=input()
if s.count("AC") >=1:
print("Yes")
else:
print("No")
|
s353015376
|
p03721
|
u806855121
| 2,000 | 262,144 |
Wrong Answer
| 578 | 32,724 | 228 |
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())
nums = []
for _ in range(N):
nums.append(list(map(int, input().split())))
nums.sort()
print(nums)
sumb = 0
for n in nums:
sumb += n[1]
if sumb >= K:
print(n[0])
break
|
s469306978
|
Accepted
| 481 | 27,872 | 216 |
N, K = map(int, input().split())
nums = []
for _ in range(N):
nums.append(list(map(int, input().split())))
nums.sort()
sumb = 0
for n in nums:
sumb += n[1]
if sumb >= K:
print(n[0])
break
|
s604990643
|
p02742
|
u982749462
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 2,940 | 145 |
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())
if h % 2 == 0:
print(h/2*w)
else:
if w % 2 == 0:
print((h//2 * w//2)*2)
else:
print(h*((w+1)//2) - w)
|
s699241661
|
Accepted
| 26 | 9,108 | 152 |
h, w = map(int, input().split())
#print(h, w)
if h == 1 or w == 1:
print(1)
elif h % 2 == 0 or w % 2 == 0:
print(h*w//2)
else:
print((h*w//2) + 1)
|
s971810705
|
p03712
|
u366676780
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 308 |
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
|
def solve():
H,W=map(int,input().split())
for i in range(W+2):
print("#",end='')
print()
for i in range(H):
print("#")
s=input()
print(s)
print("#")
for i in range(W+2):
print("#",end='')
print()
if __name__ == "__main__":
solve()
|
s331180156
|
Accepted
| 18 | 3,060 | 321 |
def solve():
H,W=map(int,input().split())
for i in range(W+2):
print("#",end='')
print()
for i in range(H):
print("#",end='')
s=input()
print(s,end='')
print("#")
for i in range(W+2):
print("#",end='')
print()
if __name__ == "__main__":
solve()
|
s071221801
|
p03693
|
u595981869
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 160 |
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?
|
if __name__ == "__main__":
r, g, b = map(int, input().split())
number = r * 100 + g * 10 + b
if number % 4 != 0:
print("No")
else:
print("Yes")
|
s676363850
|
Accepted
| 17 | 2,940 | 160 |
if __name__ == "__main__":
r, g, b = map(int, input().split())
number = r * 100 + g * 10 + b
if number % 4 != 0:
print("NO")
else:
print("YES")
|
s704647870
|
p02694
|
u644546699
| 2,000 | 1,048,576 |
Wrong Answer
| 24 | 9,164 | 236 |
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
import math
def resolve():
# O(logx)
X = int(input())
keika = 0
yokin = 100
while X <= yokin:
yokin = math.floor(yokin * 1.01)
keika += 1
print(keika)
if __name__ == "__main__":
resolve()
|
s145971861
|
Accepted
| 21 | 9,172 | 236 |
import math
def resolve():
# O(logx)
X = int(input())
keika = 0
yokin = 100
while yokin < X:
keika += 1
yokin += math.floor(yokin * 0.01)
print(keika)
if __name__ == "__main__":
resolve()
|
s651493246
|
p03371
|
u814986259
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 134 |
"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())
ans= min(A+B,C)*min(X,Y)
if X>Y:
ans+=min(A,C)*(X-Y)
else:
ans+=min(B,C)*(Y-X)
print(ans)
|
s838981050
|
Accepted
| 17 | 2,940 | 108 |
A, B, C, X, Y = map(int, input().split())
print(min(A*X+B*Y, X*C*2 + max(0, Y-X)*B, Y*C*2 + max(0, X-Y)*A))
|
s577398768
|
p03993
|
u762420987
| 2,000 | 262,144 |
Wrong Answer
| 63 | 14,008 | 145 |
There are N rabbits, numbered 1 through N. The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i. For a pair of rabbits i and j (i<j), we call the pair (i,j) a _friendly pair_ if the following condition is met. * Rabbit i likes rabbit j and rabbit j likes rabbit i. Calculate the number of the friendly pairs.
|
N = int(input())
alist = list(map(int, input().split()))
ans = 0
for i in range(N):
if alist[alist[i]-1]+1 == i:
ans += 1
print(ans)
|
s426667712
|
Accepted
| 68 | 14,008 | 148 |
N = int(input())
alist = list(map(int, input().split()))
ans = 0
for i in range(N):
if alist[alist[i]-1]-1 == i:
ans += 1
print(ans//2)
|
s667898259
|
p00022
|
u647694976
| 1,000 | 131,072 |
Wrong Answer
| 40 | 5,612 | 199 |
Given a sequence of numbers a1, a2, a3, ..., an, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a _contiquous_ subsequence.
|
while True:
N=int(input())
if N==0:
break
num=0
res=-11111111
for i in range(N):
a=int(input())
num=max(num+a,a)
res=max(num,res)
print(num)
|
s395291099
|
Accepted
| 40 | 5,604 | 251 |
while True:
N=int(input())
if N==0:
break
num=0
res=-11111111
for i in range(N):
a=int(input())
num=max(num+a, a)
#print(num)
res=max(num, res)
#print(res)
print(res)
|
s205857302
|
p03943
|
u656995812
| 2,000 | 262,144 |
Wrong Answer
| 20 | 2,940 | 112 |
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 = list(map(int, input().split()))
if a[0] + a[1] + a[2] == max(a) * 2:
print('YES')
else:
print('NO')
|
s671283995
|
Accepted
| 18 | 2,940 | 112 |
a = list(map(int, input().split()))
if a[0] + a[1] + a[2] == max(a) * 2:
print('Yes')
else:
print('No')
|
s749191946
|
p02613
|
u202826462
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 9,000 | 83 |
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())
if n % 1000 == 0:
print("0")
else:
print(1000 - n % 1000)
|
s317473178
|
Accepted
| 152 | 15,940 | 334 |
n = int(input())
s = list(input() for i in range(n))
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
if s[i] == "AC":
ac+=1
elif s[i] == "WA":
wa += 1
elif s[i] == "TLE":
tle += 1
else:
re += 1
print("AC x", str(ac))
print("WA x",str(wa))
print("TLE x",str(tle))
print("RE x",str(re))
|
s981970210
|
p03545
|
u509214520
| 2,000 | 262,144 |
Wrong Answer
| 27 | 9,132 | 424 |
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.
|
s = input()
for i in range(1 << 3):
count = int(s[0])
for j in range(1, 4):
if i & (1 << j-1):
count+=int(s[j])
else:
count-=int(s[j])
if count == 7:
ans = s[0]
for j in range(1, 4):
if i & (1 << j):
ans += '+'+s[j]
else:
ans += '-'+s[j]
ans += '=7'
print(ans)
exit()
|
s890603779
|
Accepted
| 27 | 9,208 | 426 |
s = input()
for i in range(1 << 3):
count = int(s[0])
for j in range(1, 4):
if i & (1 << j-1):
count+=int(s[j])
else:
count-=int(s[j])
if count == 7:
ans = s[0]
for j in range(1, 4):
if i & (1 << j-1):
ans += '+'+s[j]
else:
ans += '-'+s[j]
ans += '=7'
print(ans)
exit()
|
s927308342
|
p03448
|
u439392790
| 2,000 | 262,144 |
Wrong Answer
| 51 | 3,060 | 208 |
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())
cnt=0
for a in range(A):
for b in range(B):
for c in range(C):
if 500*a+100*b+50*c==X:
cnt=cnt+1
print(cnt)
|
s079344019
|
Accepted
| 51 | 3,060 | 214 |
A=int(input())
B=int(input())
C=int(input())
X=int(input())
cnt=0
for a in range(A+1):
for b in range(B+1):
for c in range(C+1):
if 500*a+100*b+50*c==X:
cnt=cnt+1
print(cnt)
|
s775644797
|
p03605
|
u216631280
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 57 |
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 in '9':
print('Yes')
else:
print('No')
|
s333935674
|
Accepted
| 17 | 2,940 | 57 |
n = input()
if '9' in n:
print('Yes')
else:
print('No')
|
s785972264
|
p03501
|
u167681750
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 58 |
You are parking at a parking lot. You can choose from the following two fee plans: * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours. * Plan 2: The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours.
|
a, b, n = map(int, input().split())
print(min((a * n), b))
|
s064732813
|
Accepted
| 17 | 2,940 | 58 |
n, a, b = map(int, input().split())
print(min((a * n), b))
|
s126692947
|
p03557
|
u284045566
| 2,000 | 262,144 |
Wrong Answer
| 2,058 | 29,452 | 634 |
The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower. He has N parts for each of the three categories. The size of the i-th upper part is A_i, the size of the i-th middle part is B_i, and the size of the i-th lower part is C_i. To build an altar, the size of the middle part must be strictly greater than that of the upper part, and the size of the lower part must be strictly greater than that of the middle part. On the other hand, any three parts that satisfy these conditions can be combined to form an altar. How many different altars can Ringo build? Here, two altars are considered different when at least one of the three parts used is different.
|
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a = sorted(a)
b = sorted(b)
c = sorted(c)
print(a)
print(b)
print(c)
def lower_bound(arr , x):
l = 0
r = len(c)
for i in range(100):
mid = (l + r) // 2
if x <= arr[mid]:
r = mid
else:
l = mid
return r
count = 0
for i in range(n):
a_count = lower_bound(a , b[i])
c_count = len(c) - lower_bound(c , b[i] + 1)
count += a_count * c_count
print(count)
|
s496754542
|
Accepted
| 824 | 29,440 | 605 |
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a = sorted(a)
b = sorted(b)
c = sorted(c)
def lower_bound(arr , x):
l = 0
r = len(c)
for j in range(30):
mid = (l + r) // 2
if x <= arr[mid]:
r = mid
else:
l = mid
return r
count = 0
for i in range(n):
a_count = lower_bound(a , b[i])
c_count = len(c) - lower_bound(c , b[i] + 1)
count += a_count * c_count
print(count)
|
s251248265
|
p03448
|
u625428807
| 2,000 | 262,144 |
Wrong Answer
| 55 | 3,064 | 252 |
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())
count = 0
for i in range(a):
for j in range(b):
for k in range(c):
sum = 500*i + 100*j + 50*k
if x == sum:
count += 1
print(count)
|
s695048429
|
Accepted
| 54 | 3,064 | 258 |
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a+1):
for j in range(b+1):
for k in range(c+1):
sum = 500*i + 100*j + 50*k
if x == sum:
count += 1
print(count)
|
s340267955
|
p03360
|
u644516473
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 104 |
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after K operations?
|
x = list(map(int, input().split()))
k = int(input())
ans = sum(x) - max(x)
ans += max(x) ** k
print(ans)
|
s932420025
|
Accepted
| 18 | 2,940 | 109 |
x = list(map(int, input().split()))
k = int(input())
ans = sum(x) - max(x)
ans += max(x) * 2 ** k
print(ans)
|
s894239853
|
p03386
|
u836157755
| 2,000 | 262,144 |
Wrong Answer
| 2,103 | 23,376 | 224 |
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
|
min, max, K = map(int, input().split())
if ((max - min + 1) > 2*K):
for i in range(min, max+1):
print(i)
else:
for i in range(min, min+K):
print(i)
for i in range(max-K, max+1):
print(i)
|
s950943849
|
Accepted
| 17 | 3,060 | 226 |
min, max, K = map(int, input().split())
if ((max - min + 1) < 2*K):
for i in range(min, max+1):
print(i)
else:
for i in range(min, min+K):
print(i)
for i in range(max-K+1, max+1):
print(i)
|
s716200579
|
p03433
|
u435281580
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 96 |
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())
m = n % 500
if m <= a:
print("YES")
else:
print("NO")
|
s987345872
|
Accepted
| 17 | 2,940 | 96 |
n = int(input())
a = int(input())
m = n % 500
if m <= a:
print("Yes")
else:
print("No")
|
s052739638
|
p03478
|
u018846452
| 2,000 | 262,144 |
Wrong Answer
| 38 | 9,084 | 251 |
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())
cnt = 0
ans = 0
print(n)
for i in range(n+1):
sum_ = 0
m = i
while True:
sum_ += m % 10
m //= 10
if not m:
break
if a <= sum_ <= b:
ans += i
print(ans)
|
s454144144
|
Accepted
| 33 | 9,124 | 187 |
n, a, b = map(int, input().split())
ans = 0
for i in range(n+1):
sum_ = 0
m = i
while True:
sum_ += m % 10
m //= 10
if not m:
break
if a <= sum_ <= b:
ans += i
print(ans)
|
s227008928
|
p03067
|
u820560680
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 108 |
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
|
a, b, c = map(int, input().split())
print("Yes") if((a < b and b < c) or (a > b and b > c)) else print("No")
|
s253952707
|
Accepted
| 18 | 2,940 | 108 |
a, b, c = map(int, input().split())
print("Yes") if((a < c and c < b) or (a > c and c > b)) else print("No")
|
s162977759
|
p03962
|
u601082779
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 24 |
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.
|
print(len(set(input())))
|
s931164207
|
Accepted
| 17 | 2,940 | 32 |
print(len(set(input().split())))
|
s909423138
|
p04029
|
u086172144
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 31 |
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)
|
s679289919
|
Accepted
| 17 | 2,940 | 36 |
n=int(input())
print(int(n*(n+1)/2))
|
s590385516
|
p03229
|
u026075806
| 2,000 | 1,048,576 |
Wrong Answer
| 2,104 | 11,680 | 812 |
You are given N integers; the i-th of them is A_i. Find the maximum possible sum of the absolute differences between the adjacent elements after arranging these integers in a row in any order you like.
|
def main():
def diffarray(arr):
sum = 0
tmp = arr[0]
for digit in arr[1:]:
sum += abs(tmp - digit)
tmp = digit
return sum
def insert(arr,max):
cur = arr[-1]
arr_ = arr[:-1]
retarr = arr
for i in range(len(arr_)):
newarr = arr_[:i] + [cur] + arr_[i:]
tmpdiff = diffarray(newarr)
if max < tmpdiff:
max = tmpdiff
retarr = newarr
return max, retarr
N = int(input())
arr=[]
for i in range(N):
arr.append(int(input()))
arr.sort()
max_diff = diffarray(arr)
for i in range(N):
max_diff, arr = insert(arr,max_diff)
print(max_diff)
return
main()
|
s311470135
|
Accepted
| 211 | 8,532 | 764 |
def main():
N = int(input())
array = [int(input()) for _ in range(N)]
array.sort()
div, mod = divmod(N, 2)
if mod == 0:
fore, last_in_fore, first_in_rear, rear = array[:div-1], array[div-1], array[div], array[div+1:]
a = 2 * sum(rear) + first_in_rear - last_in_fore - 2 * sum(fore)
print(a)
return
else:
#mode1 (mfrfm):(1,-2,2,-2,1)
fore1, mid1, rear1 = array[:div], array[div:div+2], array[div+2:]
a1 = -2 * sum(fore1) + sum(mid1) + 2 * sum(rear1)
#mode2 (mrfrm):(1,2,-2,2,1)
fore2, mid2, rear2 = array[:div-1], array[div-1:div+1], array[div+1:]
a2 = -2 * sum(fore2) - sum(mid2) + 2 * sum(rear2)
print(max(a1, a2))
return
return
main()
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.