problem_id stringclasses 428 values | submission_id stringlengths 10 10 | status stringclasses 2 values | code stringlengths 5 816 |
|---|---|---|---|
p03208 | s450965640 | Accepted | n, k = map(int, input().split())
H = sorted([int(input()) for _ in range(n)])
ans = 1100100100
for i in range(n-k+1):
ans = min(ans, H[i+k-1] - H[i])
print(ans) |
p03107 | s592562267 | Wrong Answer | S = list(input())
S.append("end")
S.append("end")
S.append("end")
i = 1
ans = 0
while S[i] != "end":
if S[i] != S[i - 1]:
del(S[i - 1])
del(S[i - 1])
i -= 1
ans += 2
else:
i += 1
print(ans) |
p02678 | s825628883 | Accepted | import sys
from collections import *
N,M=map(int,input().split())
adj=[[] for _ in range(N+1)]
for ln in sys.stdin:
A,B=map(int,ln.split())
adj[A].append(B)
adj[B].append(A)
ans=[0]*(N+1)
ans[1]=1
que=deque([1])
while que:
A=que.popleft()
for B in adj[A]:
if ans[B]==0:
ans[B]=A
que.append(B)
print('Yes')
for i in range(2,N+1):
print(ans[i])
|
p02725 | s135258062 | Accepted | K, N = map(int, input().split())
Alst = list(map(int, input().split()))
zero = Alst[0] + K
M = 0
now = Alst[0]
for i in Alst:
dis = i - now
if dis > M:
M = dis
now = i
last = zero - now
if last > M:
M = last
print(K - M) |
p03251 | s053668281 | Accepted | n,m,a,b = map(int,input().split())
x = list(map(int,input().split()))
x = max(x)
y = list(map(int,input().split()))
y = min(y)
i = x
ans = ''
for i in range(a+1,b):
# X<z<yという区間を満たしていない ので誤りその条件を付け加えるなら...
if x<i and i<=y:
ans = 1
if ans:
print('No War')
else:
print('War') |
p02665 | s540698023 | Accepted | import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
pos = [0 for i in range(n+1)]
pos[0] = 1 - a[0]
for i in range(n):
pos[i+1] = pos[i] * 2 - a[i+1]
for i in range(n+1):
if pos[i] < 0:
print(-1)
exit()
cnt = a[-1]
memo = 0
for i in range(n-1, -1, -1):
cnt += min(pos[i], memo + a[i+1]) + a[i]
memo = min(pos[i], memo + a[i+1])
print(cnt) |
p03136 | s929577527 | Wrong Answer | N=int(input())
input_list=map(int,input().split(" "))
max_input=max(input_list)
Sum_input=sum(input_list)-max_input
if max_input<Sum_input:
print("Yes")
else:
print("No") |
p03448 | s011663523 | Wrong Answer | a = int(input())
b = int(input())
c = int(input())
x = int(input())
num = 0
for i in range(a):
for j in range(b):
for k in range(c):
if 500 * i + 100 * j + 50 * k == x:
num += 1
print(num) |
p02724 | s499840643 | Accepted | X = int(input())
n_500 = X // 500
num = X - n_500 * 500
n_5 = num // 5
print(n_500 * 1000 + n_5 * 5)
|
p02618 | s990743890 | Accepted | d=int(input())
c=list(map(int,input().split()))
c_days=[0]*26
for i in range(d):
s=list(map(int,input().split()))
#最大満足度を選択
c_low=[c[x]*(i+1-c_days[x]) for x in range(26)]
c_max=[s[x]-c_low[x] for x in range(26)]
n=c_max.index(max(c_max))
c_days[n]=i+1
print(n+1) |
p03455 | s485533142 | Accepted | a,b = map(int,input().split())
if a*b%2==0:
print("Even")
else:
print("Odd") |
p03779 | s041440599 | Wrong Answer | n = int(input())
cnt = 0
p = 0
for i in range(n):
cnt += i
if cnt >= n:
p = i
break
print(p) |
p02600 | s935152334 | Accepted | X = int(input())
print(10 - X // 200) |
p03000 | s599475542 | Accepted | N, X = map(int, input().split())
L = list(map(int, input().split()))
d = 0
count = 0
for i in range(N):
d += L[i]
if X < d:
count = i + 1
break
if count == 0:
print(N + 1)
else:
print(count)
|
p03623 | s449009142 | Accepted | x,a,b=map(int,input().split())
if abs(x-a)>abs(x-b):
print("B")
else:
print("A") |
p03206 | s320554415 | Accepted | print("Christmas"+" Eve"*(25-int(input()))) |
p03673 | s860195008 | Accepted | import collections
N = int(input())
A = list(map(int, input().split()))
ans = collections.deque()
for i in range(N):
if N % 2 == 0:
if i % 2 == 0:
ans.append(A[i])
else:
ans.appendleft(A[i])
else:
if i % 2 == 0:
ans.appendleft(A[i])
else:
ans.append(A[i])
print(*ans)
|
p02582 | s403328591 | Accepted | s = list(input())
if s.count('R') == 3:
print(3)
elif s.count('R') == 1:
print(1)
elif s.count('R') == 0:
print(0)
else:
if s[1] == 'R':
print(2)
else:
print(1) |
p03285 | s030571080 | Accepted | N = int(input())
for i in range(26):
if (N-i*4)% 7 == 0 and N>= i*4:
print("Yes")
exit()
print("No")
|
p02972 | s814619749 | Wrong Answer | N = int(input())
A = list(map(int,input().split()))
box = [0]*N
ans = []
for n in range(N,0,-1):
c = 0
for i in range(n,N,n):
c += box[i-1]
c %= 2
if A[n-1] != c:
box[n-1] = 1
ans.append(n)
print(len(ans))
if ans:
print(*ans) |
p03745 | s768059763 | Wrong Answer | n = int(input())
L = list(map(int, input().split()))
cnt = 1
L2 = [''] * (n - 1)
for i in range(n - 1):
L2[i] = L[i + 1] - L[i]
j = 0
while j < n - 2:
if L2[j + 1] * L2[j] < 0:
cnt += 1
j += 1
j += 1
print(cnt) |
p04033 | s944066207 | Accepted | a,b=map(int,input().split())
if a>0 and b>0:
print('Positive')
elif a<0 and b<0 and (abs(a)-abs(b)+1)%2 != 0:
print('Negative')
elif a<0 and b<0 and (abs(a)-abs(b)+1)%2==0:
print('Positive')
else:
print('Zero') |
p03469 | s368809024 | Accepted | print('2018'+input()[4:]) |
p02663 | s115615025 | Accepted | H1, M1, H2, M2, K = map(int, input().split())
print((H2-H1)*60 + (M2-M1) -K) |
p02911 | s740412432 | Wrong Answer | n, k, q = list(map(int, input().split()))
a = [int(input()) for i in range(q)]
p = [k]*n
for i in a:
for j,val in enumerate(p):
if j != i:
p[j] -= 1
for n in p:
if n>0:
print("Yes")
else:
print("No")
|
p02642 | s593457532 | Accepted | from collections import Counter
import sys
n=int(input())
a=sorted(list(map(int,input().split())))
c=[1 for i in range(10**6+1)]
d = Counter(a)
s = list(set(a))
count = 0
if d[1] == 1:
print(1)
sys.exit()
elif d[1] >=2:
print(0)
sys.exit()
for x in s:
t = x * 2
while t <= 10 ** 6:
c[t] = 0
t += x
for x in a:
if d[x] == 1 and c[x] == 1:
count += 1
print(count) |
p02684 | s218291658 | Accepted | n, k = map(int, input().split())
a = list(map(int, input().split()))
passed = [-1] * (n+1)
route = []
v = 1
while passed[v] == -1:
passed[v] = len(route)
route.append(v)
v = a[v-1]
c = len(route) - passed[v]
l = passed[v]
if k < l:
print(route[k])
else:
k -= l
k %= c
print(route[l+k]) |
p03109 | s316520209 | Wrong Answer | S = input()
if int(S[5:6]) <= 4:
print("Heisei")
else:
print("TBD") |
p02832 | s536093112 | Accepted | n = int(input())
A = list(map(int, input().split()))
now = 1
hit = 0
for a in A:
if a != now:
hit += 1
else:
now += 1
if hit == n:
print(-1)
else:
print(hit) |
p03797 | s600055403 | Wrong Answer | N,M = [int(i) for i in input().split()]
S = 0
if N >= 2*M:
S = M // 2
else:
S = N + (M - 2*N)//4
print(S)
|
p02719 | s906371339 | Wrong Answer | n, k = [int(i) for i in input().split()]
import fractions
if k == 1:
print(0)
else:
print(fractions.gcd(n, k))
|
p02712 | s978894309 | Accepted | n = int(input())
ans =0
for i in range(1,n+1):
if i % 3 != 0 and i %5 !=0:
ans += i
print(ans) |
p03625 | s715305061 | Accepted | from collections import Counter
n = int(input())
A = list(map(int, input().split()))
C = Counter(A)
rec = []
squ = []
for a in A:
if 2 <= C[a]:
rec.append(a)
if 4 <= C[a]:
squ.append(a)
rec = list(set(rec))
squ = list(set(squ))
# print(rec)
# print(squ)
s = 0
if len(squ) != 0:
s = max(squ)**2
if len(rec) < 2:
print(s)
else:
rec.sort(reverse=True)
print(max(s, rec[0]*rec[1])) |
p02879 | s314417592 | Accepted | a,b =map(int,input().split())
if 1 <= a <=9 and 1 <= b <=9:
print(a*b)
else:
print(-1) |
p03721 | s311579782 | Wrong Answer | n,k=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
l=[]
for i in range(len(ab)):
for j in range(ab[i][1]):
l.append(ab[i][0])
l.sort()
print(l[3]) |
p02719 | s205171214 | Wrong Answer | l = input().split()
l_int = [int(a) for a in l]
N = l_int[0]
K = l_int[1]
if K > N:
print(N)
else:
print(N % K)
|
p03041 | s926748234 | Accepted | NK = input().split()
N, K = int(NK[0]), int(NK[1])
S = list(input())
if(S[K-1] == "A"):
S[K-1] = "a"
elif(S[K-1] == "B"):
S[K-1] = "b"
elif(S[K-1] == "C"):
S[K-1] = "c"
print("".join(S))
|
p02630 | s794423994 | Accepted | import collections
n = int(input())
a = list(map(int, input().split()))
q = int(input())
bc = []
for i in range(q):
bci = list(map(int, input().split()))
bc.append(bci)
cc = collections.Counter(a)
li = cc.most_common()
su = sum(a)
for i in range(q):
b, c = bc[i]
if cc[b]:
num = (c-b)*cc[b]
else:
num = 0
su += num
print(su)
if cc[c]:
cc[c] += cc[b]
else:
cc[c] = cc[b]
cc[b] = 0 |
p03592 | s953247326 | Accepted | n, m, k = map(int, input().split())
s = [[0 for i in range(n)]for j in range(m)]
for i in range(n+1):
for j in range(m+1):
if (i*m + j*n - 2*i*j) == k:
print("Yes")
exit()
print("No") |
p02987 | s315917504 | Accepted | s=input()
S=set([i for i in s])
if len(S)==2 and s.count(list(S)[0])==s.count(list(S)[1]):
print("Yes")
else:
print("No")
|
p02793 | s951323067 | Accepted | from fractions import gcd
from functools import reduce
n = int(input())
A = list(map(int,input().split()))
mod = 10 ** 9 + 7
lcm = reduce(lambda x,y: x*y//gcd(x,y), A)
# print(lcm)
ans = sum(lcm//x for x in A)
ans %= mod
print(ans) |
p03524 | s786999517 | Accepted | import collections
s = list(input())
s = collections.Counter(s)
a = s["a"]
b = s["b"]
c = s["c"]
if max(a,b,c) - min(a,b,c) <= 1:
print("YES")
else:
print("NO") |
p02553 | s053848060 | Accepted | a,b,c,d = map(int,input().split())
l = [a*c, a*d, b*c, b*d]
print(max(l)) |
p02546 | s569056143 | Wrong Answer | z = input()
if z[-1]in['s','x','z','ch','sh']:
print(z+'es')
elif z[-1]=='y'and z[-2]not in['a','e','i','o','u']:
print(z[:-1]+'ies')
elif z[-2:]=='fe':
print(z[:-2]+'ves')
elif z[-1]=='f':
print(z[:-1]+'ves')
elif z[-1]=='o'and z[-2]not in['a','e','i','o','u']:
print(z[:-1]+'oes')
else:
print(z+'s') |
p02552 | s648490375 | Accepted | n = str(input())
if n == "0":
print("1")
else:
print("0") |
p02801 | s178035805 | Accepted | C = input()
print(chr(ord(C)+1)) |
p02832 | s486121381 | Accepted | n = int(input())
a = map(int, input().split())
ans_lst = []
for ai in a:
if ai == 1 and len(ans_lst) == 0:
ans_lst.append(1)
elif len(ans_lst) > 0 and ans_lst[-1] == ai - 1:
ans_lst.append(ai)
if len(ans_lst) == 0:
print(-1)
else:
print(n - len(ans_lst)) |
p03001 | s430305518 | Accepted | # 理解するまでが面白い
# 思考5分、実装1分
w,h,x,y = map(int, input().split())
print(w*h/2)
if x == w/2 and y == h/2:
print('1')
else:
print('0') |
p03475 | s514750326 | Wrong Answer | n = int(input())
C, S, F = [0] * n, [0] * n, [0] * n
for i in range(n - 1):
C[i], S[i], F[i] = map(int, input().split())
for i in range(n):
time = S[i]
for j in range(i, n - 1):
if time % F[j] == 0:
time += C[j]
elif time < S[j]:
time = S[j] + C[j]
else:
time = time + F[j] - (time % F[j]) + C[j]
print(time)
|
p02714 | s651347884 | Accepted | from collections import Counter
N = int(input())
S = input()
C = Counter(S)
ans = C['R']*C['G']*C['B']
for w in range(1, (N+1)//2+1):
for i in range(N-(w*2)):
if S[i]!=S[i+w] and S[i]!=S[i+2*w] and S[i+w]!=S[i+2*w]:
ans -= 1
print(ans) |
p02584 | s428024384 | Accepted | import math
x, k, d = map(int, input().split())
if k * d <= abs(x):
print(abs(x) - k * d)
exit()
if x < 0:
x = abs(x)
move = math.ceil(x/d)
x = x - d * move
k -= move
if k % 2 == 0:
print(abs(x))
else:
x = x + d
print(abs(x))
|
p02911 | s127623659 | Accepted | import sys
from collections import Counter
n, k, q = map(int, sys.stdin.readline().split())
a = map(int, sys.stdin.read().split())
counter = Counter(a)
for i in range(n):
if k - q + counter[i+1] > 0:
ans = 'Yes'
else:
ans = 'No'
print(ans)
|
p02683 | s936871629 | Accepted | N,M,X=map(int,input().split())
ls=[list(map(int,input().split())) for i in range(N)]
ls_c=[]
for i in range(1,2**N):
ls_al=[0]*M
c=0
for j in range(N):
if (i>>j)&1==1:
c+=ls[j][0]
for k in range(M):
ls_al[k]+=ls[j][k+1]
if min(ls_al)>=X:
ls_c.append(c)
if ls_c!=[]:
print(min(ls_c))
else:
print(-1) |
p03469 | s018736922 | Accepted | s=input()
print(s[:3]+"8"+s[4:]) |
p03632 | s120115799 | Accepted | A, B, C, D = map(int, input().split())
if A <= C:
if B < C:
print(0)
else:
print(min(B, D) - C)
else:
if D < A:
print(0)
else:
print(min(B, D) - A) |
p03699 | s249000693 | Accepted | #16
n = int(input())
s = [int(input()) for i in range(n)]
Max = sum(s)
s.sort()
if Max%10 ==0:
for i in range(n):
if s[i]%10 != 0:
Max -= s[i]
if Max%10 !=0:
break
if Max%10 == 0:
Max = 0
print(Max) |
p03639 | s582006775 | Accepted | n=int(input())
l=list(map(int,input().split()))
d=[0,0,0]
for i in l:
if i%4==0:d[2]+=1
elif i%2==0:d[1]+=1
else:d[0]+=1
f=0
if d[-1]>=n//2:f=1
if d[0]<=d[-1]:f=1
print("Yes" if f else "No")
|
p03077 | s249010715 | Accepted | N = int(input())
A = [int(input()) for i in range(5)]
m = min(A)
cnt = (N - 1) // m + 1
print(cnt + 4) |
p02935 | s076969097 | Accepted | n = int(input())
vn =list(map(int, input().split()))
vn.sort()
a = (vn[0]+vn[1])*0.5
for i in range(2, n):
a = (a+vn[i])*0.5
print(a)
|
p02791 | s789461507 | Accepted | import math
N = int(input())
tmp = 10 ** 30
ans = 0
for P in list(map(int,input().split())):
if P <= tmp:
tmp = P
ans += 1
print(ans) |
p02600 | s937696536 | Accepted | x = int(input())
if x<=599:
ans=8
elif x<=799:
ans=7
elif x<=999:
ans=6
elif x<=1199:
ans=5
elif x<=1399:
ans=4
elif x<=1599:
ans=3
elif x<=1799:
ans=2
elif x<=1999:
ans=1
print(ans) |
p02996 | s528803867 | Accepted | def main(n, a_b):
a_b.sort(key=lambda a_b: a_b[1])
t = 0
for a, b in a_b:
t += a
if t > b:
print('No')
return
print('Yes')
if __name__ == "__main__":
n = int(input())
a_b = [list(map(int, input().split())) for _ in range(n)]
main(n, a_b)
|
p03544 | s329710832 | Accepted | n=int(input())
l=[2,1]
for i in range(2,n+1):
l.append(l[i-1]+l[i-2])
print(l[n]) |
p02577 | s148844457 | Accepted | n = input()
ans = 0
for i in n:
ans += int(i)
ans = "Yes" if ans % 9 == 0 else "No"
print(ans)
|
p02615 | s879620725 | Wrong Answer | import itertools
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
ans = 0
for L in itertools.permutations(A):
temp = 0
for i in range(N-1):
temp += min(L[i-1], L[i+1])
ans = max(ans, temp)
print(ans)
|
p03331 | s540539588 | Accepted | n = int(input())
ans = 10**9
for i in range(1,n):
ans_a = 0
ans_b = 0
a = str(i)
b = str(n-i)
for j in a:
ans_a += int(j)
for k in b:
ans_b += int(k)
ans = min(ans,ans_a+ans_b)
print(ans)
|
p02797 | s793111578 | Wrong Answer | N, K, S = map(int, input().split())
arr = [1 if S > N else S + 1] * N
for i in range(K):
arr[i] = S
print(arr) |
p02888 | s267613357 | Accepted | import itertools, bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N):
for j in range(i+1, N):
cindex = bisect.bisect_left(L, int(L[i]) + int(L[j]))
ans += cindex-1 - j
print(ans)
|
p03556 | s909882969 | Wrong Answer | #owsiudfhowidhoewifnowienfoeinfo
print(int(float(int(input())**0.5)))
|
p03067 | s140861120 | Wrong Answer | #!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
a,b,c=map(int,input().split())
if a<=b<=c or a>=b>=c:
print("Yes")
else:
print("No") |
p02993 | s535990411 | Accepted | S=input()
ans='Good'
for i in range(3):
if S[i]==S[i+1]:
ans='Bad'
print(ans) |
p02773 | s491005562 | Accepted | N = int(input())
_dict = {}
max_cnt = 0
for n in range(N):
_ = input()
if _ not in _dict:
_dict[_] = 1
else:
_dict[_] += 1
if _dict[_] > max_cnt:
max_cnt = _dict[_]
ans = [k for k, v in _dict.items() if v == max_cnt]
ans.sort()
for _ in ans:
print(_) |
p02621 | s878306219 | Accepted | from sys import stdin
c = stdin.readline().rstrip()
a = int(c)
res = a+pow(a,2)+pow(a,3)
print(res) |
p03252 | s074898677 | Accepted | import sys
s=list(input())
t=list(input())
start=[-1]*26
end=[-1]*26
for i in range(len(s)):
a=ord(s[i])-ord('a')
b=ord(t[i])-ord('a')
if(start[a]!=-1 or end[b]!=-1):
if(start[a]!=b or end[b]!=a):
print("No")
sys.exit()
start[a]=b
end[b]=a
print("Yes") |
p02595 | s710611501 | Wrong Answer | N,D=map(int,input().split())
cnt=0
for idx in range(N-1):
X,Y=map(int,input().split())
if X**2+Y**2<=D**2:
cnt=cnt+1
print(cnt) |
p02613 | s612651791 | Accepted | N = int(input())
S = [input() for _ in range(N)]
AC = 0
WA = 0
TLE = 0
RE = 0
for s in S:
if s == 'AC':
AC += 1
elif s == 'WA':
WA += 1
elif s == 'TLE':
TLE += 1
elif s == 'RE':
RE += 1
else:
pass
print('AC x ' + str(AC))
print('WA x ' + str(WA))
print('TLE x ' + str(TLE))
print('RE x ' + str(RE))
|
p03472 | s386153338 | Accepted | from math import ceil
n,h=map(int,input().split())
a=[0]*n
b=[0]*n
for i in range(n):
a[i],b[i]=map(int,input().split())
dmax=max(a)
b.sort(reverse=True)
ans=0
for d in b:
if h<=0:
print(ans)
exit()
if d<dmax:
break
h-=d
ans+=1
if h<=0:
print(ans)
exit()
print(ans+ceil(h/dmax)) |
p02661 | s662811121 | Wrong Answer | from itertools import product
N = int(input())
A = []
B = []
for _ in range(N):
a, b = map(int, input().split())
A.append(a), B.append(b)
A.sort()
B.sort()
if N % 2 == 0:
print(len(set(a + b for a, b in product(range(A[N // 2 - 1], A[N // 2] + 1), range(B[N // 2 - 1], B[N // 2] + 1)))))
else:
print(B[N // 2] - A[N // 2] + 1)
|
p04045 | s545172085 | Accepted | import sys
N, K = map(int, input().split())
D = set(map(int, input().split()))
def check(n):
m = set(str(n))
for c in m:
if int(c) in D:
return False
return True
for i in range(999999):
if check(N+i):
print(N+i)
sys.exit() |
p04030 | s607947071 | Wrong Answer | from sys import stdin
from collections import deque
input = stdin.readline
s = input()
d = deque([])
for i in s:
if s != "B":
d.append(s)
else:
if d:
d.pop()
else:
pass
print("".join(d))
|
p03665 | s234572663 | Accepted | N, P = map(int, input().split())
A = list(map(int, input().split()))
n = 0
for v in A:
if v % 2 == 0:
n += 1
if N == n:
if P == 0: ans = 2 ** N
else: ans = 0
else:
ans = 2 ** (N-1)
print(ans) |
p03730 | s513800777 | Accepted | a,b,c=[int(x) for x in input().split()]
ans = "NO"
for i in range(b):
if (a*i)%b==c:
ans="YES"
print(ans) |
p03797 | s732880458 | Wrong Answer | n,m=map(int,input().split())
ans = 0
if 2*n >= m:
print(n)
else:
ans += n
m -= 2*n
ans += m//4
print(ans) |
p02761 | s554439366 | Wrong Answer | N,M=map(int,input().split())
l=[0]*N
ans=0
for i in range(M):
s,c=map(int,input().split())
if l[s-1]==0 or l[s-1]==c:
l[s-1]=c
else:
print(-1)
exit()
for i in range(N):
ans+=int(l[i])*(10**(N-i-1))
if N==len(str(ans)):
print(ans)
else:
print(-1)
|
p02947 | s808957878 | Wrong Answer | import collections
import sys
N = int(input())
s = [sorted(collections.Counter(sys.stdin.readline().rstrip())) for _ in range(N)]
counted = {}
for s_count in s:
if str(s_count) not in counted:
counted[str(s_count)] = 1
else:
counted[str(s_count)] += 1
count = 0
for n in counted.values():
count += n * (n - 1) // 2
print(count) |
p02880 | s330622041 | Accepted | a = int(input())
li = []
for i in range(1,10):
for j in range(1,10):
li.append(i*j)
if a in li:
print('Yes')
else:
print('No')
|
p03774 | s122120351 | Wrong Answer | N, M = map(int, input().split())
student = [tuple(map(int, input().split())) for _ in range(N)]
checkpoint = [tuple(map(int, input().split())) for _ in range(M)]
closest = {}
for s in student:
min_dist = 'INF'
ans = 1
for c in checkpoint:
dist = abs(s[0]-c[0]) + abs(s[1]-c[1])
if min_dist == 'INF' or dist < min_dist:
min_dist = dist
closest[s] = ans
ans += 1
print(closest[s] for s in student)
|
p02970 | s557874830 | Accepted | import math
n,d=list(map(int,input().split()))
print(math.ceil(n/(2*d+1)))
|
p03289 | s206256940 | Accepted | s = input().strip()
a = (s[0] == "A")
c_cnt = 0
for e in s[2:(-1)]:
if e == "C":
c_cnt += 1
if a and c_cnt == 1 and s[1:].replace("C", "").islower():
print("AC")
else:
print("WA")
|
p02647 | s491552966 | Accepted | n,k=map(int,input().split())
a=list(map(int,input().split()))
for _ in range(min(k,41)):
imos=[0]*(n+1)
for i in range(n):
imos[max(0,i-a[i])]+=1
imos[min(n-1,i+a[i])+1]-=1
for i in range(n-1):
imos[i+1]+=imos[i]
for i in range(n):
a[i]=imos[i]
print(*a) |
p03679 | s732954351 | Accepted | x,a,b=map(int,input().split())
if b-a>x:
print('dangerous')
elif b-a<=0:
print('delicious')
else:
print('safe') |
p02766 | s063703178 | Accepted | def main():
N,K=map(int,input().split())
sFlag=True
s=0
while(sFlag):
sk=K**s
if(N>=sk):
sans=s
s=s+1
else:
print(sans+1)
sFlag=False
if __name__ == '__main__':
main() |
p02699 | s534105528 | Accepted | s, w = map(int, input().split())
if w >= s:
print('unsafe')
else:
print('safe')
|
p02917 | s364621715 | Accepted | n = int(input())
b = list(map(int, input().split()))
ans = 0
for i in range(n - 2):
ans += min(b[i], b[i+1])
ans += b[0] + b[n-2]
print(ans) |
p03387 | s872416961 | Wrong Answer | a, b, c = map(int, input().split())
abc_M = max([a, b, c])
ans = 0
no_max = list(map(lambda x: abs(x-abc_M), [a, b, c]))
no_max = [i for i in no_max if i != 0]
if all(i % 2 == 0 for i in no_max):
for i in no_max:
ans += i//2
if all(i % 2 != 0 for i in no_max):
for i in no_max:
ans += (i-1)//2
ans += 1
if [i %2 == 0 for i in no_max] == [True, False] or [False, True]:
ans += 1
for i in no_max:
if i % 2 != 0:
ans += (i-1)//2
if i%2 == 0:
ans += i//2
ans += 1
print(ans) |
p02690 | s028843740 | Accepted | def main():
x = int(input())
num = 10**3
for a in range(-num,num):
for b in range(-num, num):
if a**5-b**5 == x:
print(a,b)
return
if __name__ == '__main__':
main()
|
p02682 | s616069680 | Wrong Answer | a, b, c, k = map(int, input().split());
num = a;
if k >= a + b:
num -= k - (a + b);
print(num)
|
p03475 | s645591142 | Accepted | from math import ceil
N = int(input())
C = [0]*(N-1)
S = [0]*(N-1)
F = [0]*(N-1)
for i in range(N-1):
C[i],S[i],F[i] = map(int, input().split())
for i in range(N-1):
t = 0
for j in range(i,N-1):
if t<=S[j]:
t = S[j] + C[j]
else:
k = ceil((t-S[j])/F[j])
t = S[j] + F[j]*k +C[j]
print(t)
print(0)
|
p03817 | s088366416 | Accepted | x = int(input())
if 1<= x%11 <= 6:
print(x//11*2+1)
elif 7<= x%11 <= 10:
print(x//11*2+2)
else:
print(x//11*2)
|
p03071 | s791664361 | Wrong Answer | A,B = map(int,input().split())
print(max(2*A-1, A-B, 2*B+1))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.