problem_id stringclasses 428 values | submission_id stringlengths 10 10 | status stringclasses 2 values | code stringlengths 5 816 |
|---|---|---|---|
p03041 | s850443594 | Accepted | #include<bits/stdc++.h>
n,k=map(int,input().split())
s=input()
c=""
for i in range(n):
if i==k-1:
c+=s[i].lower()
else:
c+=s[i]
print(c); |
p03289 | s031390980 | Wrong Answer | s = input()
if s[0] != 'A':
print('WA')
exit()
sho = ord('a')
ok = 0
for i in s[2: len(s) - 1]:
if ord(i) < sho:
if ord(i) == ord("C"):
ok += 1
else:
print("WA")
exit()
if ord(s[0]) < sho or ord(s[1]) < sho or ord(s[len(s) - 1]) < sho:
print("WA")
exit()
if ok == 1:
print("AC")
else:
print("WA") |
p03146 | s443940842 | Wrong Answer |
import numpy as np
import sys
input = sys.stdin.readline
s = int(input())
ans = 1
cnt = 0
if s == 4:
cnt +=1
i = 0
while (s != 4 or cnt < 2):
ans +=1
if s % 2 == 0:
s = int(s/2)
else:
s = 3*s + 1
if s == 4:
cnt +=1
print(ans)
|
p02860 | s150013820 | Wrong Answer | import math
n=int(input())
s=input()
s1=s[:n//2]
s2=s[n-(n//2):]
if n%2==0:
print('No')
elif s1==s2:
print('Yes')
else :
print('No') |
p03289 | s968752545 | Wrong Answer | s=input()
print("AC" if s[0]=="A" and s[2:-1].count("C")==1 else "WA") |
p03494 | s641441221 | Accepted | # -*- coding: utf-8 -*-
import numpy as np
count=0
num_of_nums=input()
nums=np.array(input().split())
nums=nums.astype(int)
while np.all(nums%2==0):
nums=nums/2
count+=1
print(count)
|
p03163 | s221996100 | Accepted | N, W = map(int, input().split())
K = [[] for i in range(N)]
for i in range(N):
K[i] = list(map(int, input().split()))
dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(1,N+1):
w, v = K[i-1]
for sum_w in range(W+1):
if sum_w-w>=0:
dp[i][sum_w] = max(dp[i-1][sum_w], dp[i-1][sum_w-w]+v)
else:
dp[i][sum_w] = dp[i-1][sum_w]
print(dp[-1][-1]) |
p03944 | s607899743 | Accepted | import numpy as np
w,h,n = map(int, input().split())
area = np.array([[1]*w]*h)
for _ in range(n):
x,y,a = map(int, input().split())
if a == 1:
area[:,:x]=0
elif a == 2:
area[:,x:]=0
elif a == 3:
area[:y,:]=0
elif a == 4:
area[y:,:]=0
print(area.sum()) |
p02730 | s814777414 | Accepted | s = str(input())
for i in range(len(s)//2):
if s[i] != s[-(i+1)]:
print("No")
exit()
for i in range(len(s)//4):
if s[i] != s[(len(s)//2-i-1)]:
print("No")
exit()
for i in range(len(s) - (len(s)+3)//2):
if s[(len(s)+3)//2+i-1] != s[-(i+1)]:
print("No")
exit()
print("Yes") |
p03017 | s843475021 | Accepted | n,a,b,c,d = map(int,input().split())
s = list(input())
for i in range(min(a,b),max(c,d)):
if s[i] == "#" and s[i+1] == "#":
print("No")
quit()
if c < d:
print("Yes")
elif c > d:
for j in range(b-1,d):
if s[j] == "." and s[j+1] == "." and s[j-1] == ".":
print("Yes")
quit()
print("No") |
p02831 | s205273819 | Accepted | from fractions import gcd
def lcm(a,b):
return (a*b) // gcd(a,b)
A, B = map(int, input().split())
C = lcm(A,B)
print(C) |
p02811 | s340349542 | Wrong Answer | a,b=map(int,input().split())
if b<=a**500:
print("Yes")
else:
print("No") |
p02598 | s375025821 | Accepted | import math
N,K = map(int, input().split())
A_list = list(map(int, input().split()))
lb = 0
ub = 10**9
for i in range(100):
middle = (lb + ub)/2
sumi = -N
for a in A_list:
sumi += math.ceil(a/middle)
if sumi <= K:
ub = middle
else:
lb = middle
print(math.ceil(middle)) |
p02571 | s419080532 | Accepted | S = input()
T = input()
ans = 1e10
for i in range(len(S)):
if i+len(T) > len(S):
break
cnt = 0
for j in range(len(T)):
if S[i+j] != T[j]:
cnt += 1
ans = min(cnt, ans)
print(ans)
|
p03221 | s988654722 | Wrong Answer | import bisect
n, m = map(int, input().split())
# 市番号
order = []
pre = [[0] for _ in range(n + 1)]
for i in range(m):
p, y = map(int, input().split())
order.append([p, y])
pre[p].append(y)
# 各県ごとにソート
for i in range(n + 1):
pre[p].sort()
# 市番号順に,各県の何番目かをにぶたんで探す
for pp, year in order:
print('{:0>6}'.format(pp) +
'{:0>6}'.format(bisect.bisect_left(pre[pp], year)))
|
p03387 | s502914557 | Accepted | ans = 0
li = sorted(list(map(int, input().split())))
ans += (li[1] - li[0]) // 2
ans += (li[2] - li[1])
if (li[1] - li[0]) % 2 == 1:
ans += 2
print(ans)
|
p02813 | s555716004 | Accepted | from itertools import permutations
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
ans = 0
for i, pe in enumerate(permutations(range(1, N + 1))):
if P == pe:
ans += i
if Q == pe:
ans -= i
print(abs(ans))
|
p03127 | s421318388 | Accepted | import fractions
N = int(input())
A = [int(i) for i in input().split()]
m = min(A)
for i in range(N):
if A[i] % m != 0:
print(fractions.gcd(m, A[i]))
exit()
print(m) |
p03352 | s670217541 | Accepted | import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')
X = int(input())
ans = 1
for i in range(2, X):
b = i
p = 2
a = b ** p
while a <= X:
ans = max(ans, a)
p += 1
a = b ** p
print(ans) |
p04033 | s381385014 | Accepted | a,b=map(int,input().split())
if a<=b<0:
print('Negative' if (-1)**(a-b-1)==-1 else 'Positive')
elif a<=0<=b:
print('Zero')
else:
print('Positive') |
p02773 | s779934131 | Accepted | from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
smax = max(Counter(s).values())
kmax = [k for k, v in Counter(s).items() if v == smax]
print("\n".join(sorted(kmax)))
|
p02823 | s436452851 | Wrong Answer | N, A, B = map(int, input().split())
if ((B-A)+1)%2==0:
print(B-1)
else:
print((B-A)/2)
|
p02899 | s109364971 | Wrong Answer | n=int(input())
b =list(map(int,input().split()))
res=[0] * n
for i in range(n):
res[b[i]-1] = i+1
for i in res:
print(i,end='') |
p03250 | s311889156 | Accepted | def main():
A, B, C = map(int, input().split())
nums = [A, B, C]
nums.sort()
ans = nums[2]*10 + nums[1] + nums[0]
print(ans)
main() |
p02957 | s626210240 | Accepted | a, b = map(int, input().split())
c = abs(a - b)
if c % 2 != 0:
print("IMPOSSIBLE")
else:
print(int(min(a, b) + c / 2)) |
p02994 | s169538514 | Accepted | N, L = map(int, input().split())
ans = 0
sa = 10000
for i in range(N):
ans += L+i
if abs(sa) > abs(L+i):
sa = L+i
print(ans - sa) |
p02819 | s677080271 | Accepted | x = int(input())
import math
def is_prime(n):
if n == 1: return False
for k in range(2, int(math.sqrt(n)) + 1):
if n % k == 0:
return False
return True
while(1):
if(is_prime(x)):
print(x)
break
x += 1
|
p02916 | s734725660 | Accepted | N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0
for i in range(N):
ans += B[A[i]-1]
if i >0 and A[i] - A[i-1] ==1:
ans += C[A[i]-2]
print(ans) |
p02994 | s127617496 | Wrong Answer | n,l=map(int,input().split())
s=(l-1)*n+n*(n+1)/2
if n>=1:
print(s-1)
elif n>=1-l:
print(s-1+l)
else:
print(s-n) |
p02946 | s702341019 | Wrong Answer | p = list(map(int, input().split()))
ans = list(range(p[1]-p[0]+1, p[1]+p[0]))
print(ans) |
p02571 | s244444545 | Accepted | s = list(input())
t = list(input())
m = 0
for i in range(len(s)-len(t)+1):
x = 0
for j in range(len(t)):
if t[j] == s[i+j]:
x+=1
if x > m:
m = x
ans = len(t)-m
print(ans) |
p03208 | s265227571 | Wrong Answer | n, k = map(int, input().split())
h=[int(input()) for i in range(n)]
h.sort()
ans=float('inf')
for i in range(n-k):
d=h[i+k-1]-h[i]
if d<ans:
ans=d
print(ans) |
p03852 | s666886450 | Accepted | c=input()
if c=='a' or c=='e' or c=='i' or c=='o' or c=='u':
print('vowel')
else:
print('consonant') |
p02996 | s883434094 | Wrong Answer | from operator import itemgetter
N = int(input())
job = [list(map(int, input().split())) for i in range(N)]
job.sort(key = itemgetter(1))
time = 0
flag = 0
for i in range(N):
time += job[i][0]
if time > job[i][1]:
flag = 1
print(flag)
if flag == 0:
print('Yes')
else:
print('No')
|
p03220 | s696043809 | Accepted | from operator import itemgetter
N = int(input())
T, A = map(int, input().split())
*H, = map(int, input().split())
avg = sorted([[i+1, abs(T - (h * 0.006) - A)] for i, h in enumerate(H)], key=itemgetter(1))
print(avg[0][0]) |
p03557 | s321273841 | Wrong Answer | # ABC 077
import bisect
N = int(input())
A = [int(j) for j in input().split()]
B = [int(j) for j in input().split()]
C = [int(j) for j in input().split()]
ans = 0
for a in A:
for c in C:
if a < B[-1]:
A_ =bisect.bisect_left(B,a)
C_ =bisect.bisect_right(B,c)
ans += C_-A_
print(ans) |
p02647 | s638259020 | Accepted | import numpy as np
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))
from numba import jit
@jit
def imos(x):
global N
B = np.zeros_like(x)
for i in range(N):
p = x[i]
L = max(i-p, 0)
R = min(i+p, N-1)
B[L] += 1
if R < N-1:
B[R+1] -= 1
B = np.cumsum(B)
return B
for i in range(K):
if i >= 50:
break
A = imos(A)
print(*A) |
p02829 | s514687545 | Accepted | a = int(input())
b = int(input())
lis = [a, b]
ans = 2
if max(lis) == 2:
ans = 3
elif min(lis) == 2:
ans = 1
print(ans) |
p03730 | s823247685 | Accepted | import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def gcd(a,b):
while b:a,b=b,a%b
return a
def main():
a,b,c=MI()
g=gcd(a,b)
if c%g:print("NO")
else:print("YES")
main() |
p03210 | s463237340 | Accepted | print('YES' if int(input()) in [7,5,3] else 'NO') |
p02705 | s707048442 | Wrong Answer | import math
R = int(input())
print(R**2 * math.pi)
|
p03998 | s122722753 | Accepted | S = [list(input()) for _ in range(3)]
d = {0: "a", 1: "b", 2: "c"}
D = {"a":0, "b":1, "c":2}
n = 0
for _ in range(len(S[0]) + len(S[1]) + len(S[2])):
N = n
if len(S[n]) > 0:
n = D[S[n][0]]
S[N].pop(0)
else:
print(str.upper(d[n]))
break |
p02971 | s811958334 | Accepted | import sys
inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instr = lambda: sys.stdin.readline()
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())
n = inint()
A = []
for _ in range(n):
A.append(inint())
sorted_A = sorted(A)[::-1]
for a in A:
if a != sorted_A[0]:
print(sorted_A[0])
else:
print(sorted_A[1])
|
p02646 | s282989432 | Accepted | A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
distance = abs(B-A)
diff = V-W
if distance - diff * T <= 0:
print('YES')
else:
print('NO')
|
p02601 | s120289321 | Accepted | a,b,c,k=map(int,open(0).read().split())
while a>=b:b*=2;k-=1
while b>=c:c*=2;k-=1
print('YNeos'[k<0::2]) |
p02923 | s618627364 | Accepted | N = int(input())
H = list(map(int, input().split()))
ans = 0
tmp = 0
for i in range(N-1):
if H[i] >= H[i+1]:
tmp += 1
else:
if ans < tmp:
ans = tmp
tmp = 0
if ans < tmp:
ans = tmp
print(ans) |
p03387 | s842296012 | Accepted | a,b,c = sorted(map(int,input().split()))
ans = 0
ans += (c-b)//2
b += (c-b)//2*2
ans += (c-a)//2
a += (c-a)//2*2
a,b,c = sorted([a,b,c])
if a==b and b!=c:
print(ans+1)
elif a==b==c:
print(ans)
elif b==c and b!=a:
print(ans+2) |
p02641 | s093934289 | Accepted | x,n=map(int,input().split())
a=list(map(int,input().split()))
i=0
while True:
if not x-i in a:
print(x-i)
break
if not x+i in a:
print(x+i)
break
i+=1 |
p03693 | s297689756 | Wrong Answer | r, g, b = map(int, input().split())
n = r * g * b
if n % 4 == 0:
print("YES")
else:
print("NO") |
p03835 | s824818355 | Accepted | k,s = map(int, input().split())
c=0
for i in range(k+1):
for j in range(k+1):
if s>=i+j and k+1+i+j>s :
c+=1
# print( c )
print( c ) |
p03105 | s274071874 | Accepted | a, b, c = map(int, input().split())
print(min(b//a,c)) |
p02988 | s570848919 | Wrong Answer | n=int(input())
t = input().split()
count = 0
for i in range(n-2):
A = t[i:i+3]
#print(A)
y = A[1]
A.sort()
if y == A[1]:
count += 1
print(count) |
p03854 | s526232810 | Accepted | import re
S = input()
print("YES" if re.match("^(dream|dreamer|erase|eraser)+$", S) else "NO")
|
p03061 | s777686209 | Accepted | import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
import fractions
from functools import reduce
def gcd(*numbers):
return abs(reduce(fractions.gcd, numbers))
L = [A[0]]
R = [A[-1]]
A_R = A[::-1]
for i in range(1, N):
L.append(fractions.gcd(L[-1], A[i]))
R.append(fractions.gcd(R[-1], A_R[i]))
R = R[::-1]
ans = R[1]
R.append(0)
for i in range(N - 1):
ans = max(ans, fractions.gcd(L[i],R[i+2]))
print(ans)
|
p02923 | s061532268 | Accepted | N = int(input())
H = list(map(int, input().split()))
start = 0
left = 0
right = 1
ans = 0
while right < N:
if H[left] >= H[right]:
left += 1
right += 1
else:
ans = max(ans, right - start - 1)
left = right
right += 1
start = left
ans = max(ans, right - start - 1)
print(ans) |
p03785 | s154244766 | Accepted | import sys
N, C, K = map(int ,input().split())
T = [int(input()) for _ in range(N)]
T.sort()
if C == 1:
print(N)
sys.exit()
cnt = 0
capacity = 0
time_limit = 0
for i in range(N):
if capacity == 0:
capacity += 1
time_limit = T[i] + K
continue
if capacity > 0:
if T[i] <= time_limit:
capacity += 1
if capacity == C:
cnt += 1
capacity = 0
continue
elif T[i] > time_limit:
cnt += 1
capacity = 1
time_limit = T[i] + K
print(cnt+1) |
p02582 | s595987937 | Accepted | W = input()
if W[0] == 'R' and W[1] == 'R' and W[2] == 'R':
print(3)
elif (W[0] == 'R' and W[1] == 'R') or (W[1] == 'R' and W[2] == 'R'):
print(2)
elif W[0] == 'S' and W[1] == 'S' and W[2] == 'S':
print(0)
else:
print(1) |
p02744 | s297507096 | Accepted | s = 'abcdefghij'
sg = s.__getitem__
def dfs(ans):
if len(ans) == n:
print(''.join(map(sg, ans)))
return
for i in range(max(ans) + 2):
ans.append(i)
dfs(ans)
ans.pop()
n = int(input())
dfs([0])
|
p02689 | s050322045 | Accepted | n, m = list(map(int, input().split()))
hs = list(map(int, input().split()))
ans = [1]*n
for i in range(m):
road = list(map(int, input().split()))
if hs[road[0]-1] <= hs[road[1]-1]:
ans[road[0]-1] = 0
if hs[road[0]-1] >= hs[road[1]-1]:
ans[road[1]-1] = 0
print(ans.count(1))
|
p03329 | s388644024 | Accepted | n=int(input())
money=[1]
dp=[0]*(n+1)
dp[1]=1
m=6
i=1
while m<=n:
money.append(m)
i+=1
m=6**i
m=9
i=1
while m<=n:
money.append(m)
i+=1
m=9**i
for m in money:
dp[m]=1
money.sort()
for i in range(1,n+1):
for m in money:
if i+m>=n+1:
continue
if dp[i]+1<=dp[i+m] or dp[i+m]==0:
dp[i+m]=dp[i]+1
print(dp[n]) |
p03698 | s224209361 | Accepted | S=list(input())
print("yes" if len(set(S))==len(S) else "no") |
p02720 | s789825105 | Accepted | from collections import deque
K = int(input())
Q = deque()
for i in range(1, 10):
Q.append(i)
while K > 0:
q = Q.popleft()
a = q % 10
if a == 0:
Q.append(q * 10)
Q.append(q * 10 + 1)
elif a == 9:
Q.append(q * 10 + 8)
Q.append(q * 10 + 9)
else:
Q.append(q * 10 + a - 1)
Q.append(q * 10 + a)
Q.append(q * 10 + a + 1)
K -= 1
print(q)
|
p03998 | s036261337 | Wrong Answer | """
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)]
print(*S,sep="")
"""
import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
data = {}
for x in ["a","b","c"]:
data[x] = input()
pick = "a"
while True:
data[pick] = data[pick][1:]
if data[pick] == "":
break
pick = data[pick][0]
print(pick.upper()) |
p03986 | s964826611 | Wrong Answer | X=input()
A=len(X)
for i in range(A//5):
X=X.replace("ST","")
print(len(X)) |
p02660 | s860524406 | Wrong Answer | import math
n = int(input())
#Prime factoring
pf = []
for i in range(2,math.ceil(n**0.5)+1):
temp = 0
while n%i==0:
n /= i
temp += 1
if temp:
pf.append(temp)
if n==1:
break
if not pf:
pf.append(1)
ans = 0
for i in range(len(pf)):
j = 1
while pf[i]-j>=0:
ans += 1
pf[i] -= j
j += 1
print(ans) |
p04020 | s110293946 | Accepted | n = int(input())
al = [int(input()) for _ in range(n)]
if n == 1:
print(al[0] // 2 * 2 // 2)
exit()
ans = 0
for i in range(n-1):
rest = ((al[i] + al[i+1]) // 2) * 2
ans += rest
for j in range(2):
if al[i+j] >= rest:
al[i+j] -= rest
break
else:
rest -= al[i+j]
al[i+j] = 0
print(ans//2) |
p03861 | s927560797 | Wrong Answer | a,b,x=map(int,input().split())
ans=abs(b-a+1)/x
ans_a=a/x
ans_b=b/x
print(round(ans_b-ans_a))
|
p02766 | s327833199 | Accepted | N, K = map(int, input().split())
count = 1
while N//K != 0:
N //= K
count += 1
print(count) |
p04012 | s698064719 | Accepted | from collections import Counter
w=input()
c=Counter(w).values()
s="Yes"
for i in c:
if i%2==1:
s="No"
print(s) |
p03261 | s904377960 | Accepted | n = int(input())
l = [input() for _ in [0]*n]
if len(set(l)) != n:
print('No')
else:
for i in range(n-1):
if l[i][-1] != l[i+1][0]:
print('No')
break
else:
continue
else:
print('Yes')
|
p02601 | s551578825 | Wrong Answer | r, g, b = map(int, input().split())
k = int(input())
for i in range(k):
if r < g < b:
break
else:
if b < g and b < r:
b *= 2
elif g < r:
g *= 2
else:
r *= 2
if r < g < b:
print("Yes")
else:
print("No") |
p03145 | s912442019 | Wrong Answer | a,b,c=map(int,input().split())
print(a*b/2) |
p03814 | s316037897 | Accepted | s = input()
print(s.rfind('Z') + 1 - s.find('A')) |
p02576 | s889299367 | Accepted | import sys,queue,math,copy,itertools,bisect,collections,heapq
def main():
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
SI = lambda : sys.stdin.readline().rstrip()
N,X,T = LI()
ans = math.ceil(N/X)*T
print(ans)
if __name__ == '__main__':
main() |
p03665 | s243871118 | Accepted | n, p = map(int, input().split())
a = list(map(int, input().split()))
dp = [[0, 0] for _ in range(n+1)]
dp[0][0] = 1
for i in range(n):
for j in range(2):
dp[i+1][j] += dp[i][j]
dp[i+1][(j+a[i])%2] += dp[i][j]
print(dp[n][p]) |
p02786 | s848727196 | Accepted | ##D
H = int(input())
x = 0
while H//2**x != 1:
x += 1
ans = 1
for i in range(x):
ans += 2**(i+1)
print(ans) |
p03000 | s518295662 | Wrong Answer | def next_pos(D,L):
return D+L
N, X = map(int,input().split(" "))
L = [int(i) for i in input().split(" ")]
D = 0
count = 0
for i in range(N):
if D<=X:
count+=1
D = next_pos(D,L[i])
print(count) |
p02787 | s360269240 | Accepted | h, n = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(n)]
#(a,b):=(ダメージ,消費魔力)
dp = [float('inf')] * (h + 1)
dp[0] = 0
for i in range(h + 1):
for j in range(n):
if dp[i] == float('inf'):continue
temp_a = i + ab[j][0] if i + ab[j][0] < h else h
temp_b = dp[i] + ab[j][1]
dp[temp_a] = min(dp[temp_a], temp_b)
print(dp[-1])
#print(dp)
|
p02882 | s992637734 | Accepted | import math
A, B ,X = map(int,input().split())
C = 2 * X / A / B
if C <= A:
print(math.degrees(math.atan(B/C)))
else:
C = 2*(A**2 * B - X) / (A**2)
print(math.degrees(math.atan(C/A)))
|
p03385 | s088426516 | Accepted | if sorted(list(input()))==["a","b","c"]:
print("Yes")
else:
print("No") |
p02556 | s242464922 | Accepted | import sys
input = sys.stdin.buffer.readline
INF = 10**18
N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
XY.sort()
ans = 0
x0, y0 = XY[0]
m1 = -x0+y0# 今ままでのmax
m2 = x0+y0
for x, y in XY:
ans = max(ans, x+m1 - y)
ans = max(ans, y - (-x+m2))
m1 = max(m1, -x+y)
m2 = min(m2, x+y)
print(ans) |
p02910 | s168946072 | Accepted | N = input()
print("No" if "L" in N[::2] or "R" in N[1::2] else "Yes") |
p03163 | s966941046 | Accepted | import numpy as np
import sys
def main():
input = sys.stdin.readline
n, W = map(int, input().split())
w, v = [0] * n, [0] * n
for i in range(n):
w[i], v[i] = map(int, input().split())
ndp = np.zeros(W + 1, dtype=np.int64)
for w, v in zip(w, v):
np.maximum(ndp[:-w] + v, ndp[w:], out=ndp[w:])
print(ndp[-1])
if __name__ == "__main__":
main() |
p04019 | s516891298 | Wrong Answer | s = input()
N = s.count('N')
S = s.count('S')
E = s.count('E')
W = s.count('W')
if (N >= 1 and S >= 1) or (E >= 1 and W >= 1):
print('Yes')
else:
print('No')
|
p02911 | s723322360 | Accepted | N, K, Q = map(int, input().split())
a_list = [int(input()) for _ in range(Q)]
point = [0] * N
for a in a_list:
point[a-1] += 1
for i in point:
if K - (Q - i) <= 0:
print('No')
else:
print('Yes')
|
p02766 | s739686019 | Accepted | N,K = map(int, input().split())
counter = 1
tmp = 1
while True:
tmp *= K
if tmp > N:
break
counter += 1
print(counter) |
p02719 | s334210909 | Wrong Answer | N, K = map(int, input().split())
if N == 0:
print(N)
elif K == 0:
print(K)
elif N < K:
k = K % N
ans = abs(N - k)
print(ans)
elif N > K:
k = N % K
ans = abs(K - k)
if k == 0:
print("0")
else:
print(ans)
else:
print("0") |
p04012 | s895131496 | Wrong Answer | s = input()
ss = list(set(s))
N = len(ss)
cnt = 0
for i in range(N):
cnt=cnt+s.count(ss[i])
if cnt%2==0:
print("Yes")
else:
print("No") |
p03281 | s838967578 | Wrong Answer | in_num = int(input())
check_num = 0
ans_counter = 0
while check_num <= in_num:
i = 1
div_counter = 0
while i <= check_num :
if check_num % i == 0:
div_counter += 1
i += 2
if div_counter == 8:
ans_counter += 1
check_num += 2
print(ans_counter)
|
p02601 | s917073329 | Accepted | a,b,c=map(int,input('').split())
k=int(input())
for i in range(k):
if a<b and b<c:
print("Yes")
exit()
if b<=a:
b*=2
continue
if c<=b:
c*=2
continue
if a<b and b<c:
print("Yes")
else:
print('No')
|
p03000 | s908166667 | Wrong Answer | n, x = map(int, input().split())
L = list(map(int, input().split()))
ans = 1
sum_L = 0
for j in range(n):
sum_L += sum_L + L[j]
if sum_L <= x :
ans += 1
else :
exit(0)
print(ans)
|
p02958 | s034018727 | Accepted | import copy
N=int(input())
p=[int(i) for i in input().rstrip().split()]
p_c=copy.deepcopy(p)
p_c.sort()
cnt=0
for i in range(len(p)):
if p[i]!=p_c[i]:
cnt+=1
else:
continue
if cnt==2 or cnt==0:
print("YES")
else:
print("NO") |
p02831 | s930318434 | Accepted | def gcd(a, b):
while b:
a, b = b, a % b
return a
def lcm(a, b):
return a * b // gcd (a, b)
A, B = list(map(int, input().split()))
print(lcm(A,B))
|
p02613 | s005175491 | Accepted | n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
k = input().upper()
if k == 'AC':
ac +=1
elif k == 'WA':
wa +=1
elif k == 'TLE':
tle +=1
elif k == 'RE':
re +=1
print('{} x {}'.format('AC',ac))
print('{} x {}'.format('WA',wa))
print('{} x {}'.format('TLE',tle))
print('{} x {}'.format('RE',re)) |
p03760 | s172682835 | Accepted | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
o = input().strip()
e = input().strip()
ans = []
for i, v in enumerate(o):
ans.append(v)
if (i != len(o) - 1) or (len(o) == len(e)):
ans.append(e[i])
print(''.join(ans))
|
p02665 | s514335752 | Accepted | N = int(input())
A = list(map(int, input().split()))
s = sum(A)
e = 1
ans = 1
flag = 1
if N == 0:
if s >= 2:
flag = 0
else:
ans = 1
else:
for i in range(N):
e = (e - A[i]) * 2
if e < A[i+1]:
flag = 0
break
tmp = min(e, s)
s -= A[i+1]
ans += tmp
if flag == 0:
print(-1)
else:
print(ans) |
p02628 | s306809547 | Accepted | n,k = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
ans = 0
for i in range(k):
ans += l[i]
print(ans) |
p02785 | s998829476 | Accepted | N, K = map(int,input().split())
H = list(map(int,input().split()))
H.sort(reverse=True)
print(sum(H[K:])) |
p02973 | s522802350 | Accepted | import bisect
n = int(input())
seq = []
for i in range(n):
seq.append(int(input()))
seq.reverse()
LIS = [seq[0]]
for i in range(1,len(seq)):
if seq[i] >= LIS[-1]:
LIS.append(seq[i])
else:
LIS[bisect.bisect_right(LIS, seq[i])] = seq[i]
print(len(LIS)) |
p03038 | s441869918 | Accepted | import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
from bisect import bisect_left
n, m = map(int, input().split())
a = list( map(int, input().split()))
a.sort()
bc = [tuple(map(int,input().split())) for i in range(m)]
bc = sorted(bc, reverse=True, key=lambda x: x[1])
i = 0
d = []
for b, c in bc:
d.extend([c]*b)
if len(d) >= n:
break
a=a+d
a.sort(reverse=True)
print(sum(a[:n]))
#l.sort(reverse=True)
#A=A+l[:N]
#A.sort(reverse=True)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.