problem_id stringclasses 428
values | submission_id stringlengths 10 10 | status stringclasses 2
values | code stringlengths 5 816 |
|---|---|---|---|
p03951 | s421474349 | Accepted | import sys
input = lambda : sys.stdin.readline().rstrip()
n = int(input())
s = input()
t = input()
ans = 10**10
for i in range(n - 1, -1, -1):
if s[i:] == t[:n-i]:
if len(s) + len(t[n-i:]) >= n:
ans = min(ans, len(s) + len(t[n-i:]))
if len(s) + len(t) >= n:
ans = min(ans, len(s) + len(t))
if ans == 10**10:
print(n)
else:
print(ans) |
p03487 | s763952760 | Accepted | n=int(input());a=list(map(int,input().split()));d={}
for i in a:
if i not in d: d[i]=1
else: d[i]+=1
print(sum([j if i>j else j-i for i,j in d.items()])) |
p03760 | s725812924 | Accepted | o = input()
e = input()
s = len(o)
t = len(e)
ans = ""
for i in range(s):
ans += o[i]
if s-t == 1 and i == s-1: break
ans += e[i]
print(ans) |
p03861 | s998144898 | Wrong Answer | a,b,x = map(int, input().split())
ax = max(0,(a-1)//x)
bx = b//x
#print(ax)
#print(bx)
print(bx-ax) |
p02994 | s906130635 | Accepted | # 131 B
n, l = map(int, input().split())
cmin = float('inf')
sum = 0
for i in range(1, n+1):
f = l + i - 1
sum += f
if cmin >= 0:
cmin = min(cmin, f)
else:
cmin = max(cmin, f)
print(sum - cmin) |
p03803 | s249796732 | Accepted | a, b = map(int,input().split())
if a == 1:
if a < b:
print('Alice')
else:
print('Draw')
elif b == 1:
if a > b:
print('Bob')
else:
print('Draw')
else:
if a < b:
print('Bob')
elif a > b:
print('Alice')
else:
print('Draw') |
p03804 | s018060720 | Accepted | n, m = map(int, input().split())
a = [[i for i in input()] for j in range(n)]
b = [[i for i in input()] for j in range(m)]
def match(y,x):
result = True
for i in range(m):
for j in range(m):
if a[y+i][x+j] != b[i][j]:
result = False
return result
flg = False
for i in range(n-m+1):
for j in range(n-m+1):
if match(i,j):
flg = True
print('Yes' if flg else 'No') |
p03607 | s369636413 | Wrong Answer | n = int(input())
a = [int(input()) for i in range(n)]
import collections
b = collections.Counter(a)
set_a = set(a)
cnt = 0
for i in range(len(a)):
if b[a[i]]%2 == 1:
cnt += 1
print(cnt) |
p02600 | s893979133 | Accepted | n = int(input())
print(10-n//200) |
p03804 | s986083322 | Wrong Answer | N, M = map(int, input().split())
a_li = [input() for i in range(N)]
b_li = [input() for i in range(M)]
for i in range(N - M):
for j in range(N - M) :
for k in range(M) :
if a_li[i + k][j : j + M] != b_li[k] :
break
if k == M - 1:
print("Yes")
exit()
print("No")
|
p02970 | s141238783 | Wrong Answer | import math
x,y =map(int,input().split())
print(math.ceil(x/((y*y)+1))) |
p02639 | s864267759 | Accepted | x=list(map(int,input().split()))
print(x.index(0)+1) |
p02959 | s781782713 | Wrong Answer | n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
p = 0
result = 0
for i in range(n):
p += b[i]
if a[i] < p:
result += a[i]
p -= a[i]
else:
result += p
p = 0
if a[n] < p:
result += a[n]
else:
result += p
print(result) |
p02661 | s852350799 | Accepted | def main():
n = int(input())
a = [None]*n
b = [None]*n
for i in range(n):
a[i],b[i] = map(int, input().split())
a.sort()
b.sort()
if n&1:
print(b[n//2]-a[n//2]+1)
else:
print(b[n//2-1]+b[n//2]-a[n//2]+1-a[n//2-1])
if __name__ == "__main__":
main() |
p03261 | s854570670 | Accepted | """
author : halo2halo
date : 23, Jan, 2020
"""
import sys
# import itertools
# import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
N = int(readline())
W = read().decode('utf8').split()
temp = W[0][-1]
Ws = set(W)
f = True
if len(Ws) != N:
f = False
else:
for w in W[1:]:
if temp == w[0]:
temp = w[-1]
else:
f = False
break
print("Yes" if f else "No")
|
p02640 | s198077852 | Accepted | X,Y = map(int,input().split())
if X*4 < Y or X*2 > Y:
print("No")
else:
if Y == X*2:
print("Yes")
else:
if (Y-X*2)%2==0:
print('Yes')
elif (Y-X*2)%2!=0:
print('No') |
p02813 | s067899165 | Wrong Answer | from itertools import permutations
n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
a = -1
b = -1
count = 0
for per in permutations(range(1,n+1)):
count += 1
arr = [i for i in per]
if arr==p:
a = count
elif arr==q:
b = count
print(abs(a-b)) |
p03997 | s121717484 | Accepted | a,b,h=[int(input()) for _ in range(3)]
print((a+b)*h//2)
|
p04034 | s890780495 | Accepted | n,m = map(int,input().split())
balls = [1 for _ in range(n)]
red = [1] + [0 for _ in range(1,n)]
for _ in range(m):
x, y = map(int,input().split())
x,y = x-1, y-1
if balls[x] ==0:
continue
balls[x] -= 1
balls[y] += 1
if red[x]:
red[y] = 1
if balls[x]==0:
red[x] = 0
print(sum(red))
|
p02777 | s236580417 | Accepted |
s, t = [x for x in input().split()]
a, b = [int(x) for x in input().split()]
u = input()
if u == s:
a = a-1
if u == t:
b = b-1
print(a, b)
|
p02615 | s567551660 | Accepted | N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
res = 0
if N % 2 == 0:
r = N // 2
for i in range(r):
res += A[i] * 2
print(res - A[0])
else:
r = N // 2 + 1
for i in range(r):
res += A[i] * 2
print(res - A[0] - A[r - 1])
|
p03617 | s238071382 | Accepted | # coding: utf-8
# Your code here!
q,h,s,d = map(int,input().split())
N=int(input())
x=min(q*8,h*4,s*2,d)#2Lあたりの値段
y=min(q*4,h*2,s)
if N % 2 == 0:
ans = x * (N//2)
else:
ans = x * (N // 2)
ans += y
print(ans) |
p04033 | s254267156 | Accepted | a, b = map(int, input().split())
if a < 0 and b < 0:
print("Positive") if (b - a + 1) % 2 == 0 else print("Negative")
elif a < 0 and b >= 0:
print("Zero")
else:
print("Positive")
|
p02789 | s138278680 | Accepted | N, M = map(int, input().split(" "))
if N == M:
print("Yes")
else:
print("No") |
p02645 | s130584660 | Accepted | s = input()
print(s[:3])
|
p03339 | s551965643 | Accepted | N = int(input())
S = input()
w = [0] * (N+1)
e = [0] * (N+1)
for i in range(N):
if S[i] == 'W':
w[i+1] = w[i] + 1
e[i+1] = e[i]
if S[i] == 'E':
e[i+1] = e[i] + 1
w[i+1] = w[i]
ans = 10 ** 6
for i in range(N):
ans = min(ans, w[i] + e[N] - e[i + 1])
print(ans) |
p03289 | s221432823 | Accepted | import sys
s = input()
state = False
if s[0] != "A":
print("WA")
sys.exit()
cnt = 0
for i in range(2,len(s)-1):
if s[i] == "C":
cnt +=1
if cnt != 1:
print("WA")
sys.exit()
for i in range(len(s)):
if s[i] == "A":
continue
elif s[i] == "C":
continue
elif s[i].islower():
continue
else:
print("WA")
sys.exit()
print("AC") |
p03106 | s083429311 | Accepted | a, b, k = map(int, input().split())
cnt = 0
for i in reversed(range(1, 101)):
if a%i==0 and b%i==0:
cnt += 1
if cnt == k:
print(i)
break |
p02548 | s110271697 | Accepted | #import numpy as np
(N, ) = [int(n) for n in input().split()]
ans = 0
for i in range(1, N):
ans += (N-1) // i
print(ans)
|
p02796 | s864631705 | Wrong Answer | n=int(input())
l=[input().split() for i in range(n)]
l=[[int(i) for i in j] for j in l]
l.sort()
left=[]
right=[]
count=1
for i in range(len(l)):
left.append(l[i][0]-l[i][1])
right.append(l[i][0]+l[i][1])
if len(right)>1:
if left[-1]<right[-2]:
right=right[:(-1)]
left=left[:(-1)]
else:
count+=1
print(count) |
p02556 | s333960380 | Accepted | n = int(input())
l = [0]*n
k = [0]*n
for i in range(n):
x,y = map(int,input().split())
l[i]=x+y
k[i]=x-y
print(max(abs(max(l)-min(l)), abs(min(l)-max(l)), abs(max(k)-min(k)), abs(min(k)-max(k)))) |
p03803 | s285172519 | Accepted | A,B=map(int,input().split())
if A==1:
A=A+13
if B==1:
B=B+13
if A>B:
print('Alice')
elif A<B:
print('Bob')
else:
print('Draw') |
p02882 | s914791197 | Accepted | from math import atan, degrees
a, b, x = map(int, input().split())
rad = atan(2*(b/a-x/(a**3))) if x>=(a**2)*b/2 else atan(a*(b**2)/2/x)
print(degrees(rad)) |
p02624 | s890112307 | Wrong Answer | N = int(input())
furui = [1]*(N+1)
ans = 0
for i in range(2, N+1):
k = i
while k < N:
furui[k] += 1
k += i
ans += furui[i]*i
print(ans)
|
p02582 | s153863443 | Wrong Answer | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def main():
S = input()
mx = 0
cnt = 0
pre = 'R'
for i in range(len(S)):
if (S[i] == 'R') and (pre == 'R'):
cnt += 1
else:
cnt = 0
pre = 'S'
mx = max(cnt, mx)
print(mx)
if __name__ == '__main__':
main()
|
p03943 | s266532983 | Accepted | A, B, C = map(int, input().split())
if A+B == C or A+C == B or A == B+C:
print('Yes')
else:
print('No') |
p03486 | s743615698 | Accepted | s = sorted(input())
t = sorted(input(),reverse = True)
if s < t:
print('Yes')
else:
print('No') |
p03481 | s310465194 | Accepted | def main():
X, Y = (int(i) for i in input().split())
ans = 0
while X <= Y:
ans += 1
X *= 2
print(ans)
if __name__ == '__main__':
main()
|
p02578 | s146699499 | Accepted | def main():
N = int(input())
A = list(map(int, input().split()))
m = A[0]
S = 0
for a in A:
if m - a > 0:
S += m - a
if m < a:
m = a
print(S)
if __name__ == "__main__":
main()
|
p02705 | s301321633 | Wrong Answer | N = int(input())
print(N*3.141592) |
p02766 | s097880993 | Accepted | def resolve():
N, K = list(map(int, input().split()))
cnt = 1
while N >= K**cnt:
cnt += 1
print(cnt)
if '__main__' == __name__:
resolve() |
p03208 | s277811107 | Accepted | n, k = map(int, input().split())
h = sorted([int(input()) for x in range(n)])
d = 10**9
for i in range(n-k+1):
d = min(d, h[i+k-1] - h[i])
if d == 0:
break
print(d)
|
p02747 | s508108684 | Accepted | S = input()
if len(S) % 2 == 0 and S.count('hi') == len(S)//2:
print('Yes')
else:
print('No') |
p04005 | s896034333 | Accepted | a,b,c=map(int,input().split())
A = b*c*(a-(a//2)*2)
B = c*a*(b-(b//2)*2)
C = a*b*(c-(c//2)*2)
print(min(A,B,C))
|
p03106 | s688281993 | Wrong Answer | a,b,k=map(int,input().split())
i=0
while(k):
i+=1
if max(a%i,b%i):
pass
else:
k-=1
print(i) |
p03351 | s664440501 | Accepted | a,b,c,d=map(int,input().split())
if abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d):
print('Yes')
else:
print('No') |
p03723 | s841258475 | Accepted | A,B,C=map(int,input().split())
cnt=0
lp=0
ls=set()
a=A
b=B
c=C
ls.add((a,b,c))
while not(a%2==1 or b%2==1 or c%2==1 or lp==1):
a=int((A+B+C-a)/2)
b=int((A+B+C-b)/2)
c=int((A+B+C-c)/2)
cnt+=1
if ((a,b,c) in ls):
lp=1
if lp==1:
print(-1)
else:
print(cnt) |
p03836 | s693241485 | Accepted | sx,sy,tx,ty = map(int, input().split())
dx=tx-sx
dy=ty-sy
s='R'*dx+'U'*dy+'L'*dx+'D'*dy+'L'+'U'*(dy+1)+'R'*(dx+1)+'D'+'R'+'D'*(dy+1)+'L'*(dx+1)+'U'
print(s) |
p03360 | s762380003 | Wrong Answer | # abc096_b.py
A = list(map(int,input().split()))
A.sort(reverse=True)
N = int(input())
ans = 0
for i,v in enumerate(A):
if i == 0:
ans += v*2*N
else:
ans += v
print(ans) |
p03254 | s955327573 | Accepted | N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
count = 0
for i in range(len(a)):
if x - a[i] >= 0:
x -= a[i]
count += 1
else:
break
if count == N and x > 0:
print(count - 1)
else:
print(count) |
p03319 | s284654038 | Accepted | N, K = map(int, input().split())
A = [-1] + list(map(int, input().split()))
if (N - 1) % (K - 1):
print((N - 1) // (K - 1) + 1)
else:
print((N - 1) // (K - 1))
|
p03524 | s368017804 | Accepted | import collections
s = list(input())
tmp = len(set(s))
c = collections.Counter(s).most_common()
if (c[0][1] >= c[-1][1] + 2 and tmp == 3) or (tmp == 2 and len(s) > 2) or (tmp == 1 and len(s) != 1):
print('NO')
else:
print('YES')
|
p02959 | s095494310 | Accepted | n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt=0
for i in range(n):
if a[i]<=b[i]:
cnt+=a[i]
b[i]-=a[i]
if a[i+1]<=b[i]:
cnt+=a[i+1]
a[i+1]=0
else:
cnt+=b[i]
a[i+1]-=b[i]
else:
cnt+=b[i]
print(cnt)
|
p03836 | s352869526 | Wrong Answer | sx, sy, tx, ty = map(int,input().split())
dx = (tx - sx)
dy = (ty - sy)
s = 'U' * dy + 'R' * dx
s += 'D' * dy + 'L' * dx
s += 'L' + 'U' * (dy+1) + 'R' * (dx+2)
s += 'R' + 'D' * (dy+1) + 'L' * (dx+2)
print(s)
|
p03105 | s620977817 | Wrong Answer | a,b,c=list(map(int,input().split()))
count=0
while(a<=b):
a-=b
if count==c:
break
count+=1
print(count) |
p02696 | s860029430 | Accepted | import math
a, b, n = list(map(int, input().split()))
x = min(b-1,n)
ans = math.floor(a*x/b)-a*math.floor(x/b)
print(ans) |
p04045 | s730201038 | Accepted | n,k=map(int,input().split())
l=list(map(int,input().split()))
s=str(n)
flag=False
while flag==False:
flag=True
for j in l:
if s.count(str(j))!=0:
s=int(s)
s+=1
s=str(s)
flag=False
break
print(s) |
p02675 | s087651125 | Accepted | n = input()
if n[-1] == '3':
print("bon")
elif n[-1] in ["0", "1", "6", "8"]:
print("pon")
else:
print("hon")
|
p03011 | s175341907 | Accepted | # A - Airplane
# https://atcoder.jp/contests/abc129/tasks/abc129_a
ABC = list(map(int, input().split()))
ABC.sort()
print(ABC[0] + ABC[1])
|
p02783 | s864628729 | Wrong Answer | h,a = map(int,input().split())
if h%a==0:
print(h//a)
else:
print(h//a) |
p03720 | s869116644 | Wrong Answer | import numpy as np
N, M = map(int, input().split())
c = []
for _ in range(M):
a, b= map(int, input().split())
c.append(a)
c.append(b)
C = np.zeros((max(c),1),dtype = 'int')
for i in range(len(C)):
C[i,0] = c.count(i+1)
print(C) |
p02993 | s149612543 | Accepted | import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
s = S()
ans = 'Good'
tmp = ''
for c in s:
if tmp == c:
ans = 'Bad'
tmp = c
print(ans) |
p02847 | s004095225 | Accepted | S = input()
if S == "SUN":
print(7)
elif S == "MON":
print(6)
elif S == "TUE":
print(5)
elif S == "WED":
print(4)
elif S == "THU":
print(3)
elif S == "FRI":
print(2)
else:
print(1) |
p03408 | s935806992 | Accepted | from operator import itemgetter
n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for i in range(m)]
d=dict()
for i in range(n):
if s[i] not in d:
d[s[i]]=1
else:
d[s[i]]+=1
for i in range(m):
if t[i] in d:
d[t[i]]-=1
d=sorted(list(d.items()),reverse=True,key=itemgetter(1))
if d[0][1]>0:
print(d[0][1])
else:
print(0) |
p03854 | s548708502 | Wrong Answer | s = input()
flag = 0
while(len(s)>0):
if (s[:6] == 'eraser'):
s = s[6:]
elif (s[:5] == 'erase'):
s = s[5:]
elif (s[:5] == 'dream'):
if (s[5:8] == 'ere' or s[5:8] == 'erd'):
s = s[7:]
else:
s = s[5:]
else:
flag = 1
break
if (flag == 0):
print('Yes')
else:
print('No') |
p02759 | s808347118 | Accepted | N = int(input())
print((N + 1) // 2) |
p02767 | s628894484 | Wrong Answer | import numpy as np
n = int(input())
x = list(map(int, input().split()))
m = int(np.median(x))
k = int(np.std(x))
ans = max(x) ** 2 * n
# pos = m + k
# print(pos)
# cost = 0
for i in range(m-k, m+k, 1):
cost = 0
for j in range (n):
cost += (x[j] - i) ** 2
# print(cost)
if cost < ans:
ans = cost
print(ans) |
p02910 | s889830891 | Accepted | S = input()
even = [v for i, v in enumerate(S) if i % 2 == 0]
odd = [v for i, v in enumerate(S) if i % 2 == 1]
count = even.count("L") + odd.count("R")
print("Yes" if count == 0 else "No") |
p02786 | s097861005 | Wrong Answer | H = int(input())
print(H)
def ref(H,d):
d = d+1
if 1 < H:
H, d = ref(H/2,d*2)
return H, d
_, d = ref(H,0)
print(d) |
p02647 | s063700622 | Accepted | n,k=map(int,input().split())
A=list(map(int,input().split()))
C=[n for _ in range(n)]
for loop in range(k):
B=[0 for _ in range(n)]
for i in range(n):
l,r=max(0,i-A[i]),i+A[i]+1
B[l] +=1
if r<n:B[r] -=1
for i in range(n-1):
B[i+1]=B[i]+B[i+1]
A=B
if A==C:break
print(*A) |
p03073 | s299588131 | Accepted | s = input()
count = 0
tmp = s[0]
for i in range(1, len(s)):
if s[i] == tmp:
count += 1
if s[i] == "0":
tmp = "1"
else:
tmp = "0"
else:
tmp = s[i]
print(count) |
p03836 | s610904715 | Wrong Answer | data = list(map(int, input().split()))
x = data[2] - data[0]
y = data[3] - data[1]
go = x * "U" + y * "R"
come = x * "D" + y * "L"
path = (go + come) * 2
print(path)
|
p02947 | s885127807 | Accepted | import collections
n=int(input())
print(int(sum((i*(i-1)/2)for i in collections.Counter([str(sorted(input()))for i in range(n)]).values()))) |
p02694 | s441891452 | Accepted | def main():
n = int(input())
print(b(n))
def b(n: int) -> int:
m = 100
i = 0
while True:
m = m * 101 // 100
i += 1
if m >= n:
break
return i
if __name__ == '__main__':
main()
|
p03835 | s068048524 | Accepted | k,s = map(int, input().split())
count = 0
for x in range(k+1):
for y in range(k+1):
z = s-(x+y)
if (0 <= z <= k):
count += 1
print(count) |
p02783 | s692823153 | Accepted | a,b=map(int,input().split())
if a%b == 0:
print(a//b)
else:
print(a//b+1) |
p03251 | s162137552 | Accepted | n,m,x,y = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a.sort(reverse = True)
b.sort()
bool = False
if a[0] < b[0]:
for i in range(a[0] + 1,b[0] + 1):
if x < i and i <= y:
bool = True
if bool:
print('No War')
else:
print('War') |
p03680 | s261503012 | Accepted | N = int(input())
d = []
visited = [False for _ in range(N+1)]
for _ in range(N):
d.append(int(input())-1)
i = 0
cnt = 0
while True:
if i == 1:
break
elif cnt >= N:
cnt = -1
break
elif visited[i]:
cnt = -1
break
else:
visited[i] = True
cnt += 1
i = d[i]
print(cnt) |
p04005 | s475676064 | Accepted | # AtCoder Grand Contest 004
# A - Divide a Cuboid
l=list(map(int,input().split()))
l.sort()
if l[0]*l[1]*l[2]%2==0:
print(0)
else:
print(l[0]*l[1]) |
p02694 | s707656561 | Accepted | k=int(input())
n=100
y=0
while(n<k):
n=int(n*1.01)
y+=1
#print(y,n)
print(y) |
p03861 | s995083229 | Wrong Answer | import sys
import math
numbers = sys.stdin.readline().split(' ')
a = int(numbers[0])
b = int(numbers[1])
c = int(numbers[2])
if a > 0:
print(int(b//c - (a-1)//c))
else:
print(math.floor(b//c))
|
p03556 | s993474197 | Accepted | N = int(input())
from math import floor, sqrt
ans = floor(sqrt(N))**2
print(ans)
|
p02631 | s354229811 | Accepted | from functools import reduce
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
a_xor=reduce(lambda x,y : x^y,a)
for i in range(n):
b[i]=a[i]^a_xor
## b[i] = reduce(lambda x,y : x^y,a[0:i+1]+a[i:])
print(" ".join(list(map(str,b)))) |
p02829 | s460187652 | Accepted | # input
A = int(input())
B = int(input())
# check
Answer = list(set([1, 2, 3]) ^ set([A, B]))[0]
print(Answer) |
p04044 | s632881960 | Accepted | N, L = map(int, input().split())
S = [input() for _ in range(N)]
S.sort()
print("".join(S)) |
p02732 | s521764823 | Accepted | N=int(input())
a=list(map(int, input().split()))
cnt=[0]*N
for i in range(N):
cnt[a[i]-1]+=1
c_sum=0
for i in range(N):
c_sum+=(cnt[i]*(cnt[i]-1))//2
for i in range(N):
k=(cnt[a[i]-1])*(cnt[a[i]-1]-1) //2
l=(cnt[a[i]-1]-1)*(cnt[a[i]-1]-2) //2
d=k-l
print(c_sum-d) |
p02947 | s922062109 | Accepted | import sys
input = sys.stdin.readline
N = int(input())
S = sorted([sorted(input()) for _ in range(N)])
ans = 0
pre = '_'
precnt = 0
for s in S:
if s == pre:
precnt += 1
ans += precnt
else:
pre = s
precnt = 0
print(ans)
|
p03862 | s696812036 | Wrong Answer | n, x = map(int, input().split())
li_a = list(map(int, input().split()))
s = []
for i in range(n-1):
s.append(li_a[i]+li_a[i+1])
ans = 0
for i in range(n-1):
if s[i] >= x:
ans += s[i] - x
if i != n-2:
s[i+1] -= s[i] - x
print(ans) |
p02747 | s739525049 | Accepted | S = input()
ans = "Yes"
if len(S)%2==1:ans = "No"
for i in range(len(S)//2):
if S[i*2]+S[i*2+1]!="hi":
ans = "No"
print(ans) |
p03799 | s205140799 | Wrong Answer | n,m = map(int,input().split())
ans = 0
if 2*n>m:
ans += m//2
else:
ans += n
m -= 2*n
ans += m//3
print(ans) |
p03380 | s451868875 | Accepted | N=int(input())
a=sorted(list(map(int,input().split())))
n=a[-1]
tmp=0
if n%2==0:
ideal=n//2
for i in range(N-1):
if abs(ideal-tmp)>abs(ideal-a[i]):
tmp=a[i]
else:
ideal1=(n-1)//2
ideal2=ideal1+1
for i in range(N-1):
if abs(ideal1-tmp)>abs(ideal1-a[i]) or abs(ideal2-tmp)>abs(ideal2-a[i]):
tmp=a[i]
print(' '.join([str(n),str(tmp)])) |
p02640 | s830975106 | Wrong Answer | x,y = map(int,input().split())
m=4*x
yf=y//4
ans='Yes'
if m<y:
ans='No'
elif y%2!=0:
ans='No'
elif y%2==0 or y%4==0:
pass
elif yf+1<=x:
pass
else:
ans='No'
print(ans) |
p03494 | s275806804 | Wrong Answer | N = int(input())
A = list(map(int,input().split()))
ans = 10 ** 6
for a in A:
c = 0
while a % 2 == 0:
a //= 2
ans = min(c,ans)
print(ans) |
p03639 | s816243730 | Accepted | n = int(input())
a = list(map(int,input().split()))
num_4 = 0
num_2 = 0
num_1 = 0
for ai in a:
if(ai%4==0):
num_4 += 1
elif(ai%2==0):
num_2 += 1
else:
num_1 += 1
if(num_4 >= num_1):
print('Yes')
elif(num_4 + 1 == num_1)&(num_2==0):
print('Yes')
else:
print('No')
|
p02787 | s381971403 | Accepted | H, N = map(int, input().split())
Magic = [list(map(int, input().split())) for i in range(N)]
MAX_COST = max(Magic)[1]
# dp[damage] := モンスターに damage を与えるために必要な最小コスト
dp = [float('inf')] * (H + 1)
dp[0] = 0
for h in range(H):
for damage, cost in Magic:
next_index = min(h + damage, H)
dp[next_index] = min(dp[next_index], dp[h] + cost)
print(dp[-1])
|
p03339 | s691280119 | Accepted | n = int(input())
s = input()
w = [0]*n
e = [0]*n
if s[0] == "W": w[0] += 1
else: e[0] += 1
for i in range(1,n):
if s[i] == "W":
w[i] = w[i-1]+1
e[i] = e[i-1]
else:
w[i] = w[i-1]
e[i] = e[i-1]+1
ans = float("inf")
if e[n-1]-e[0] < ans: ans = e[n-1]-e[0]
if w[n-1] < ans: ans = w[n-1]
for i in range(1,n-1):
t = w[i-1] + e[n-1]-e[i]
if t < ans: ans = t
print(ans) |
p03377 | s376788193 | Accepted | a, b, x= map(int, input().split())
if (a <= x <= a+b):
print("YES")
else:
print("NO") |
p02759 | s287454342 | Accepted | a=int(input())
if a%2==0:
print(int(a/2))
else:
print(int((a+1)/2)) |
p03067 | s180537750 | Accepted | a, b, c = map(int, input().split())
if a <= c <= b or b <= c <= a:
print("Yes")
else:
print("No") |
p03211 | s150507555 | Accepted | #114_B
S=input()
Ans=1000
for i in range(len(S)-2):
x=int(S[i:i+3])
Ans=min(Ans,abs(x-753))
print(Ans) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.