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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s861351130
|
p04011
|
u332331919
| 2,000 | 262,144 |
Wrong Answer
| 34 | 9,072 | 534 |
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
|
# 044_a
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if ((1 <= N & N <= 10000) & (1 <= K & K <= 10000)) \
& (1 <= X & X <= 10000) & (1 <= Y & Y <= 10000):
if (X > Y):
price = 0
if (N <= K):
for i in range(1, N + 1):
price += X
if (N > K):
for i in range(1, K + 1):
price += X
for j in range(1, (N - (K + 1))):
price += Y
print(price)
|
s321257494
|
Accepted
| 27 | 9,164 | 589 |
# 044_a
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if ((1 <= N & N <= 10000) & (1 <= K & K <= 10000)) \
& (1 <= X & X <= 10000) & (1 <= Y & Y <= 10000):
if (X > Y):
price = 0
if (N < K):
for i in range(1, N + 1):
price += X
if (N >= K):
for i in range(1, K + 1):
price += X
for j in range(K + 1, N + 1):
price += Y
print(price)
|
s646790711
|
p03504
|
u021548497
| 2,000 | 262,144 |
Wrong Answer
| 351 | 23,824 | 704 |
Joisino is planning to record N TV programs with recorders. The TV can receive C channels numbered 1 through C. The i-th program that she wants to record will be broadcast from time s_i to time t_i (including time s_i but not t_i) on Channel c_i. Here, there will never be more than one program that are broadcast on the same channel at the same time. When the recorder is recording a channel from time S to time T (including time S but not T), it cannot record other channels from time S-0.5 to time T (including time S-0.5 but not T). Find the minimum number of recorders required to record the channels so that all the N programs are completely recorded.
|
n, c = map(int, input().split())
program = [[] for _ in range(c)]
for i in range(n):
s, t, cc = map(int, input().split())
program[cc-1].append((s, t))
count = [0]*(10**5+1)
judge = True
for i in range(c):
program[i].sort()
l = len(program[i])
for j in range(l-1):
if judge:
count[program[i][j][0]-1] += 1
if program[i][j][1] == program[i][j+1][0]:
judge = False
else:
judge = True
if judge:
count[program[i][j][1]] -= 1
if l == 0:
continue
if judge:
count[program[i][l-1][0]-1] += 1
count[program[i][l-1][1]] -= 1
ans = 0
for i in range(10**5+1):
if i != 0:
count[i] += count[i-1]
if ans < count[i]:
ans = count[i]
print(ans)
|
s121934893
|
Accepted
| 360 | 23,900 | 713 |
n, c = map(int, input().split())
program = [[] for _ in range(c)]
for i in range(n):
s, t, cc = map(int, input().split())
program[cc-1].append((s, t))
count = [0]*(10**5+1)
for i in range(c):
program[i].sort()
l = len(program[i])
judge = True
for j in range(l-1):
if judge:
count[program[i][j][0]-1] += 1
if program[i][j][1] == program[i][j+1][0]:
judge = False
else:
judge = True
if judge:
count[program[i][j][1]] -= 1
if l == 0:
continue
if judge:
count[program[i][l-1][0]-1] += 1
count[program[i][l-1][1]] -= 1
ans = 0
for i in range(10**5+1):
if i != 0:
count[i] += count[i-1]
if ans < count[i]:
ans = count[i]
print(ans)
|
s280452702
|
p03485
|
u185464141
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 57 |
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
a,b = map(int, input().split())
print(int(a + b + 1 / 2))
|
s284298921
|
Accepted
| 17 | 2,940 | 56 |
a,b = map(int, input().split())
print((a + b + 1) // 2)
|
s766857482
|
p03605
|
u143492911
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 88 |
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=list(map(int,input()))
if 1<=n.count("9"):
print("Yes")
else:
print("No")
|
s431624523
|
Accepted
| 17 | 2,940 | 86 |
n=list(map(int,input()))
if 1<=n.count(9):
print("Yes")
else:
print("No")
|
s891721305
|
p02399
|
u130834228
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,548 | 98 |
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
|
a, b= map(int, input().split())
d = a // b
r = a % b
f = a/b
print(str(d)+" "+str(r)+" "+str(f))
|
s293558375
|
Accepted
| 20 | 7,616 | 131 |
a, b= map(int, input().split())
d = a // b
r = a % b
f = a/b
#print(str(d)+" "+str(r)+" "+str(f))
print("%d %d %.5f" % (d, r, f))
|
s738442302
|
p03795
|
u266874640
| 2,000 | 262,144 |
Wrong Answer
| 20 | 3,316 | 100 |
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())
power = 1
for i in range(1,N+1):
power = power * i % 1000000007
print(power)
|
s749283190
|
Accepted
| 17 | 2,940 | 49 |
N = int(input())
print(N * 800 - (N // 15) * 200)
|
s934645197
|
p03386
|
u331036636
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 443 |
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 = []
ans.append(a)
if b-a > k:
for i in range(1,k):
ans.append(a+i)
for j in range(1,k):
ans.append(b-j)
ans.append(b)
for k in range(len(set(ans))):
print(list(set(ans))[k])
else:
for i in range(1,b-a):
ans.append(a+i)
for j in range(1,b-a):
ans.append(b-j)
ans.append(b)
for k in range(len(set(ans))):
print(list(set(ans))[k])
|
s900112893
|
Accepted
| 19 | 3,064 | 225 |
a,b,k=map(int,input().split())
ans = []
ans.append(a)
for i in range(min(k,b-a)):
ans.append(a+i)
for j in range(min(k,b-a)):
ans.append(b-j)
ans.append(b)
for k in range(len(set(ans))):
print(sorted(set(ans))[k])
|
s451780346
|
p03997
|
u197237612
| 2,000 | 262,144 |
Wrong Answer
| 28 | 9,120 | 76 |
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 )
|
s360204090
|
Accepted
| 26 | 9,036 | 82 |
a = int(input())
b = int(input())
h = int(input())
print( int((a + b) * h / 2) )
|
s883138532
|
p02678
|
u638456847
| 2,000 | 1,048,576 |
Wrong Answer
| 291 | 54,204 | 767 |
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
|
from collections import deque
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def main():
N,M,*ab = map(int, read().split())
E = [[] for _ in range(N+1)]
for a, b in zip(*[iter(ab)]*2):
E[a].append(b)
E[b].append(a)
par = [0] * (N+1)
seen = [-1] * (N+1)
seen[1] = 0
queue = deque([1])
while queue:
v = queue.popleft()
for e in E[v]:
if seen[e] == -1:
seen[e] = seen[v] + 1
par[e] = v
queue.append(e)
for i in range(1, N+1):
if seen[i] == -1:
print("No")
exit()
print("\n".join(map(str, par[2:])))
if __name__ == "__main__":
main()
|
s570385032
|
Accepted
| 321 | 54,268 | 784 |
from collections import deque
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def main():
N,M,*ab = map(int, read().split())
E = [[] for _ in range(N+1)]
for a, b in zip(*[iter(ab)]*2):
E[a].append(b)
E[b].append(a)
par = [0] * (N+1)
seen = [-1] * (N+1)
seen[1] = 0
queue = deque([1])
while queue:
v = queue.popleft()
for e in E[v]:
if seen[e] == -1:
seen[e] = seen[v] + 1
par[e] = v
queue.append(e)
for i in range(1, N+1):
if seen[i] == -1:
print("No")
exit()
print("Yes")
print("\n".join(map(str, par[2:])))
if __name__ == "__main__":
main()
|
s004172813
|
p03495
|
u249895018
| 2,000 | 262,144 |
Wrong Answer
| 215 | 39,648 | 375 |
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them.
|
import os
import sys
n,k = map(int, input().split())
a = [x for x in map(int, input().split())]
d = {}
for i in a:
if i in d:
d[i]+=1
else:
d[i] = 1
sorted(d.items(), key=lambda x: x[1])
if(len(d) <= k):
print(0)
exit(0)
tmp = len(d)
ans = 0
for i in d.keys():
tmp-=1
ans += d[i]
if(tmp==k):
break
print(ans)
exit(0)
|
s529242573
|
Accepted
| 219 | 39,648 | 379 |
import os
import sys
n,k = map(int, input().split())
a = [x for x in map(int, input().split())]
d = {}
for i in a:
if i in d:
d[i]+=1
else:
d[i] = 1
s_d = sorted(d.items(), key=lambda x: x[1])
if(len(d) <= k):
print(0)
exit(0)
tmp = len(d)
ans = 0
for _,v in s_d:
tmp-=1
ans += v
if(tmp==k):
break
print(ans)
exit(0)
|
s016848698
|
p02413
|
u237991875
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,616 | 174 |
Your task is to perform a simple table calculation. Write a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column.
|
r, c = map(int, input().split())
for i in range(r):
line = list(map(int, input().split()))
line.append(sum(line))
line = map(str, line)
print(" ".join(line))
|
s044754386
|
Accepted
| 20 | 7,704 | 333 |
r, c = map(int, input().split())
hyou = []
tate_sum = [0] * (c + 1)
for i in range(r):
line = list(map(int, input().split()))
line.append(sum(line))
tate_sum = [tate_sum[j] + line[j] for j in range(len(line))]
hyou.append(" ".join(map(str, line)))
hyou.append(" ".join(map(str, tate_sum)))
print("\n".join(hyou))
|
s510226012
|
p03836
|
u732743460
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 85 |
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
|
sx,sy,tx,ty = map(int,input().split())
a=tx-sx
b=ty-sy
print("U"*b+"R"*a+"D"*b+"L"*a)
|
s053500499
|
Accepted
| 17 | 3,060 | 142 |
sx,sy,tx,ty = map(int,input().split())
a=tx-sx
b=ty-sy
print("U"*b+"R"*a+"D"*b+"L"*a+"L"+"U"*(b+1)+"R"*(a+1)+"D"+"R"+"D"*(b+1)+"L"*(a+1)+"U")
|
s723581100
|
p03556
|
u923712635
| 2,000 | 262,144 |
Wrong Answer
| 29 | 2,940 | 58 |
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())
i = 1
while(i**2<=N):
i += 1
print(i-1)
|
s728956636
|
Accepted
| 28 | 2,940 | 64 |
N = int(input())
i = 1
while(i**2<=N):
i += 1
print((i-1)**2)
|
s138938801
|
p02694
|
u036744580
| 2,000 | 1,048,576 |
Wrong Answer
| 23 | 9,164 | 260 |
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?
|
# Python 3
from sys import stdin, stdout
if __name__ == "__main__":
x = stdin.readline()
x = int(x)
curr = 101
ans = 1
while curr <= x:
curr *= 101
curr //= 100
ans += 1
stdout.write(str(ans) + '\n')
|
s019153220
|
Accepted
| 22 | 9,160 | 259 |
# Python 3
from sys import stdin, stdout
if __name__ == "__main__":
x = stdin.readline()
x = int(x)
curr = 101
ans = 1
while curr < x:
curr *= 101
curr //= 100
ans += 1
stdout.write(str(ans) + '\n')
|
s459984930
|
p03545
|
u239204773
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 721 |
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.
|
def DepthFirst_search(S,pre):
global out
#print(out)
print('pre = {}'.format(pre))
if len(S) == 1 :
if pre + int(S[0]) == 7:
out = out + '+{}'.format(int(S[0])) + '=7'
return True
if pre - int(S[0]) == 7:
out = out + '-{}'.format(int(S[0])) + '=7'
return True
return False
pre += int(S[0])
if DepthFirst_search(S[1:len(S)],pre):
#print(out)
out = '+' + S[0] + out
return True
pre -= 2*int(S[0])
if DepthFirst_search(S[1:len(S)],pre):
#print(out)
out = '-' + S[0] + out
return True
return False
out = ''
pre = 0
S = input()
DepthFirst_search(S,pre)
print(out[1:])
|
s389353025
|
Accepted
| 18 | 3,064 | 722 |
def DepthFirst_search(S,pre):
global out
#print(out)
if len(S) == 1 :
if pre + int(S[0]) == 7:
out = out + '+{}'.format(int(S[0])) + '=7'
return True
if pre - int(S[0]) == 7:
out = out + '-{}'.format(int(S[0])) + '=7'
return True
return False
pre += int(S[0])
if DepthFirst_search(S[1:len(S)],pre):
#print(out)
out = '+' + S[0] + out
return True
pre -= 2*int(S[0])
if DepthFirst_search(S[1:len(S)],pre):
#print(out)
out = '-' + S[0] + out
return True
return False
out = ''
pre = 0
S = input()
DepthFirst_search(S,pre)
print(out[1:])
|
s936563723
|
p03598
|
u612975321
| 2,000 | 262,144 |
Wrong Answer
| 23 | 9,140 | 48 |
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())
a = int(input())
print(n**2-a)
|
s079591306
|
Accepted
| 29 | 9,100 | 134 |
n = int(input())
k = int(input())
x = list(map(int, input().split()))
d = 0
for i in x:
y = min(i, abs(k-i))
d += 2*y
print(d)
|
s175895862
|
p00001
|
u424041287
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,508 | 25 |
There is a data which provides heights (in meter) of mountains. The data is only for ten mountains. Write a program which prints heights of the top three mountains in descending order.
|
x = int(input().rstrip())
|
s723456244
|
Accepted
| 20 | 7,724 | 331 |
num =[0,0,0]
for a in range(10):
x = int(input().rstrip())
if x > num[0]:
num[2] = num[1]
num[1] = num[0]
num[0] = x
continue
elif x > num[1]:
num[2] = num[1]
num[1] = x
continue
elif x > num[2]:
num[2] = x
for a in range(3):
print(num[a])
|
s203118813
|
p03814
|
u663014688
| 2,000 | 262,144 |
Wrong Answer
| 2,107 | 86,988 | 299 |
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.
|
S = input()
S = list(S)
l = []
ans = ''
l_str = ''
for i in range(len(S)-1):
if S[i] == 'A':
for j in range(len(S)-1):
l.append(S[i])
if S[i] == 'Z':
l_str = ''.join(l)
if l_str > ans:
ans = l_str
print(ans)
|
s290482921
|
Accepted
| 72 | 11,180 | 214 |
S = input()
a = []
z = []
for i in range(len(S)):
if S[i] == 'A':
a.append(i)
if S[i] == 'Z':
z.append(i)
a = min(a)
z = max(z)
if z<=a:
print('0')
else:
print(len(S[a:z+1]))
|
s776662238
|
p03997
|
u077291787
| 2,000 | 262,144 |
Wrong Answer
| 20 | 2,940 | 116 |
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a, b, h= list(map(int, [input().rstrip() for _ in range(3)]))
print((a + b) * h / 2)
|
s742743903
|
Accepted
| 17 | 2,940 | 122 |
a, b, h = list(map(int, [input().rstrip() for _ in range(3)]))
print(int((a + b) * h / 2))
|
s792303004
|
p03150
|
u810787773
| 2,000 | 1,048,576 |
Wrong Answer
| 27 | 9,048 | 532 |
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
|
def main():
S = input()
if S == 'keyence':
return ('Yes')
ans = 'keyence'
j = 0
cnt = 0
i = 0
while i<len(S):
if S[i] == ans[j]:
while True:
j += 1
i += 1
if j == 7:
return ('Yes')
elif S[i] != ans[j]:
cnt += 1
if cnt > 1:
return('No')
break
else:
i += 1
return('No')
print(main())
|
s710214730
|
Accepted
| 27 | 8,856 | 457 |
def main():
S = input()
if S[0] != 'k':
return ('NO')
elif S == 'keyence':
return ('YES')
ans = 'keyence'
i = 0
j = 0
while True:
i += 1
j += 1
if S[i] != ans[j]:
break
num = 7-j
cnt = 0
while cnt < num:
cnt += 1
#print(ans[-cnt])
if S[-cnt] != ans[-cnt]:
return ('NO')
return ('YES')
print(main())
|
s765510008
|
p02831
|
u409757418
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 113 |
Takahashi is organizing a party. At the party, each guest will receive one or more snack pieces. Takahashi predicts that the number of guests at this party will be A or B. Find the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted. We assume that a piece cannot be divided and distributed to multiple guests.
|
a , b = map(int, input().split())
ab = a*b
if a < b:
a, b = b, a
while b:
a = b
b = a % b
print(ab // a)
|
s346140311
|
Accepted
| 17 | 2,940 | 112 |
a , b = map(int, input().split())
ab = a*b
if a < b:
a, b = b, a
while b > 0:
a, b = b, a % b
print(ab // a)
|
s751733104
|
p03578
|
u309141201
| 2,000 | 262,144 |
Wrong Answer
| 639 | 84,476 | 397 |
Rng is preparing a problem set for a qualification round of CODEFESTIVAL. He has N candidates of problems. The difficulty of the i-th candidate is D_i. There must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems. Determine whether Rng can complete the problem set without creating new candidates of problems.
|
from collections import Counter
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
dd = Counter(d)
tt = Counter(t)
print(dd, tt)
ok = True
for i, j in tt.items():
if i in dd:
# print('Y')
if dd[i] < j:
ok = False
else:
ok = False
# print(i, j, ok)
if ok:
print('YES')
else:
print('NO')
|
s154910802
|
Accepted
| 284 | 57,056 | 399 |
from collections import Counter
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
dd = Counter(d)
tt = Counter(t)
# print(dd, tt)
ok = True
for i, j in tt.items():
if i in dd:
# print('Y')
if dd[i] < j:
ok = False
else:
ok = False
# print(i, j, ok)
if ok:
print('YES')
else:
print('NO')
|
s155856378
|
p03433
|
u968649733
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 98 |
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, A = [int(input()) for _ in range(2)]
if (N - A) % 500 == 0:
print('YES')
else:
print('NO')
|
s711752819
|
Accepted
| 17 | 2,940 | 93 |
N, A = [int(input()) for _ in range(2)]
if N % 500 <= A:
print('Yes')
else:
print('No')
|
s837636408
|
p00002
|
u114472050
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,408 | 85 |
Write a program which computes the digit number of sum of two integers a and b.
|
import sys
for line in sys.stdin:
a, b = line.split()
print(len(str(a + b)))
|
s885476699
|
Accepted
| 20 | 7,636 | 96 |
import sys
for line in sys.stdin:
a, b = line.split()
print(len(str(int(a) + int(b))))
|
s372385896
|
p03162
|
u743908701
| 2,000 | 1,048,576 |
Wrong Answer
| 525 | 50,164 | 1,068 |
Taro's summer vacation starts tomorrow, and he has decided to make plans for it now. The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day: * A: Swim in the sea. Gain a_i points of happiness. * B: Catch bugs in the mountains. Gain b_i points of happiness. * C: Do homework at home. Gain c_i points of happiness. As Taro gets bored easily, he cannot do the same activities for two or more consecutive days. Find the maximum possible total points of happiness that Taro gains.
|
n = int(input())
x = [-1]*n
for i in range(n):
x[i] = list(map(int, input().split()))
ans = [[0]*3 for i in range(n)]
ans[0] = x[0]
for k in range(1,n):
for j in range(3):
ans[k][j] = max(ans[k-1][(j+1)%3], ans[k-1][(j+2)%3]) + x[k][j]
print(ans[i])
print(max(ans[n-1]))
|
s030281737
|
Accepted
| 460 | 50,176 | 277 |
n = int(input())
x = [-1]*n
for i in range(n):
x[i] = list(map(int, input().split()))
ans = [[0]*3 for i in range(n)]
ans[0] = x[0]
for k in range(1,n):
for j in range(3):
ans[k][j] = max(ans[k-1][(j+1)%3], ans[k-1][(j+2)%3]) + x[k][j]
print(max(ans[n-1]))
|
s286926022
|
p02694
|
u571524394
| 2,000 | 1,048,576 |
Wrong Answer
| 22 | 9,156 | 43 |
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
X = int(input())
print(100*X//(X-1)+X-201)
|
s398261214
|
Accepted
| 22 | 9,168 | 106 |
X = int(input())
year = 0
x = 100
while True:
x = x + x//100
year += 1
if x >= X:break
print(year)
|
s420226130
|
p03379
|
u814781830
| 2,000 | 262,144 |
Wrong Answer
| 296 | 25,472 | 175 |
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N.
|
N = int(input())
X = list(map(int, input().split()))
X.sort()
m1 = X[N // 2]
m2 = X[(N-2)//2]
for x in X:
if x < m1:
print(m1)
else:
print(m2)
|
s819512847
|
Accepted
| 280 | 26,772 | 192 |
N = int(input())
X = list(map(int, input().split()))
sortX = sorted(X)
m1 = sortX[N // 2]
m2 = sortX[(N-2)//2]
for x in X:
if x < m1:
print(m1)
else:
print(m2)
|
s820606220
|
p02612
|
u344888046
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 9,144 | 32 |
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)
|
s274779310
|
Accepted
| 26 | 9,168 | 58 |
N = int(input())
k = 10000
ans = (k - N) % 1000
print(ans)
|
s953870711
|
p03161
|
u416758623
| 2,000 | 1,048,576 |
Wrong Answer
| 1,746 | 13,980 | 281 |
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 one of the following: Stone i + 1, i + 2, \ldots, i + K. 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,k = map(int, input().split())
h = list(map(int, input().split()))
dp = [0] * n
dp[0] = 0
print(dp)
for i, j in enumerate(h):
s = 0 if i < k else i - k
if i == 0:
continue
dp[i] = min([abs(j - h_k) + dp_k for h_k, dp_k in zip(h[s:i], dp[s:i])])
print(dp[-1])
|
s152920794
|
Accepted
| 1,779 | 13,980 | 271 |
n,k = map(int, input().split())
h = list(map(int, input().split()))
dp = [0] * n
dp[0] = 0
for i, j in enumerate(h):
s = 0 if i < k else i - k
if i == 0:
continue
dp[i] = min([abs(j - h_k) + dp_k for h_k, dp_k in zip(h[s:i], dp[s:i])])
print(dp[-1])
|
s897106905
|
p03920
|
u803848678
| 2,000 | 262,144 |
Wrong Answer
| 311 | 3,952 | 648 |
The problem set at _CODE FESTIVAL 20XX Finals_ consists of N problems. The score allocated to the i-th (1≦i≦N) problem is i points. Takahashi, a contestant, is trying to score exactly N points. For that, he is deciding which problems to solve. As problems with higher scores are harder, he wants to minimize the highest score of a problem among the ones solved by him. Determine the set of problems that should be solved.
|
import heapq
n = int(input())
def divide_two(s, heap):
use = -heapq.heappop(heap)
#print(s, heap)
#print(use)
top, bot = use//2+use%2, use//2
while True:
#print(top, bot)
if top >= use or bot <= 0:
print(use)
exit()
if top == bot:
top += 1
bot -= 1
continue
if top in s or bot in s:
top += 1
bot -= 1
continue
heapq.heappush(heap, -top)
heapq.heappush(heap, -bot)
s.add(top)
s.add(bot)
return True
s = set([n])
heap = [-n]
while divide_two(s, heap):
pass
|
s603595668
|
Accepted
| 23 | 3,316 | 315 |
n = int(input())
if n == 1:
print(1)
exit()
s = 0
cnt = 1
while True:
s += cnt
if s < n <= s+cnt+1:
use = cnt+1
sub = use*(use+1)//2 - n
for i in range(use):
if i+1 == sub:
continue
print(i+1)
exit()
else:
cnt += 1
|
s833054704
|
p03457
|
u437273756
| 2,000 | 262,144 |
Wrong Answer
| 414 | 21,052 | 330 |
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
|
N = int(input())
plan = []
for i in range(N):
plan += [[int(n) for n in input().split(' ')]]
ret = "YES"
t0 , x0, y0 = 0, 0, 0
for t, x, y in plan:
dt = t-t0
dx = x-x0
dy = y-y0
result = dt - (dx+dy)
if (result<0) | (result%2!=0):
ret = "NO"
break
t0, x0, y0 = t, x, y
print(ret)
|
s422252125
|
Accepted
| 425 | 21,052 | 372 |
N = int(input())
plan = []
for i in range(N):
plan += [[int(n) for n in input().split(' ')]]
ret = "Yes"
t0 , x0, y0 = 0, 0, 0
for t, x, y in plan:
dt = t-t0
dx = abs(x-x0)
dy = abs(y-y0)
result = dt - (dx+dy)
if result<0:
ret = "No"
break
if result%2!=0:
ret = "No"
break
t0, x0, y0 = t, x, y
print(ret)
|
s032161411
|
p00016
|
u184989919
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,792 | 393 |
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 sys
import math
def TreasureHunt():
x,y=(0.0,0.0)
alpha=90
for line in sys.stdin:
a,b=list(map(int,line.split(',')))
if a==0 and b==0:
break
x+=a*math.cos(alpha/180.0*math.pi)
y+=a*math.sin(alpha/180.0*math.pi)
alpha=(alpha-b+360)%360
print(int(x),int(y))
TreasureHunt()
|
s170693220
|
Accepted
| 20 | 7,828 | 404 |
import sys
import math
def TreasureHunt():
x,y=(0.0,0.0)
alpha=90
for line in sys.stdin:
a,b=list(map(int,line.split(',')))
if a==0 and b==0:
break
x+=a*math.cos(alpha/180.0*math.pi)
y+=a*math.sin(alpha/180.0*math.pi)
alpha=(alpha-b+360)%360
print(int(x))
print(int(y))
TreasureHunt()
|
s103279468
|
p02399
|
u962909487
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,596 | 58 |
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
|
a,b = map(int,input().split())
print(a//b,a%b,float(a/b))
|
s169752427
|
Accepted
| 20 | 5,600 | 68 |
a,b = map(int,input().split())
print(a//b,a%b,"{:.5f}".format(a/b))
|
s461508089
|
p03719
|
u439392790
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 87 |
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
|
A,B,C=map(int,input().split())
if C>=A and C<=B:
print('YES')
else:
print('NO')
|
s705112638
|
Accepted
| 17 | 2,940 | 87 |
A,B,C=map(int,input().split())
if C>=A and C<=B:
print('Yes')
else:
print('No')
|
s149550767
|
p04035
|
u693716675
| 2,000 | 262,144 |
Wrong Answer
| 142 | 14,052 | 475 |
We have N pieces of ropes, numbered 1 through N. The length of piece i is a_i. At first, for each i (1≤i≤N-1), piece i and piece i+1 are tied at the ends, forming one long rope with N-1 knots. Snuke will try to untie all of the knots by performing the following operation repeatedly: * Choose a (connected) rope with a total length of at least L, then untie one of its knots. Is it possible to untie all of the N-1 knots by properly applying this operation? If the answer is positive, find one possible order to untie the knots.
|
n,l = [int(i) for i in input().split()]
a=[int(i) for i in input().split()]
max_len = a[0]+a[1]
max_joint = 1
for i in range(1,n-1):
len = a[i] + a[i+1]
if len > max_len:
max_len = len
max_joint = i+1
if max_len < l:
print("Impossible")
exit()
else:
print("Possible")
for i in range(1,max_joint):
print(i)
for i in range(n, max_joint, -1):
print(i)
print("Possible")
|
s227157277
|
Accepted
| 146 | 14,060 | 457 |
#C
n,l = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
maxsum=0
maxind = 0
for i in range(n-1):
s = a[i]+a[i+1]
if s > maxsum:
maxsum = s
maxind = i+1
if maxsum<l:
print("Impossible")
else:
print("Possible")
for i in range(1,maxind):
print(i)
for i in range(n-1,maxind,-1):
print(i)
print(maxind)
|
s567805473
|
p03478
|
u772261431
| 2,000 | 262,144 |
Wrong Answer
| 52 | 8,900 | 311 |
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 = list(map(int, input().split()))
total = 0
for i in range(1,n + 1):
length = len(str(i))
ele = []
for j in range(1, length + 1):
num = str(i)[-j]
num = int(num)
ele.append(num)
s = sum(ele)
if a <= s and s <= b:
total += s
print(total)
|
s064254496
|
Accepted
| 45 | 9,112 | 270 |
n, a, b = list(map(int, input().split()))
total = 0
for i in range(1,n + 1):
length = len(str(i))
ele = []
l = str(i)
array = list(map(int, l))
s = sum(array)
if a <= s and s <= b:
total += i
print(total)
|
s675097489
|
p03494
|
u734169929
| 2,000 | 262,144 |
Wrong Answer
| 148 | 12,496 | 155 |
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())
import numpy as np
A = np.array(list(map(int, input().split())))
ans = 0
while not np.any(A % 2 == 0):
A = A / 2
ans += 1
print(ans)
|
s133052605
|
Accepted
| 300 | 21,220 | 145 |
N = input()
import numpy as np
A = np.array(list(map(int, input().split())))
ans = 0
while not np.any(A % 2):
A = A / 2
ans += 1
print(ans)
|
s548609590
|
p03480
|
u748241164
| 2,000 | 262,144 |
Wrong Answer
| 63 | 11,376 | 1,203 |
You are given a string S consisting of `0` and `1`. Find the maximum integer K not greater than |S| such that we can turn all the characters of S into `0` by repeating the following operation some number of times. * Choose a contiguous segment [l,r] in S whose length is at least K (that is, r-l+1\geq K must be satisfied). For each integer i such that l\leq i\leq r, do the following: if S_i is `0`, replace it with `1`; if S_i is `1`, replace it with `0`.
|
#N = int(input())
S = str(input())
#X, Y = map(int, input().split())
#C = list(map(int, input().split()))
conti = []
now = 1
for i in range(1, len(S)):
if S[i] == S[i - 1]:
now += 1
else:
conti.append(now)
now = 1
conti.append(now)
#print(conti)
nn = len(conti)
ss = int((nn + 1) / 2)
ruiseki = [0] * (nn + 1)
for i in range(nn):
ruiseki[i + 1] = ruiseki[i] + conti[i]
ans = 10 ** 5 + 1
pesudo = 10 ** 5 + 1
区間一つだけは選択せずに避けることができる
for i in range(nn - ss + 1):
now = ruiseki[i + ss] - ruiseki[i]
if now < pesudo:
ans = pesudo
pesudo = now
elif now < ans:
ans = now
#print(nn, ss)
print(ans)
|
s410471883
|
Accepted
| 64 | 9,216 | 229 |
#N = int(input())
S = str(input())
#X, Y = map(int, input().split())
#C = list(map(int, input().split()))
N =len(S)
ans = N
for i in range(1, N):
if S[i] != S[i - 1]:
now = max(i, N - i)
ans = min(ans, now)
print(ans)
|
s444956827
|
p03997
|
u168906897
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 73 |
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a = int(input())
b = int(input())
h = int(input())
s = (a+b)*h/2
print(s)
|
s315768234
|
Accepted
| 17 | 2,940 | 81 |
a = int(input())
b = int(input())
h = int(input())
s = int((a + b)*h/2)
print(s)
|
s433885957
|
p03719
|
u466826467
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 97 |
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
|
a, b, c = list(map(int, input().split()))
if a <= c <= b:
print("YES")
else:
print("NO")
|
s670722172
|
Accepted
| 17 | 2,940 | 97 |
a, b, c = list(map(int, input().split()))
if a <= c <= b:
print("Yes")
else:
print("No")
|
s130744712
|
p02603
|
u514678698
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 8,964 | 195 |
To become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives. He is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows: * A_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day. In the i-th day, M-kun can make the following trade **any number of times** (possibly zero), **within the amount of money and stocks that he has at the time**. * Buy stock: Pay A_i yen and receive one stock. * Sell stock: Sell one stock for A_i yen. What is the maximum possible amount of money that M-kun can have in the end by trading optimally?
|
n = int(input())
a = list(map(int, input().split()))
mon = 1000
for i in range(1, n):
if a[i-1] < a[i]:
kb = mon // a[i-1]
mon %= a[i-1]
mon += kb * a[i]
print(kb, mon)
print(mon)
|
s463481881
|
Accepted
| 33 | 9,140 | 178 |
n = int(input())
a = list(map(int, input().split()))
mon = 1000
for i in range(1, n):
if a[i-1] < a[i]:
kb = mon // a[i-1]
mon %= a[i-1]
mon += kb * a[i]
print(mon)
|
s815869031
|
p02267
|
u585035894
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,600 | 149 |
You are given a sequence of _n_ integers S and a sequence of different _q_ integers T. Write a program which outputs C, the number of integers in T which are also in the set S.
|
input()
l = [int(i) for i in input().split()]
input()
c = 0
for i in input().split():
for j in l:
if i == l:
c += 1
print(c)
|
s424419766
|
Accepted
| 170 | 6,548 | 172 |
input()
l = [int(i) for i in input().split()]
input()
c = 0
for i in input().split():
for j in l:
if int(i) == j:
c += 1
break
print(c)
|
s149755070
|
p03455
|
u306241759
| 2,000 | 262,144 |
Wrong Answer
| 28 | 9,124 | 98 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a, b = (int(x) for x in input().split())
c = a*b
if c%2:
print("Even")
else:
print("Odd")
|
s357190167
|
Accepted
| 25 | 9,148 | 99 |
a, b = (int(x) for x in input().split())
c = a*b
if c%2:
print("Odd")
else:
print("Even")
|
s292704884
|
p04043
|
u016393440
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 222 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
a, b, c = (int(i) for i in input().split())
if a == 5 or b == 5 or c == 5:
if (a == 7 and b == 7) or (b == 7 and c == 7) or (a == 7 and c == 7):
print('YES')
else:
print('NO')
else :
print('NO')
|
s649900492
|
Accepted
| 17 | 3,060 | 262 |
a, b, c = (int(i) for i in input().split())
if a == 7 or b == 7 or c == 7:
if (a == 5 and b == 5) or (b == 5 and c == 5) or (a == 5 and c == 5):
print('YES')
exit()
else:
print('NO')
exit()
else:
print('NO')
exit()
|
s488172601
|
p03759
|
u642874916
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 90 |
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
|
a, b, c = map(int, input().split())
if b - c == c - b:
print('YES')
else:
print('NO')
|
s713415154
|
Accepted
| 17 | 2,940 | 91 |
a, b, c = map(int, input().split())
if b - a == c - b:
print('YES')
else:
print('NO')
|
s664966287
|
p03635
|
u124762318
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 57 |
In _K-city_ , there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?
|
ls = list(input())
print(ls[0] + str(len(ls)-2) + ls[-1])
|
s646741765
|
Accepted
| 17 | 2,940 | 86 |
n, m = (int(i) for i in input().split())
if m > 1:
gaiku = (n-1)*(m-1)
print(gaiku)
|
s584423882
|
p00512
|
u408260374
| 8,000 | 131,072 |
Wrong Answer
| 30 | 6,720 | 150 |
ある工場では,各営業所から製品生産の注文を受けている. 前日の注文をまとめて,各製品の生産合計を求めたい. 入力ファイルの1行目には注文データの数 n が書いてあり, 続く n 行には製品名と注文数が空白で区切られて書いてある. 製品名は5文字以内の英大文字で書かれている. 注文データには同じ製品が含まれていることもあり,順序はバラバラである. この注文データの中に現れる同じ製品の注文数を合計し, 出力ファイルに製品名と合計を空白を区切り文字として出力しなさい. ただし,製品名に次の順序を付けて,その順で出力すること. 順序:文字の長さの小さい順に,同じ長さのときは,前から比べて 最初に異なる文字のアルファベット順とする. 入力データにおける製品数,注文数とその合計のどれも106以下である. 出力ファイルにおいては, 出力の最後の行にも改行コードを入れること.
|
o={}
for _ in range(int(input())):p,m=input().split();o[p]=o.get(p,0)+int(m)
k=sorted([(len(x),x) for x in list(o.keys())])
for i,j in k:print(i,o[j])
|
s305820539
|
Accepted
| 70 | 6,724 | 143 |
o={}
for _ in range(int(input())):p,m=input().split();o[p]=o.get(p,0)+int(m)
k=sorted([(len(x),x)for x in o.keys()])
for _,i in k:print(i,o[i])
|
s181395982
|
p00436
|
u150984829
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,592 | 208 |
1 から 2n の数が書かれた 2n 枚のカードがあり,上から 1, 2, 3, ... , 2n の順に積み重なっている. このカードを,次の方法を何回か用いて並べ替える. **整数 k でカット** 上から k 枚のカードの山 A と 残りのカードの山 B に分けた後, 山 A の上に山 B をのせる. **リフルシャッフル** 上から n 枚の山 A と残りの山 B に分け, 上から A の1枚目, B の1枚目, A の2枚目, B の2枚目, …, A の n枚目, B の n枚目, となるようにして, 1 つの山にする. 入力の指示に従い,カードを並び替えたあとのカードの番号を,上から順番に出力するプログラムを作成せよ.
|
n=int(input())
c=list(range(1,1+2*n))
for _ in[0]*int(input()):
k=int(input())
if k:c=c[k:]+c[:k]
else:
for a,b in zip(c[:n],c[n:]):
c+=[a,b]
c=c[2*n:]
print(c,sep='')
|
s360791482
|
Accepted
| 20 | 5,676 | 194 |
from itertools import chain
n=int(input())
c=list(range(2*n))
for _ in[0]*int(input()):
k=int(input())
c=c[k:]+c[:k]if k else list(chain.from_iterable(zip(c[:n],c[n:])))
for x in c:print(x+1)
|
s030320104
|
p02407
|
u688488162
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,704 | 117 |
Write a program which reads a sequence and prints it in the reverse order.
|
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
for i in range(n):
print(a[i],end="")
|
s956795268
|
Accepted
| 40 | 7,700 | 158 |
n = int(input())
a = list(map(int,input().split()))
a.reverse()
for i in range(n):
if i==n-1:
print(a[i])
else:
print(a[i],end=" ")
|
s440698652
|
p03681
|
u581040514
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 3,496 | 409 |
Snuke has N dogs and M monkeys. He wants them to line up in a row. As a Japanese saying goes, these dogs and monkeys are on bad terms. _("ken'en no naka", literally "the relationship of dogs and monkeys", means a relationship of mutual hatred.)_ Snuke is trying to reconsile them, by arranging the animals so that there are neither two adjacent dogs nor two adjacent monkeys. How many such arrangements there are? Find the count modulo 10^9+7 (since animals cannot understand numbers larger than that). Here, dogs and monkeys are both distinguishable. Also, two arrangements that result from reversing each other are distinguished.
|
N, M = map(int, input().split())
if abs(N - M) > 1:
print(0)
elif N == M:
answer = 1
for i in range(1, N+1):
answer = answer * i
for j in range(1, M+1):
answer = answer * j
answer = answer * 2
answer = answer % (1e+9 + 7)
print (answer)
else:
answer = 1
for i in range(1, N+1):
answer = answer * i
for j in range(1, M+1):
answer = answer * j
answer = answer % (1e+9 + 7)
print(answer)
|
s992564637
|
Accepted
| 43 | 3,064 | 381 |
N, M = [int(_) for _ in input().split()]
mod = 10**9+7
if N < M:
N, M = M, N
if N == M:
answer = 1
for i in range(2, N+1):
answer = answer * i
answer = answer % mod
answer = answer**2 * 2 % mod
print (answer)
elif N == M+1:
answer = 1
for i in range(2, M+1):
answer = answer * i
answer = answer % mod
answer = answer**2 * N % mod
print(answer)
else:
print(0)
|
s522421473
|
p03861
|
u638902622
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 267 |
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
|
from sys import stdin
a,b,x = stdin.readline().rstrip().split()
count = 0
a_int = float(a)
b_int = float(b)
x_int = float(x)
count = (b_int / x_int) - (a_int / x_int)
if a_int % x_int == 0:
count += 1
if abs(a_int - b_int) <= 1:
count = 0
result = int(count)
|
s719090764
|
Accepted
| 17 | 3,060 | 181 |
from sys import stdin
a,b,x = stdin.readline().rstrip().split()
count = 0
a_int = int(a)
b_int = int(b)
x_int = int(x)
count = (b_int // x_int) - ((a_int-1) // x_int)
print(count)
|
s245023905
|
p02383
|
u100813820
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,660 | 3,004 |
Write a program to simulate rolling a dice, which can be constructed by the following net. As shown in the figures, each face is identified by a different label from 1 to 6. Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures.
|
# 23-Structure_and_Class-Dice_I.py
# ???????????? I
# Input
# Output
# Constraints
# Note
# Sample Input 1
# 1 2 4 8 16 32
# SE
# Sample Output 1
# 8
# Sample Input 2
# 1 2 4 8 16 32
# EESWN
# Sample Output 2
# 32
class Dice:
def __init__(self, dice_num):
self.side_top=1
self.side_bot=6
self.side_Nor=5
self.side_Eas=3
self.side_Sau=2
self.side_Wes=4
self.dice_num = dice_num
def op_N(self):
self.side_top, self.side_bot, self.side_Nor, self.side_Sau =\
self.side_Sau, self.side_Nor, self.side_top, self.side_bot
def op_E(self):
self.side_top, self.side_bot, self.side_Eas, self.side_Wes =\
self.side_Wes, self.side_Eas, self.side_top, self.side_bot
def op_S(self):
self.side_top, self.side_bot, self.side_Nor, self.side_Sau =\
self.side_Nor, self.side_Sau, self.side_bot, self.side_top
def op_W(self):
self.side_top, self.side_bot, self.side_Eas, self.side_Wes =\
self.side_Eas, self.side_Wes, self.side_bot, self.side_top
def print_side_top(self):
print( dice_num[self.side_top-1] )
def print_side_all(self):
print( "top:{}, bot:{}, Nor:{}, Eas{}, Sau:{}, Wes,{}.".format(self.side_top, self.side_bot, self.side_Nor, self.side_Eas, self.side_Sau, self.side_Wes ) )
dice_num = list( map(int, input().split()))
op = input()
dice_roll = Dice(dice_num)
for i in op:
if i == "N":
dice_roll.op_N()
elif i =="E":
dice_roll.op_E()
elif i =="S":
dice_roll.op_S()
elif i =="W":
dice_roll.op_W()
else:
print("?????°??°")
dice_roll.print_side_all()
dice_roll.print_side_top()
|
s574593583
|
Accepted
| 30 | 7,780 | 4,419 |
# 23-Structure_and_Class-Dice_I.py
# ???????????? I
# Input
# Output
# Constraints
# Note
# Sample Input 1
# 1 2 4 8 16 32
# SE
# Sample Output 1
# 8
# Sample Input 2
# 1 2 4 8 16 32
# EESWN
# Sample Output 2
# 32
#------------------------------------------------------------------------------------------
# class Dice:
# self.side_top=1
# self.side_bot=6
# self.side_Nor=5
# self.side_Eas=3
# self.side_Sau=2
# self.side_Wes=4
# def op_N(self):
# def op_E(self):
# self.side_top, self.side_bot, self.side_Eas, self.side_Wes =\
# self.side_Wes, self.side_Eas, self.side_top, self.side_bot
# def op_S(self):
# def op_W(self):
# self.side_top, self.side_bot, self.side_Eas, self.side_Wes =\
# self.side_Eas, self.side_Wes, self.side_bot, self.side_top
# def print_side_top(self):
# def print_side_all(self):
# else:
#------------------------------------------------------------------------------------------
class Dice:
def __init__(self, dice_num): # 1 2 3 4 5 6
self.dice_state=[1,6,5,3,2,4] #[top, bot, nor, eas, sau, wes]
self.dice_num = dice_num
def op_N(self):
self.dice_state = [ self.dice_state[i-1] for i in [5,3,1,4,2,6] ]
def op_E(self):
self.dice_state = [ self.dice_state[i-1] for i in [6,4,3,1,5,2] ]
def op_S(self):
self.dice_state = [ self.dice_state[i-1] for i in [3,5,2,4,1,6] ]
def op_W(self):
self.dice_state = [ self.dice_state[i-1] for i in [4,6,3,2,5,1] ]
def get_state_top(self):
return self.dice_state[0]
def get_num_top(self):
return self.dice_num[self.dice_state[0]-1]
def print_side_top(self):
print( self.dice_num[self.dice_state[0]-1] )
def print_side_all(self):
print( "top:{}, bot:{}, Nor:{}, Eas{}, Sau:{}, Wes,{}.".format(self.side_top, self.side_bot, self.side_Nor, self.side_Eas, self.side_Sau, self.side_Wes ) )
dice_num = list( map(int, input().split()))
dice_roll = Dice(dice_num)
Func_set = {'N': dice_roll.op_N, 'W': dice_roll.op_W, 'E': dice_roll.op_E, 'S': dice_roll.op_S}
for i in input():
Func_set[i]()
dice_roll.print_side_top()
|
s899872354
|
p03474
|
u247465867
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 178 |
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
|
#2019/10/24
AB, S = open(0).readlines()
# print(AB, S)
A, B = map(int, AB.split())
print('Yes' if S[:A].isdecimal() and S[A]=='-' and S[A+1:].isdecimal() else 'No')
|
s855018001
|
Accepted
| 17 | 2,940 | 227 |
#2019/10/24
# AB, S = open(0).readlines()
# print(AB, S)
# A, B = map(int, AB.split())
A, B = map(int, input().split())
S = input()
print('Yes' if S[:A].isdecimal() and S[A]=='-' and S[A+1:].isdecimal() else 'No')
|
s296695402
|
p02694
|
u615576660
| 2,000 | 1,048,576 |
Wrong Answer
| 22 | 9,168 | 207 |
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
import math
X = int(input())
Takahashi_money =100
num = 0
while Takahashi_money <= X:
Takahashi_money = Takahashi_money * 1.01
Takahashi_money = math.floor(Takahashi_money)
num += 1
print(num)
|
s935089139
|
Accepted
| 22 | 9,168 | 206 |
import math
X = int(input())
Takahashi_money =100
num = 0
while Takahashi_money < X:
Takahashi_money = Takahashi_money * 1.01
Takahashi_money = math.floor(Takahashi_money)
num += 1
print(num)
|
s407091734
|
p02743
|
u143492911
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 290 |
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?
|
import math
# A = [list(map(int, input().split())) for _ in range(3)]
# B = [int(input()) for _ in range(n)]
# X = list(map(int, input().split()))
a, b, c = map(int, input().split())
if math.sqrt(a) + math.sqrt(b) < math.sqrt(c):
print("YES")
else:
print("NO")
|
s027103596
|
Accepted
| 18 | 2,940 | 304 |
# A = [list(map(int, input().split())) for _ in range(3)]
# B = [int(input()) for _ in range(n)]
# X = list(map(int, input().split()))
a, b, c = map(int, input().split())
if c-a-b < 0:
print("No")
else:
if 4*a*b < (c-a-b)**2:
print("Yes")
else:
print("No")
|
s393996762
|
p03478
|
u042347918
| 2,000 | 262,144 |
Wrong Answer
| 90 | 3,628 | 553 |
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).
|
"""
B - Some Sums
"""
ans = 0
N, a, b = map(int, input().split())
def digitSum(n):
d = str(n)
#print(d)
e = list(map(int, d))
#print(e)
f = sum(e)
return f
#print(a, b, n)
for i in range(N+1):
digitSum(i)
if a <= digitSum(i):
if b >= digitSum(i):
print(digitSum(i))
ans += i
print(ans)
|
s330649075
|
Accepted
| 50 | 3,060 | 521 |
"""
B - Some Sums
"""
ans = 0
N, a, b = map(int, input().split())
def digitSum(n):
d = str(n)
#print(d)
e = list(map(int, d))
#print(e)
f = sum(e)
return f
#print(a, b, n)
for i in range(N+1):
digitSum(i)
if a <= digitSum(i) <= b:
ans += i
print(ans)
|
s401468302
|
p03251
|
u687343821
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 239 |
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
|
N,M,X,Y=map(int,input().split(' '))
x_list=list(map(int,input().split(' ')))
y_list=list(map(int,input().split(' ')))
x_max=max(x_list)
y_min=min(y_list)
if((X+1) < Y and (x_max+1) < y_min):
print("No War")
else:
print("War")
|
s125398552
|
Accepted
| 17 | 3,060 | 265 |
N,M,X,Y=map(int,input().split(' '))
x_list=list(map(int,input().split(' ')))
y_list=list(map(int,input().split(' ')))
x_list.append(X)
y_list.append(Y)
x_max=max(x_list)
y_min=min(y_list)
if(X < Y and x_max < y_min):
print("No War")
else:
print("War")
|
s459988870
|
p03455
|
u220612891
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 76 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a = 1
b = 21
c = a*b
if c % 2 == 0:
print("Even")
else:
print("Odd")
|
s892357674
|
Accepted
| 17 | 2,940 | 117 |
s = list(map(int, input().split()))
a = s[0]
b = s[1]
c = a*b
if c % 2 == 0:
print("Even")
else:
print("Odd")
|
s234659063
|
p02393
|
u254455259
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,596 | 117 |
Write a program which reads three integers, and prints them in ascending order.
|
a,b,c=map(int,input().split(" "))
if a>b:
a,b=b,a
elif b>c:
b,c=c,b
print(str(a)+" "+str(b)+" "+str(c))
|
s863186989
|
Accepted
| 20 | 5,600 | 135 |
a,b,c=map(int,input().split(" "))
if a>b:
a,b=b,a
if b>c:
b,c=c,b
if a>b:
a,b=b,a
print(str(a)+" "+str(b)+" "+str(c))
|
s583853883
|
p03471
|
u449514925
| 2,000 | 262,144 |
Wrong Answer
| 540 | 3,060 | 549 |
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
|
# -*- coding: utf-8 -*-
N, Y = map(int, input().split())
#s = input()
#print(s[0:K-1]+s[K-1].lower()+s[K:N])
i=0
j=0
k=0
ans="-1 -1 -1"
sum=0
i=int(Y/10000)
if i<=N:
if i==N:
if Y%10000 ==0:
ans=str(i)+" 0 0"
else:
for j in range(N-i):
for k in range(N-i-j):
sum = 10000*i + 5000*j + 1000*k
if sum==Y:
ans = str(i) + " " + str(j) + " " + str(k)
break
print(ans)
|
s222724627
|
Accepted
| 855 | 3,060 | 416 |
# -*- coding: utf-8 -*-
N, Y = map(int, input().split())
#s = input()
#print(s[0:K-1]+s[K-1].lower()+s[K:N])
i=0
j=0
k=0
ans="-1 -1 -1"
sum=0
for i in range(N+1):
for j in range(N-i+1):
k=N-i-j
sum = 10000*i + 5000*j + 1000*k
if sum==Y:
ans = str(i) + " " + str(j) + " " + str(k)
break
print(ans)
|
s508203544
|
p02608
|
u551058317
| 2,000 | 1,048,576 |
Wrong Answer
| 25 | 9,180 | 591 |
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
N = int(input().strip())
x, y, z = 1, 1, 1
f = [0] * (N+1)
# while x**2 + y**2 + z**2 + x*y + y*z + x*z <= N:
def calc(x, y, z, f):
n = x**2 + y**2 + z**2 + x*y + y*z + x*z
if n <= N:
f[n] += 1
return f
while True:
f = calc(x, y, z, f)
f = calc(x+1, y, z, f)
f = calc(x, y+1, z, f)
f = calc(x, y, z+1, f)
f = calc(x+1, y+1, z, f)
f = calc(x, y+1, z+1, f)
f = calc(x+1, y, z+1, f)
x += 1
y += 1
z += 1
if x**2 + y**2 + z**2 + x*y + y*z + x*z > N:
break
for i in range(1, N+1):
print(f[i])
|
s866254954
|
Accepted
| 265 | 9,404 | 711 |
N = int(input().strip())
x, y, z = 1, 1, 1
f = [0] * (N + 1)
# while x**2 + y**2 + z**2 + x*y + y*z + x*z <= N:
def calc(x, y, z, f, axis="xyz"):
n = x**2 + y**2 + z**2 + x*y + y*z + x*z
if n <= N:
f[n] += 1
if axis == "xyz":
f = calc(x+1, y, z, f, axis="xyz")
f = calc(x, y+1, z, f, axis="yz")
f = calc(x, y, z+1, f, axis="z")
elif axis == "yz":
f = calc(x, y+1, z, f, axis="yz")
f = calc(x, y, z+1, f, axis="z")
elif axis == "z":
f = calc(x, y, z + 1, f, axis="z")
return f
else:
return f
f = calc(x, y, z, f)
for i in range(1, N+1):
print(f[i])
|
s025016971
|
p03860
|
u905582793
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 25 |
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
|
print("A"+input()[0]+"C")
|
s645866809
|
Accepted
| 17 | 2,940 | 37 |
x= list(input())
print("A"+x[8]+"C")
|
s602289883
|
p04030
|
u086172144
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 122 |
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
|
s=list(input())
res=[]
for i in s:
if i=="b":
res=res[:-1]
else:
res.append(i)
print("".join(res))
|
s682523435
|
Accepted
| 17 | 2,940 | 122 |
s=list(input())
res=[]
for i in s:
if i=="B":
res=res[:-1]
else:
res.append(i)
print("".join(res))
|
s011827180
|
p02255
|
u467422569
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,600 | 431 |
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.
|
def trace(A,input_num):
for i in range(input_num):
print(A[i],end = " ")
print("\n")
def insertionSort(A,input_num):
for i in range(input_num):
v = A[i]
j = i - 1
while(j >= 0 and A[j] > v):
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
trace(A,input_num)
input_num = int(input())
A = list(map(int, input().split()))
trace(A,input_num)
|
s004459371
|
Accepted
| 20 | 5,976 | 318 |
def insertionSort(A,input_num):
for i in range(input_num):
v = A[i]
j = i - 1
while(j >= 0 and A[j] > v):
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
print(*A)
input_num = int(input())
A = list(map(int, input().split()))
insertionSort(A,input_num)
|
s065451396
|
p03599
|
u513081876
| 3,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 100 |
Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations. * Operation 1: Pour 100A grams of water into the beaker. * Operation 2: Pour 100B grams of water into the beaker. * Operation 3: Put C grams of sugar into the beaker. * Operation 4: Put D grams of sugar into the beaker. In our experimental environment, E grams of sugar can dissolve into 100 grams of water. Snuke will make sugar water with the highest possible density. The beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker. Find the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it. If there is more than one candidate, any of them will be accepted. We remind you that the sugar water that contains a grams of water and b grams of sugar is \frac{100b}{a + b} percent. Also, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.
|
A, B, C, D, E, F = map(int, input().split())
if A <=B:
print(A*100, 0)
else:
print(B*100, 0)
|
s557982910
|
Accepted
| 2,043 | 12,476 | 650 |
A, B, C, D, E, F = map(int, input().split())
water = []
for a in range(31):
for b in range(31):
if 100 * a * A + 100* b * B <= F:
water.append(100 * a * A + 100 * b * B)
water = list(set(water))
water.remove(0)
sugar = []
for c in range(3001):
for d in range(3001):
if c * C + d * D <= F:
sugar.append(c * C + d * D)
sugar = list(set(sugar))
sugar.remove(0)
memo = []
for w in water:
for s in sugar:
if w + s <= F and s/(w+s) <= E/(100+E):
memo.append([s/(s+w),w+s, s])
memo.sort(reverse=True)
if len(memo) == 0:
print(100 * A, 0)
else:
print(memo[0][1], memo[0][2])
|
s125850915
|
p03369
|
u516554284
| 2,000 | 262,144 |
Wrong Answer
| 19 | 2,940 | 35 |
In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen.
|
s=input()
print(700+3*s.count('o'))
|
s489997558
|
Accepted
| 17 | 2,940 | 38 |
s=input()
print(700+100*s.count('o'))
|
s937824749
|
p03827
|
u414558682
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 190 |
You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).
|
N = int(input())
S = input()
print(N)
print(S)
x = 0
x_list = [0]
for s in S:
print(s)
if s == 'I':
x += 1
elif s == 'D':
x -= 1
x_list.append(x)
print(x_list)
print(max(x_list))
|
s937068667
|
Accepted
| 17 | 2,940 | 198 |
N = int(input())
S = input()
# print(N)
# print(S)
x = 0
x_list = [0]
for s in S:
# print(s)
if s == 'I':
x += 1
elif s == 'D':
x -= 1
x_list.append(x)
# print(x_list)
print(max(x_list))
|
s024906000
|
p03556
|
u556594202
| 2,000 | 262,144 |
Wrong Answer
| 26 | 9,228 | 29 |
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.
|
print(int(int(input())**0.5))
|
s590350152
|
Accepted
| 30 | 9,344 | 35 |
print(int(int(input())**0.5//1)**2)
|
s534979544
|
p02613
|
u118760114
| 2,000 | 1,048,576 |
Wrong Answer
| 161 | 16,528 | 349 |
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())
c0=[]
c1=[]
c2=[]
c3=[]
for i in range(N):
S = input()
if S == "AC":
c0.append(S)
elif S == "WA":
c1.append(S)
elif S == "TLE":
c2.append(S)
elif S == "RE":
c3.append(S)
print("AC ","× ",len(c0))
print("WA ","× ",len(c1))
print("TLE ","× ",len(c2))
print("RE ","× ",len(c3))
|
s658697939
|
Accepted
| 150 | 16,412 | 337 |
N = int(input())
c0=[]
c1=[]
c2=[]
c3=[]
for i in range(N):
S = input()
if S == "AC":
c0.append(S)
elif S == "WA":
c1.append(S)
elif S == "TLE":
c2.append(S)
elif S == "RE":
c3.append(S)
print("AC","x",len(c0))
print("WA","x",len(c1))
print("TLE","x",len(c2))
print("RE","x",len(c3))
|
s641957039
|
p02612
|
u525589885
| 2,000 | 1,048,576 |
Wrong Answer
| 33 | 9,140 | 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)
|
s974484918
|
Accepted
| 30 | 9,088 | 66 |
n = int(input())
import math
a = math.ceil(n/1000)
print(a*1000-n)
|
s527274845
|
p03612
|
u063962277
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 277 |
You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two **adjacent** elements in the permutation. You want to have p_i ≠ i for all 1≤i≤N. Find the minimum required number of operations to achieve this.
|
p = [int(i) for i in input().split()]
l = len(p)
number = [i+1 for i in range(l)]
d = [bool(p[i]-number[i]) for i in range(l)]
d.append(True)
cnt = 0
i = 0
while i < l:
if d[i] == False:
cnt += 1
if d[i+1] == False:
i += 1
i += 1
print(cnt)
|
s390502554
|
Accepted
| 94 | 13,880 | 294 |
n = int(input())
p = [int(i) for i in input().split()]
l = len(p)
number = [i+1 for i in range(l)]
d = [bool(p[i]-number[i]) for i in range(l)]
d.append(True)
cnt = 0
i = 0
while i < l:
if d[i] == False:
cnt += 1
if d[i+1] == False:
i += 1
i += 1
print(cnt)
|
s361997641
|
p03386
|
u980492406
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 204 |
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())
li = []
x = 0
while a + x <= b and b - x >= a and x <= k :
li.append(a+x)
li.append(b-x)
x += 1
se = set(li)
li = list(se)
li.sort()
for i in li :
print(i)
|
s040203910
|
Accepted
| 17 | 3,064 | 206 |
a,b,k = map(int,input().split())
li = []
x = 0
while a + x <= b and b - x >= a and x <= k-1 :
li.append(a+x)
li.append(b-x)
x += 1
se = set(li)
li = list(se)
li.sort()
for i in li :
print(i)
|
s777059981
|
p03069
|
u982630224
| 2,000 | 1,048,576 |
Wrong Answer
| 420 | 14,620 | 250 |
There are N stones arranged in a row. Every stone is painted white or black. A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is `.`, and the stone is black if the character is `#`. Takahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone. Find the minimum number of stones that needs to be recolored.
|
N=int(input())
S=input()
cost=[]
left=0
right=0
for i in range(N):
if S[i]=='#':
right+=1
cost.append(N-right)
for i in range(0,N):
if S[i]=='#':
left+=1
right-=1
print(left,right)
cost.append(left+N-i-1-right)
cost.sort()
print(cost[0])
|
s481566742
|
Accepted
| 165 | 12,168 | 231 |
N=int(input())
S=input()
cost=[]
left=0
right=0
for i in range(N):
if S[i]=='#':
right+=1
cost.append(N-right)
for i in range(0,N):
if S[i]=='#':
left+=1
right-=1
cost.append(left+N-i-1-right)
cost.sort()
print(cost[0])
|
s448139542
|
p02612
|
u485172913
| 2,000 | 1,048,576 |
Wrong Answer
| 31 | 9,180 | 63 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
n=int(input())
if((1000-n)>0):
print(1000-n)
else:
print(0)
|
s094634981
|
Accepted
| 31 | 9,100 | 79 |
n=int(input())
if(n%1000==0):
print(0)
else:
x=n%1000
print(1000-x)
|
s204652055
|
p03044
|
u867848444
| 2,000 | 1,048,576 |
Wrong Answer
| 536 | 38,636 | 422 |
We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied: * For any two vertices painted in the same color, the distance between them is an even number. Find a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.
|
n=int(input())
uvw=[list(map(int,input().split())) for i in range(n-1)]
def Graph(ab):
log=[0]*n
G=[[] for i in range(n)]
for a,b,c in ab:
G[a-1].append(b)
G[b-1].append(a)
if c%2==0:
log[a-1]=1
log[b-1]=1
#up_G[b-1]=a
return log #,up_G
log=Graph(uvw)
print(*log,sep='\n')
|
s650155639
|
Accepted
| 698 | 54,156 | 778 |
def Graph(ab):
G=[[] for i in range(n)]
for a,b,c in ab:
G[a-1].append((b,c%2))
G[b-1].append((a,c%2))
#up_G[b-1]=a
return G #,up_G
from collections import deque
def dfs(G,v,p):
q=deque()
q.append((v,p,0))
ans=[0]*n
while q:
V,P,S=q.pop()
if S==0:
#q.append((V,1))
for new_v,dis in G[V-1]:
if new_v==P:continue
ans[new_v-1]=(ans[V-1]+dis)%2
q.append((new_v,V,0))
return ans
n=int(input())
uvw=[list(map(int,input().split())) for i in range(n-1)]
G=Graph(uvw)
#print(G)
ans=dfs(G,1,-1)
print(*ans,sep='\n')
|
s835078289
|
p03474
|
u265323413
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 293 |
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
|
A, B = map(int, input().split())
chars = list(input())
for i in range(A):
if not chars[i].isdigit():
print("Noa")
exit()
if chars[A] != '-':
print("No")
exit()
for i in range(B):
if not chars[i].isdigit():
print("No")
exit()
print("Yes")
|
s702574785
|
Accepted
| 17 | 2,940 | 158 |
A, B = map(int, input().split())
chars = input()
if chars[A] == '-' and chars[:A].isdigit() and chars[-B:].isdigit():
print("Yes")
else:
print("No")
|
s415628575
|
p02993
|
u094932051
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 231 |
The door of Snuke's laboratory is locked with a security code. The security code is a 4-digit number. We say the security code is _hard to enter_ when it contains two consecutive digits that are the same. You are given the current security code S. If S is hard to enter, print `Bad`; otherwise, print `Good`.
|
while True:
try:
S = input()
for i in range(len(S)-1):
if S[i] == S[i-1]:
print("Bad")
break
else:
print("Good")
except:
break
|
s596595937
|
Accepted
| 17 | 2,940 | 231 |
while True:
try:
S = input()
for i in range(len(S)-1):
if S[i] == S[i+1]:
print("Bad")
break
else:
print("Good")
except:
break
|
s453188896
|
p04029
|
u760391419
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 34 |
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)
|
s282445947
|
Accepted
| 17 | 2,940 | 34 |
N = int(input())
print(N*(N+1)//2)
|
s462259972
|
p03470
|
u680851063
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 72 |
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
|
n = int(input())
l = [int(input(i)) for i in [0]*n]
print(list(set(l)))
|
s735964487
|
Accepted
| 17 | 2,940 | 76 |
n = int(input())
l = [int(input()) for i in [0]*n]
print(len(list(set(l))))
|
s999505641
|
p03574
|
u420522278
| 2,000 | 262,144 |
Wrong Answer
| 30 | 3,064 | 503 |
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())
m = []
for y in range(h):
s = input()
l = []
for i in s:
if i == '#':
l.append(1)
else:
l.append(0)
m.append(l)
print(m)
for y in range(h):
s = ''
for x in range(w):
bomb = 0
for i,j in ((-1,-1),(-1,0),(-1,1),(0,-1),(0,1),(1,-1),(1,0),(1,1)):
if y+j < 0 or x+i < 0 or x+i >= w or y+j >= h:
continue
if m[y+j][x+i] == 1:
bomb += 1
if m[y][x] == 1:
bomb = '#'
s += str(bomb)
print(s)
|
s959091978
|
Accepted
| 30 | 3,064 | 494 |
h,w = map(int, input().split())
m = []
for y in range(h):
s = input()
l = []
for i in s:
if i == '#':
l.append(1)
else:
l.append(0)
m.append(l)
for y in range(h):
s = ''
for x in range(w):
bomb = 0
for i,j in ((-1,-1),(-1,0),(-1,1),(0,-1),(0,1),(1,-1),(1,0),(1,1)):
if y+j < 0 or x+i < 0 or x+i >= w or y+j >= h:
continue
if m[y+j][x+i] == 1:
bomb += 1
if m[y][x] == 1:
bomb = '#'
s += str(bomb)
print(s)
|
s435934330
|
p03623
|
u434872492
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 72 |
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
|
x,a,b = map(int,input().split())
ans = min(abs(x-a),abs(x-b))
print(ans)
|
s169178995
|
Accepted
| 17 | 2,940 | 90 |
x,a,b = map(int,input().split())
if abs(x-a)<abs(x-b):
print("A")
else:
print("B")
|
s523419584
|
p03192
|
u026155812
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 87 |
You are given an integer N that has exactly four digits in base ten. How many times does `2` occur in the base-ten representation of N?
|
N = input()
num=0
for i in range(len(N)):
if N[i] ==2:
num += 1
print(num)
|
s389887838
|
Accepted
| 17 | 2,940 | 107 |
N = input().strip()
num=0
for i in range(len(N)):
if N[i] == '2':
num += 1
print(num)
|
s149523235
|
p03050
|
u229621546
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 14 |
Snuke received a positive integer N from Takahashi. A positive integer m is called a _favorite number_ when the following condition is satisfied: * The quotient and remainder of N divided by m are equal, that is, \lfloor \frac{N}{m} \rfloor = N \bmod m holds. Find all favorite numbers and print the sum of those.
|
1000000000000
|
s701277711
|
Accepted
| 115 | 3,424 | 335 |
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5)+1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n//i)
return sorted(divisors,reverse=True)
N = int(input())
div = make_divisors(N)
ans = [(a - 1) for a in div if a > 1 and N % (a - 1) == N // (a - 1)]
print(sum(ans))
|
s311666399
|
p02743
|
u115110170
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,060 | 74 |
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?
|
a,b,c = map(lambda x:int(x)**0.5,input().split())
print('YNeos'[a+b<c::2])
|
s662693977
|
Accepted
| 17 | 2,940 | 101 |
a,b,c = map(int,input().split())
if c-a-b>0 and 4*a*b<(c-a-b)**2:
print("Yes")
else:
print("No")
|
s071160817
|
p00045
|
u868716420
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,528 | 255 |
販売単価と販売数量を読み込んで、販売金額の総合計と販売数量の平均を出力するプログラムを作成してください。
|
Sum, Ave, Cou = 0, 0, 0
while True :
try :
a, b = input().split(',')
Sum += int(a) * int(b)
Ave += int(b)
Cou += 1
except : break
if Ave / Cou - Ave // Cou > 0.5 : print(Sum, Ave // Cou+1)
else : print(Sum,Ave//Cou)
|
s682938297
|
Accepted
| 30 | 7,640 | 258 |
Sum, Ave, Cou = 0, 0, 0
while True :
try :
a, b = input().split(',')
Sum += int(a) * int(b)
Ave += int(b)
Cou += 1
except : break
print(Sum)
if Ave / Cou - Ave // Cou >= 0.5 : print(Ave // Cou+1)
else : print(Ave//Cou)
|
s040111997
|
p03476
|
u001024152
| 2,000 | 262,144 |
Time Limit Exceeded
| 2,104 | 3,828 | 442 |
We say that a odd number N is _similar to 2017_ when both N and (N+1)/2 are prime. You are given Q queries. In the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.
|
# D
prime_num = set([2])
size = int(1e5)*2+1
for i in range(3,size,2):
for p in prime_num:
if i%p==0: break
else: continue
else:
prime_num.add(i)
cnt = [0]*(int(1e5)+2)
for p in prime_num:
if p<=int(1e5) and (p+1)//2 in prime_num:
cnt[p] = 1
for i in range(1, int(1e5)+2):
cnt[i] += cnt[i-1]
Q = int(input())
for _ in range(Q):
l,r = map(int, input().split())
print(cnt[r]-cnt[l])
|
s160078583
|
Accepted
| 259 | 14,792 | 677 |
# D
from math import sqrt
def sieve(n:int)->list:
if n<2: return [False]*(n+1)
is_prime = [True]*(n+1)
is_prime[0] = False
is_prime[1] = False
for i in range(2, int(sqrt(n))+1):
if is_prime[i]:
for j in range(i*i, n+1, i):
is_prime[j] = False
return is_prime
N = int(1e5)
is_prime = sieve(N)
# like-2017
cnt = [0]*(N+1)
for i in range(1, N+1):
cnt[i] += cnt[i-1]
if is_prime[i] and is_prime[(i+1)//2]:
cnt[i] += 1
import sys
Q = sys.stdin.readline()
for l,r in (map(int, line.split()) for line in sys.stdin.readlines()):
print(cnt[r] - cnt[l-1])
|
s780810478
|
p02607
|
u070630744
| 2,000 | 1,048,576 |
Wrong Answer
| 34 | 10,408 | 333 |
We have N squares assigned the numbers 1,2,3,\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i. How many squares i satisfy both of the following conditions? * The assigned number, i, is odd. * The written integer is odd.
|
import math
import collections
import fractions
import itertools
import functools
import operator
def solve():
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in a:
if i+1 % 2 == 0 and a[i] % 2 == 0:
ans += 1
print(ans)
return 0
if __name__ == "__main__":
solve()
|
s369910318
|
Accepted
| 46 | 10,332 | 342 |
import math
import collections
import fractions
import itertools
import functools
import operator
def solve():
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
if (i+1) % 2 == 1 and a[i] % 2 == 1:
ans += 1
print(ans)
return 0
if __name__ == "__main__":
solve()
|
s762780931
|
p03693
|
u773686010
| 2,000 | 262,144 |
Wrong Answer
| 27 | 9,084 | 74 |
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?
|
N = int("".join(map(str,input().split())))
print(("No","Yes")[N % 4 == 0])
|
s875675273
|
Accepted
| 21 | 9,020 | 74 |
N = int("".join(map(str,input().split())))
print(("NO","YES")[N % 4 == 0])
|
s776741070
|
p03564
|
u168416324
| 2,000 | 262,144 |
Wrong Answer
| 27 | 9,024 | 91 |
Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value: * Operation A: The displayed value is doubled. * Operation B: The displayed value increases by K. Square1001 needs to perform these operations N times in total. Find the minimum possible value displayed in the board after N operations.
|
n=int(input())
k=int(input())
ans=1
for i in range(n):
ans=max(ans+k,ans*2)
print(ans)
|
s713881946
|
Accepted
| 26 | 9,160 | 92 |
n=int(input())
k=int(input())
ans=1
for i in range(n):
ans=min(ans+k,ans*2)
print(ans)
|
s490671671
|
p03388
|
u380524497
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 353 |
10^{10^{10}} participants, including Takahashi, competed in two programming contests. In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th. The _score_ of a participant is the product of his/her ranks in the two contests. Process the following Q queries: * In the i-th query, you are given two positive integers A_i and B_i. Assuming that Takahashi was ranked A_i-th in the first contest and B_i-th in the second contest, find the maximum possible number of participants whose scores are smaller than Takahashi's.
|
q = int(input())
for _ in range(q):
R = list(map(int, input().split()))
a, b = min(R), max(R)
if b - a <= 1:
res = 2 * (a-1)
else:
c = int((a*b)**0.5)
if c ** 2 == a * b:
c -= 1
if c * (c+1) < a * b:
res = 2 * (c-1) + 1
else:
res = 2 * (c-1) - 1
print(res)
|
s337231591
|
Accepted
| 18 | 3,188 | 349 |
q = int(input())
for _ in range(q):
R = list(map(int, input().split()))
a, b = min(R), max(R)
if b - a <= 1:
res = 2 * (a-1)
else:
c = int((a*b)**0.5)
if c ** 2 == a * b:
c -= 1
if c * (c+1) < a * b:
res = 2 * (c-1) + 1
else:
res = 2 * (c-1)
print(res)
|
s029612237
|
p03546
|
u551909378
| 2,000 | 262,144 |
Wrong Answer
| 30 | 3,516 | 660 |
Joisino the magical girl has decided to turn every single digit that exists on this world into 1. Rewriting a digit i with j (0≤i,j≤9) costs c_{i,j} MP (Magic Points). She is now standing before a wall. The wall is divided into HW squares in H rows and W columns, and at least one square contains a digit between 0 and 9 (inclusive). You are given A_{i,j} that describes the square at the i-th row from the top and j-th column from the left, as follows: * If A_{i,j}≠-1, the square contains a digit A_{i,j}. * If A_{i,j}=-1, the square does not contain a digit. Find the minimum total amount of MP required to turn every digit on this wall into 1 in the end.
|
H,W = map(int, input().split())
c, A = [], []
num = [0] * 10
for _ in range(10):
ci = list(map(int, input().split()))
ci[0], ci[1] = ci[1], ci[0]
c.append(ci)
for _ in range(H):
A += list(map(int, input().split()))
for i in [0] + list(range(2, 10)):
num[i] += A.count(i)
c = [[0]] + c[:1] + c[2:]
num[0], num[1] = num[1], num[0]
dp = [[10000 for i in range(10)] for j in range(10)]
dp[1][1] = c[1][0]
for i in range(2, 10):
dp[i][i] = min(c[i][0], min(c[i][j] + dp[i-1][j] for j in range(i-1, 0, -1)))
for j in range(1, i):
dp[i][j] = min(dp[i-1][j], c[j][i] + dp[i][i])
print(sum(dp[9][i] * num[i] for i in range(1,10)))
|
s642024502
|
Accepted
| 30 | 3,508 | 608 |
H,W = map(int, input().split())
c, A = [], []
num = [0] * 10
for _ in range(10):
ci = list(map(int, input().split()))
ci[0], ci[1] = ci[1], ci[0]
c.append(ci)
for _ in range(H):
A += list(map(int, input().split()))
for i in [0] + list(range(2, 10)):
num[i] += A.count(i)
c = [[0]] + c[:1] + c[2:]
num[0], num[1] = num[1], num[0]
dp = [[c[i][0] for i in range(10)]] + [[10000 for i in range(10)] for j in range(9)]
for i in range(1, 10):
for j in range(1, 10):
dp[i][j] = min(c[j][k] + dp[i-1][k] for k in range(1, 10))
print(sum(dp[9][i] * num[i] for i in range(1,10)))
|
s246366175
|
p04030
|
u068584789
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 139 |
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
|
keys = input()
r = ''
for k in keys:
if k == 0:
r += '0'
elif k == '1':
r += '1'
elif k == 'b':
r = r[:len(r)-1]
print(r)
|
s881588026
|
Accepted
| 17 | 2,940 | 141 |
keys = input()
r = ""
for k in keys:
if k == "0":
r += "0"
elif k == "1":
r += "1"
elif k == "B":
r = r[:len(r)-1]
print(r)
|
s792756020
|
p04029
|
u727787724
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 35 |
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())
a=n*(n+1)/2
print(a)
|
s528757807
|
Accepted
| 17 | 2,940 | 40 |
n=int(input())
a=int(n*(n+1)/2)
print(a)
|
s118711381
|
p03455
|
u448922807
| 2,000 | 262,144 |
Wrong Answer
| 28 | 9,084 | 91 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a,b = map(int, input().split())
if((a*b)%2 == 0):
print('Odd')
else:
print('Even')
|
s515927875
|
Accepted
| 28 | 9,092 | 91 |
a,b = map(int, input().split())
if((a*b)%2 == 0):
print('Even')
else:
print('Odd')
|
s144808658
|
p03457
|
u546417841
| 2,000 | 262,144 |
Wrong Answer
| 942 | 3,444 | 585 |
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=input()
N=int(N)
flag=True
tk=0
xk,yk=0,0
for i in range(N):
txy=input()
t,x,y=txy.split()
t=int(t)
x=int(x)
y=int(y)
if abs(t-tk) >= abs(x-xk)+abs(y-yk):
if (abs(t-tk)+abs(x-xk)+abs(y-yk))%2==0:
print('Yes')
flag=True
else:
print('No')
flag=False
else:
print('No')
flag=False
tk=tk+t
xk=xk+x
yk=yk+y
if not flag:
break
|
s514525264
|
Accepted
| 396 | 3,064 | 553 |
N=input()
N=int(N)
flag=True
tk=0
xk=0
yk=0
for i in range(N):
txy=input()
t,x,y=txy.split()
t=int(t)
x=int(x)
y=int(y)
if abs(t-tk) >= abs(x-xk)+abs(y-yk):
if (abs(t-tk)+abs(x-xk)+abs(y-yk))%2==0:
flag=True
else:
flag=False
else:
flag=False
tk=t
xk=x
yk=y
if not flag:
print('No')
break
if flag:
print('Yes')
|
s086135961
|
p03567
|
u163320134
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 125 |
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()
flag=False
for i in range(len(s)-1):
if s[i:i+1]=='AC':
flag=True
if flag:
print('Yes')
else:
print('No')
|
s895246844
|
Accepted
| 17 | 2,940 | 126 |
s=input()
flag=False
for i in range(len(s)-1):
if s[i:i+2]=='AC':
flag=True
if flag:
print('Yes')
else:
print('No')
|
s349081833
|
p03971
|
u531813944
| 2,000 | 262,144 |
Wrong Answer
| 103 | 4,040 | 427 |
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these. Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests. * A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B. * An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students. A string S is assigned indicating attributes of all participants. If the i-th character of string S is `a`, this means the participant ranked i-th in the Qualification contests is a Japanese student; `b` means the participant ranked i-th is an overseas student; and `c` means the participant ranked i-th is neither of these. Write a program that outputs for all the participants in descending rank either `Yes` if they passed the Qualification contests or `No` if they did not pass.
|
from sys import stdin
n, a, b = [int(x) for x in stdin.readline().strip().split()]
s = stdin.readline()
a = a + b
all_num = 0
oversea_num = 0
for t in s:
if t == 'a':
if all_num < a:
print('Yes')
all_num += 1
else:
print('No')
elif t == 'b':
if oversea_num < b and all_num < a:
print('Yes')
all_num += 1
oversea_num += 1
else:
print('No')
else:
print('No')
|
s153265609
|
Accepted
| 104 | 4,016 | 335 |
N, A, B = map(int, input().split())
S = input()
clears = 0
clears_foreigner = 0
for s in S:
if s == "a" and clears < A + B:
print("Yes")
clears += 1
elif s == "b" and clears < A + B and clears_foreigner < B:
print("Yes")
clears += 1
clears_foreigner += 1
else:
print("No")
|
s088020640
|
p03557
|
u074220993
| 2,000 | 262,144 |
Wrong Answer
| 2,206 | 29,396 | 266 |
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 = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
ans = 0
for a in A:
B_a = [b > a for b in B]
for b in B_a:
C_b = [c > b for c in C]
ans += len(C_b)
print(ans)
|
s770780045
|
Accepted
| 247 | 29,056 | 364 |
import bisect as bs
def main():
with open(0) as f:
N = int(f.readline())
A = sorted(list(map(int, f.readline().split())))
B = list(map(int, f.readline().split()))
C = sorted(list(map(int, f.readline().split())))
ans = 0
for b in B:
ans += bs.bisect_left(A, b) * (N-bs.bisect_right(C, b))
print(ans)
main()
|
s166827928
|
p02601
|
u087118202
| 2,000 | 1,048,576 |
Wrong Answer
| 28 | 9,196 | 252 |
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())
d=k
for i in range(k):
if b < a:
b = b*2
if b > a:
d=d-k
break;
for i in range(d):
if c < b:
c = c*2
if c > b:
break;
if a < b and b < c:
print('Yes')
else:
print('No')
|
s072899234
|
Accepted
| 28 | 9,188 | 179 |
a,b,c = map(int, input().split())
k=int(input())
count=0
while a >= b:
b *= 2
count+=1
while b >= c:
c *=2
count+=1
if count <= k:
print('Yes')
else:
print('No')
|
s667691491
|
p03487
|
u075303794
| 2,000 | 262,144 |
Wrong Answer
| 135 | 18,092 | 395 |
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.
|
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
a = list(map(int, read().split()))
dic = {}
ans = 0
for i in range(n):
ans += 1
try:
dic[a[i]] += 1
if dic[a[i]] == a[i]:
ans -= a[i]
except KeyError:
dic[a[i]] = 1
if dic[a[i]] == a[i]:
ans -= a[i]
print(dic)
print(ans)
|
s797390891
|
Accepted
| 109 | 18,220 | 384 |
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
a = list(map(int, read().split()))
dic = {}
ans = 0
for i in range(n):
ans += 1
try:
dic[a[i]] += 1
if dic[a[i]] == a[i]:
ans -= a[i]
except KeyError:
dic[a[i]] = 1
if dic[a[i]] == a[i]:
ans -= a[i]
print(ans)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.