problem_id
stringclasses 428
values | submission_id
stringlengths 10
10
| status
stringclasses 2
values | code
stringlengths 5
816
|
|---|---|---|---|
p04045
|
s588386474
|
Accepted
|
numbers = [str(e) for e in range(10)]
n, k = map(int, input().split())
hate_list = [e for e in input().split()]
available = set(numbers) - set(hate_list)
for i in range(n, 100000):
nums = set(str(i))
if nums <= available:
print(i)
break
|
p02630
|
s149698650
|
Accepted
|
N = int(input())
A_list = list(map(int, input().split()))
A_dict = {}
res = 0
for a in A_list:
res += a
if a in A_dict.keys():
A_dict[a] += 1
else:
A_dict[a] = 1
Q = int(input())
for i in range(Q):
b,c = map(int, input().split())
tmp = A_dict[b] if b in A_dict.keys() else 0
A_dict[b] = 0
if c in A_dict.keys():
A_dict[c] += tmp
else:
A_dict[c] = tmp
res += c*tmp - b*tmp
print(res)
|
p02994
|
s402965874
|
Accepted
|
N,L=map(int,input().split())
taste=[L+i-1 for i in range(1,N+1)]
j=0
for i in range(N):
if abs(taste[j])>abs(taste[i]):
j=i
print(sum(taste)-taste[j])
|
p03243
|
s496355340
|
Wrong Answer
|
n = list(input())
m = max(n)
print(m*3)
|
p02665
|
s713396244
|
Accepted
|
n,*a=map(int,open(0).read().split())
tot=sum(a)
v=[1]
for q in a:
tot-=q
vt=min(2*(v[-1]-q),tot)
if vt<0:
print(-1)
exit()
v.append(vt)
print(sum(v))
|
p02727
|
s612367341
|
Accepted
|
x, y, a, b, c = map(int, input().split())
ps = sorted(list(map(int, input().split())), reverse=True)[:x]
qs = sorted(list(map(int, input().split())), reverse=True)[:y]
rs = list(map(int, input().split()))
apples = sorted(ps + qs + rs, reverse=True)
print(sum(apples[:x+y]))
|
p02622
|
s745726574
|
Wrong Answer
|
a=input()
b=input()
c=len(a)
d=0
for i in range(c):
if a[i]==b[i]:
d=d+1
print(d)
|
p03767
|
s331845035
|
Wrong Answer
|
N = int(input())
a = list(map(int,input().split()))
a.sort()
print(sum(a[(3*N)-2*N:(3*N)-N]))
|
p03261
|
s173388346
|
Accepted
|
N=int(input())
W=[input() for _ in range(N)]
ans='Yes'
for i in range(N-1):
if W[i][-1] != W[i+1][0]:
ans='No'
break
if len(set(W))!=N:
ans='No'
print(ans)
|
p02993
|
s128198040
|
Accepted
|
S = input()
for i in range(3):
if S[i] == S[i+1]:
print("Bad")
exit()
print("Good")
|
p03329
|
s742306717
|
Wrong Answer
|
import sys
from io import StringIO
import unittest
sys.setrecursionlimit(100**3)
def rec(n, dp):
if n == 1:
return 1
if dp[n] < float('inf'):
return dp[n]
pow6 = 6
pow9 = 9
dp[n] = min(n, dp[n])
while n > pow6:
dp[n] = min(dp[n], rec(n-pow6, dp) + 1)
pow6 *= 6
while n > pow9:
dp[n] = min(dp[n], rec(n-pow9, dp) + 1)
pow9 *= 9
return dp[n]
def resolve():
n = int(input())
dp = [float('inf')]*(n+1)
print(rec(n, dp))
resolve()
|
p02556
|
s960130116
|
Wrong Answer
|
n = int(input())
dist = []
for i in range(n):
x, y = map(int, input().split())
dist.append(x + y)
dist.sort()
print(abs(dist[0] - dist[-1]))
|
p03351
|
s373547450
|
Accepted
|
a,b,c,d = map(int , input().split())
if abs(c -a) <= d :
print('Yes')
elif abs(b -a) <= d and abs(c -b) <= d:
print('Yes')
else:
print('No')
|
p02761
|
s906426457
|
Wrong Answer
|
N,M = input().split(' ')
numlist = []
for i in range(int(N)):
numlist.append('0')
for i in range(int(M)):
S,C = input().split(' ')
numlist[int(S)-1] = C
num = ''.join(numlist)
num = int(num)
if len(str(num)) == int(N):
print(int(num))
elif N == 1 & num == 0:
print(0)
else:
print(-1)
|
p02797
|
s967397467
|
Accepted
|
n, k, s = map(int, input().split())
dat = [999999999] * n
for i in range(k):
dat[i] = s
dat = list(map(str, dat))
print(" ".join(dat))
|
p02785
|
s427743840
|
Accepted
|
from collections import Counter
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort(reverse=True)
for i in range(k):
if i <= (n-1):
h[i] = 0
else:
break
print(sum(h))
|
p02748
|
s445283029
|
Accepted
|
A,B,M = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ans = 10**9
for i in range(M):
x,y,c = [int(i) for i in input().split()]
if ans > a[x-1] + b[y-1] - c:
ans = a[x-1] + b[y-1] - c
if ans > min(a) + min(b):
ans = min(a) + min(b)
print(ans)
|
p02689
|
s261730864
|
Wrong Answer
|
n,m = map(int,input().split())
H = list(map(int,input().split()))
ans = []
cut =[]
for i in range(m):
a,b = map(int,input().split())
ans.append(a)
ans.append(b)
if a in cut:
cut.append(a)
else:
cut.append(min(a,b))
ansset = set(ans)
cutset = set(cut)
print(len(ansset)-len(cutset))
|
p03417
|
s782112653
|
Wrong Answer
|
n,m = map(int, input().split())
ans = n*m
tmp = n + m - 2
print(ans - tmp * 2)
|
p02596
|
s139409736
|
Accepted
|
n=int(input())
if(n%2==0 or n%5==0):
print(-1)
else:
a=7
ans=1
flag=1
while(flag):
if(a%n==0):
print(ans)
flag=0
break
else:
ans+=1
s=str(a)
s1='7'
s2=int(s+s1)
a=(int(s2))%n
|
p03944
|
s374796469
|
Accepted
|
W,H,N = map(int, input().split())
m = [[0]*W]*H
import numpy as np
arr = np.array(m)
for i in range(N):
x, y, a = map(int, input().split())
if a == 1:
arr[:,:x] = 1
if a == 2:
arr[:, x:] = 1
if a == 3:
arr[H - y:,:] = 1
if a == 4:
arr[:H-y,:] = 1
print(np.count_nonzero(arr == 0))
|
p03328
|
s678331388
|
Accepted
|
A, B = map(int, input().split())
print(int((B - A )*( B - A +1)/2 - B ))
|
p02631
|
s724949958
|
Accepted
|
n = int(input())
a = list(map(int, input().split()))
p = 0
for i in range(n):
p = p ^ a[i]
for i in range(n):
print(p ^ a[i], end=' ')
|
p03779
|
s197963881
|
Accepted
|
import math
X=int(input())
a = (-1+(1+8*X)**(0.5))/2
print(int(math.ceil(a)))
|
p03611
|
s783725552
|
Wrong Answer
|
N=int(input())
a=list(map(int,input().strip().split()))
dp=[0 for n in range(max(a)+1)]
for n in range(N):
dp[a[n]]+=1
ans=0
for n in range(1,len(dp)-2):
ans=max(ans,dp[n-1]+dp[n]+dp[n+1])
print(ans)
|
p02947
|
s308102489
|
Accepted
|
import collections
n=int(input())
s=["".join(sorted(input())) for i in range(n)]
c=list(collections.Counter(s).values())
r=0
for x in c:
if x!=1:r+=(x*(x-1)//2)
print(r)
|
p02712
|
s926172455
|
Accepted
|
N = int(input())
N_list = [1,3,3,7,7,7,14,22,22,22,33,33,46,60,60]
N_add15 = [1,2,2,3,3,3,4,5,5,5,6,6,7,8,8]
num_15 = N // 15
n_list = N_list[N%15-1] + 15 * N_add15[N%15-1] * (num_15)
if(N < 16):
ans = N_list[N-1]
else:
ans = num_15 * num_15 * 60 + n_list
print(ans)
|
p02727
|
s663514018
|
Wrong Answer
|
def main():
X, Y, A, B, C = map(int, input().split())
aka_list = sorted([int(t) for t in input().split()],reverse=True)[:X]
midori_list = sorted([int(t) for t in input().split()],reverse=True)[:Y]
mu_list = sorted([int(t) for t in input().split()],reverse=True)[:X+Y]
j = 0
sum_list = sorted(aka_list + midori_list)
for i in range(len(sum_list)):
if sum_list[i] < mu_list[j]:
sum_list[i] = mu_list[j]
if j < C-1:
j += 1
print(sum(sum_list))
main()
|
p02548
|
s672963142
|
Wrong Answer
|
k=int(input())
n=k-1
val=n
for i in range(2,n):
val+=n//i
print(val+1)
|
p02935
|
s944339968
|
Accepted
|
n=int(input())
V=list(map(int, input().split()))
V = sorted(V)
while True:
if len(V) == 1:
break
new = (V[0]+V[1])/2
V = V[2:]
V.append(new)
V = sorted(V)
print(V[0])
|
p02584
|
s484470884
|
Accepted
|
x, k, d = map(int, input().split())
x = abs(x)
lap, rem = divmod(x, d)
if lap >= k:
print(x - k * d)
exit()
nokori = k - lap
rem0, rem1 = rem, d - rem
if nokori % 2 == 0:
print(rem0)
else:
print(rem1)
|
p03163
|
s110660317
|
Accepted
|
N,W=map(int,input().split())
w,v=[],[]
for i in range(N):
a,b=map(int,input().split())
w.append(a)
v.append(b)
dp=[[0]*(W+1) for i in range(N+1)]
for i in range(N):
for j in range(W+1):
if j-w[i]>=0:
dp[i+1][j]=dp[i][j-w[i]]+v[i]
dp[i+1][j]=max(dp[i+1][j],dp[i][j])
print(dp[N][W])
|
p03827
|
s492265766
|
Accepted
|
n = int(input())
s = input()
ans = 0
x = 0
for i in s:
if i == 'I':
x += 1
else:
x -= 1
ans = max(ans,x)
print(ans)
|
p03632
|
s749153153
|
Accepted
|
a,b,c,d = map(int,input().split())
overlap = max(0,(min(b,d)-max(a,c)))
print(overlap)
|
p03264
|
s729305501
|
Wrong Answer
|
K=int(input())
print((K/2)*((K+1)/2))
|
p03435
|
s234531859
|
Accepted
|
C = [list(map(int,input().split())) for _ in range(3)]
if C[0][0]-C[0][1]==C[1][0]-C[1][1]==C[2][0]-C[2][1] and C[0][1]-C[0][2]==C[1][1]-C[1][2]==C[2][1]-C[2][2] \
and C[1][0]-C[0][0]==C[1][1]-C[0][1]==C[1][2]-C[0][2] and C[2][0]-C[1][0]==C[2][1]-C[1][1]==C[2][2]-C[1][2]:
print("Yes")
else:
print("No")
|
p03478
|
s886749475
|
Wrong Answer
|
N, A, B = map(int, input().split())
Sum = 0
for i in range(N):
a = (i+1)//1000
b = (i+1)%1000//100
c = (i+1)%100//10
d = (i+1)%10
e= a+b+c+d
if e >= A and e <= B:
Sum = Sum + (i+1)
print(Sum)
|
p02789
|
s981381845
|
Accepted
|
a = list(map(int, input().split()))
if a[0] == a[1]:
print("Yes")
else:
print("No")
|
p02623
|
s370090702
|
Accepted
|
from sys import stdin
n, m, k = map(int, stdin.readline().rstrip().split())
a = list(map(int, stdin.readline().rstrip().split()))
b = list(map(int, stdin.readline().rstrip().split()))
A,B = [0],[0]
for i in range(n):
A.append(A[i]+a[i])
for i in range(m):
B.append(B[i]+b[i])
ans = 0
j = m
for i in range(n + 1):
if A[i] > k:
break
while A[i] > k- B[j]:
j -= 1
ans = max(ans, i + j)
print(ans)
|
p02802
|
s170066052
|
Accepted
|
n,m = map(int,input().split())
a = [0]*n
ac = 0
wa = 0
for i in range(m):
p,s = map(str,input().split())
p = int(p)
if s == "AC" and a[p-1] != -1:
ac +=1
wa += a[p-1]
a[p-1] = -1
elif s == "WA" and a[p-1] != -1:
a[p-1] += 1
print(ac,wa)
|
p03106
|
s960563000
|
Accepted
|
A,B,K=map(int,input().split())
div=[]
for i in range(1,max(A,B)+1):
if A%i==0 and B%i==0:
div+=[i]
print(div[-K])
|
p02753
|
s001318711
|
Wrong Answer
|
s=input()
if len(s)==3 or len(s)==0:
print("No")
else:
print("Yes")
|
p03071
|
s548431579
|
Wrong Answer
|
A,B = map (int, input ().split ())
p = 0
for i in range (2):
if A > B:
p += A
else:
p += B
print (p)
|
p02814
|
s410522788
|
Wrong Answer
|
import math
import fractions
from functools import reduce
def lcm_base(x, y):
return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
return reduce(lcm_base, numbers, 1)
n,m = (int(x) for x in input().split())
a = list(map(int, input().split()))
lc = int(lcm_list(a) // 2)
if lc > m: print(0)
else: print(int((m / lc) // 2 + 1))
|
p03795
|
s303394656
|
Accepted
|
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
n = int(input())
print(n*800 - n//15*200)
|
p03109
|
s864706856
|
Wrong Answer
|
a,b,c = input().split('/')
if int(a) <= 2019 and int(b) <= 4 and int(c) <=30:
print('heisei')
else:
print('TBD')
|
p02935
|
s762005500
|
Accepted
|
#138_C
import heapq
n = int(input())
v = list(map(int, input().split()))
heapq.heapify(v)
for _ in range(n-1):
x = heapq.heappop(v)
y = heapq.heappop(v)
heapq.heappush(v, (x+y)/2)
print(heapq.heappop(v))
|
p02835
|
s969977950
|
Accepted
|
a=list(map(int,input().split()))
if(sum(a)>=22):
print("bust")
else:
print("win")
|
p02576
|
s812186897
|
Accepted
|
n,x,t = map(int,input().split())
a = n / x +0.99999999999
print(int(a)*t)
|
p02693
|
s622923124
|
Wrong Answer
|
K = int(input())
A,B = input().split()
A = int(A)
B = int(B)
if K > B:
print("NG")
if A <= K and K <=B:
print("OK")
if K < B-A+1:
print("OK")
else:
print("NG")
|
p03161
|
s866684664
|
Accepted
|
N,K = map(int, input().split())
h = list(map(int, input().split()))
dp = [0] + [1000000000000]*(N-1)
for i in range(1,N):
for j in range(max(i-K,0),i):
dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]))
print(dp[-1])
|
p02953
|
s984207669
|
Accepted
|
n = int(input())
klist = list(map(int,input().split()))
hlist = klist[::-1]
for i in range(n-1):
if hlist[i]+1 < hlist[i+1]:
print('No')
break
if hlist[i]+1 == hlist[i+1]:
hlist[i+1] -= 1
else:print('Yes')
|
p03323
|
s165200643
|
Accepted
|
a,b= map(int,input().split())
if a<=8 and b<=8: print('Yay!')
else: print(':(')
|
p03323
|
s172472065
|
Wrong Answer
|
def main():
line = input()
A, B = [int(n) for n in line.split()]
if A <= 8:
print('Yay!')
else:
print(':(')
main()
|
p03219
|
s871965688
|
Wrong Answer
|
x, y = map(int, input().split())
print(x+y/2)
|
p02726
|
s215012754
|
Accepted
|
from itertools import combinations
n, x, y = map(int, input().split())
cnt = [0] * n
for i, j in combinations(range(n), 2):
i, j = i + 1, j + 1
dist = min(abs(j - i), abs(i - x) + abs(j - y) + 1,
abs(i - y) + abs(j - x) + 1)
cnt[dist] += 1
for i in range(1, n):
print(cnt[i])
|
p02911
|
s727278085
|
Accepted
|
n, k, q = map(int,input().split())
a = [input() for _ in range(q)]
b = [k for i in range(n)]
import numpy as np
np_b = np.array(b)
np_b -= q
np_backed_b = np_b.tolist()
for i in range(q):
np_backed_b[int(a[i])-1] +=1
for i in range(n):
if np_backed_b[i]<=0:
print('No')
else:
print('Yes')
|
p03250
|
s846587447
|
Accepted
|
l=list((map(int,input().split())))
ls=sorted(l,reverse=True)
print(ls[0]*10+ls[1]+ls[2])
|
p02959
|
s824582435
|
Accepted
|
import math
import re
import copy
import sys
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = 0
for i in range(n):
c += min(a[i],b[i])
if a[i] < b[i]:
c += min(a[i+1],b[i]-a[i])
a[i+1] -= min(a[i+1],b[i]-a[i])
print(c)
|
p03387
|
s482354507
|
Accepted
|
a=sorted(list(map(int, input().split())))
b=0
while(True):
if a[0]==a[1] and a[1]==a[2]:
print(b)
exit()
elif a[0]==a[1]:
a[0]+=1
a[1]+=1
else:
a[0]+=2
b+=1
a=sorted(a)
|
p03543
|
s884960334
|
Wrong Answer
|
n = input()
if int(n[1:]) % 111 == 0 or int(n[:-1]) % 111 == 0:
print("Yes")
else:
print("NO")
|
p02948
|
s928778700
|
Accepted
|
# D - Summer Vacation
import heapq
n, m = map(int, input().split())
w = [[0] for _ in range(m+1)]
for _ in range(n):
a, b = map(int, input().split())
if a<=m:
w[a].append(b)
ans = 0
hq = []
for i in range(1, m+1):
for j in w[i]:
heapq.heappush(hq, -j)
ans += heapq.heappop(hq)
print(ans * -1)
|
p03493
|
s481724517
|
Accepted
|
D = input()
DL = [D[i] for i in range(3)]
print(DL.count('1'))
|
p03673
|
s208360688
|
Accepted
|
n = int(input())
a = [int(x) for x in input().split()]
if n % 2 == 0:
b = a[n - 1 : 0 : -2] + a[0 : n - 1 : 2]
else:
b = a[n - 1 : : -2] + a[1 : n - 1 : 2]
print(*b)
|
p02802
|
s426787466
|
Wrong Answer
|
N, M = list(map(int, input().split()))
ac = 0
wa = 0
temp = -1
is_ac = False
temp_wa = 0
for i in range(M):
s = input().split()
no = int(s[0])
result = s[1]
if temp != no:
temp = no
temp_wa = 0
is_ac = False
if (not is_ac) and result == 'AC':
is_ac = True
ac += 1
wa += temp_wa
elif (not is_ac) and result == 'WA':
temp_wa += 1
print(str(ac) + " " + str(wa))
|
p03145
|
s657778256
|
Accepted
|
a, b, c = map(int, input().split())
print(a * b // 2)
|
p03485
|
s758407731
|
Accepted
|
a,b = map(int, input().split())
print((a+b+1)//2)
|
p03632
|
s331479119
|
Accepted
|
def main():
a, b, c, d = [int(e) for e in input().split()]
if d <= a or b <= c:
print(0)
elif a <= c and d <= b:
print(d - c)
elif c <= a and d <= b:
print(d - a)
elif a <= c and b <= d:
print(b - c)
elif c <= a and b <= d:
print(b - a)
if __name__ == "__main__":
main()
|
p02831
|
s736876211
|
Wrong Answer
|
def lcm(x, y):
return (x * y) // math.gcd(x, y)
def main(A, B):
A, B = list(map(int,input().split()))
print(lcm(A, B))
|
p02713
|
s638093677
|
Accepted
|
from itertools import product
from math import gcd
k = int(input())
result = 0
for a, b, c in product(range(1, k+1), repeat=3):
result += gcd(a, gcd(b, c))
print(result)
|
p02983
|
s161169502
|
Wrong Answer
|
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def solve():
l, r = MI()
mod = 2019
lst = []
for i in range(0, min(pow(2019, 2), r-l)+1):
t = (l + i) % mod
lst.append(t)
# print(t)
lst.sort()
print(lst[0] * lst[1])
if __name__ == '__main__':
solve()
|
p03705
|
s659636537
|
Accepted
|
n,a,b=map(int,input().split())
#整数の数はb-a+1
#最小の1つと最大の1つを除いたn-2個について考える
if n==1 and a!=b:
print(0)
exit()
elif n==1 and a==b:
print(1)
exit()
elif a>b:
print(0)
exit()
elif a==b:
print(1)
exit()
m=a*(n-2)#最小
M=b*(n-2)#最大
ans=M-m+1
print(ans)
|
p03449
|
s701927719
|
Accepted
|
n=int(input())
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
ans=0
for i in range(n):
tmp=0
tmp+=sum(a1[:i+1])
tmp+=sum(a2[i:])
ans=max(tmp,ans)
print(ans)
|
p02742
|
s785989917
|
Accepted
|
#!/usr/bin/env python3
H,W = [int(x) for x in input().split(" ")]
if H == 1 or W == 1:
ans = 1
elif H % 2 == 0 or W % 2 == 0:
ans = (H * W) // 2
else:
ans = (H - 1) * W // 2 + (W + 1) //2
print(ans)
|
p02971
|
s102844695
|
Wrong Answer
|
n = int(input())
a = [int(input()) for i in range(n)]
a_max = max(a)
a2 = a[:]
a2.remove(a_max)
a_second_max = max(a2)
for i in range(n):
if i == max:
print(a_second_max)
else:
print(a_max)
|
p03627
|
s180174804
|
Accepted
|
#!/usr/bin/env python
# coding: utf-8
# In[38]:
import collections
# In[52]:
N = int(input())
A = list(map(int, input().split()))
# In[54]:
a_cnt = collections.Counter(A)
p = sorted([i for i in a_cnt.items() if i[1] >= 2], reverse=True)
if len(p) > 0:
if p[0][1]>=4:
print(p[0][0]**2)
elif len(p) > 1:
print(p[0][0]*p[1][0])
else:
print(0)
else:
print(0)
# In[ ]:
|
p03161
|
s677238181
|
Accepted
|
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()
n, k = na()
h = na()
inf = 1 << 60
dp = [inf for i in range(n)]
dp[0] = 0
for i in range(n):
p = min(i + k + 1, n)
for j in range(i + 1, p):
dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]))
print(dp[n - 1])
|
p03427
|
s147786737
|
Wrong Answer
|
n=int(input())
t=list(str(n))
if n%10**(len(t)-1)==0:
print(9*(len(t)-1))
elif n%10**(len(t)-2)==0:
print(int(t[0])+9*(len(t)-1))
else:
print(int(t[0])-1+9*(len(t)-1))
|
p02786
|
s196305172
|
Accepted
|
#coding:utf-8
import sys,os
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
input = lambda: given().rstrip()
LMIIS = lambda: list(map(int,input().split()))
II = lambda: int(input())
XLMIIS = lambda x: [LMIIS() for _ in range(x)]
YN = lambda c : print('Yes') if c else print('No')
MOD = 10**9+7
H = II()
from math import log2,floor
print( 2**(floor(log2(H))+1)-1)
if __name__ == '__main__':
main()
|
p02623
|
s517141440
|
Accepted
|
import sys
readline = sys.stdin.readline
N,M,K = map(int,readline().split())
A = [0] + list(map(int,readline().split()))
B = [0] + list(map(int,readline().split()))
for i in range(1, len(A)):
A[i] += A[i - 1]
for i in range(1, len(B)):
B[i] += B[i - 1]
import bisect
ans = 0
for i in range(len(A)):
rest = K - A[i]
if rest < 0:
continue
if ans < i:
ans = i
b_read = bisect.bisect_right(B, rest)
if ans < i + b_read - 1:
ans = i + b_read - 1
print(ans)
|
p03323
|
s886479793
|
Accepted
|
A, B = map(int, input().split())
if A<8 and B <8:
print("Yay!")
elif A==8 and B == 8:
print("Yay!")
else:
print(":(")
|
p02911
|
s611139914
|
Accepted
|
n,k,q=map(int,input().split())
a=[int(input()) for i in range(q)]
p=[k-q]*n
for i in range(q):
#q回の正解が出る
r=a[i]-1
p[r]=p[r]+1
#正解したら1点多くなる
for i in range(n):
if p[i]>0:
print('Yes')
else:
print('No')
|
p03434
|
s356621554
|
Wrong Answer
|
N = int(input())
a = list(map(int,input().split()))
print(max(a)-min(a))
|
p02683
|
s377359793
|
Accepted
|
from operator import add
n,m,x=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]
ans=float('inf')
for i in range(2**n):
c=0
s=[0]*m
for b in range(n):
if i>>b&1:
c+=l[b][0]
for j in range(m):
s[j]+=l[b][j+1]
if all([e>=x for e in s]):
ans=min(ans,c)
if ans==float('inf'):
ans=-1
print(ans)
|
p02835
|
s489212958
|
Accepted
|
a=list(map(int,input().split()))
if sum(a)>=22:
print("bust")
elif sum(a)<=21:
print("win")
|
p02665
|
s032609190
|
Accepted
|
n = int(input())
a = list(map(int,input().split()))
cumsum_a = a.copy()
for i in range(n-1, -1, -1):
cumsum_a[i] += cumsum_a[i+1]
ans = 0
node = 1
for i in range(n + 1):
if a[i] > node:
ans = -1
break
ans += node
if i < n:
node = min(2 * (node - a[i]), cumsum_a[i + 1])
print(ans)
|
p02724
|
s488441189
|
Accepted
|
x = int(input())
a = x // 500
x = x - a * 500
b = x // 5
print(1000*a+5*b)
|
p02570
|
s616100982
|
Wrong Answer
|
d,t,s= map(int,input().split())
if s*t>=d:
print('yeah')
else:
print('No')
|
p02766
|
s700320247
|
Accepted
|
n, k = input().split()
n = int(n)
k = int(k)
res = 0
while n >= k:
n /= k
res += 1
res += 1
print(int(res))
|
p03162
|
s255977489
|
Accepted
|
N = int(input())
l = []
for i in range(N):
h = [int(x) for x in input().split()]
l.append(h)
DP=[[0 for i in range(3)] for j in range(N+1)]
for j in range(0,N):
for i in range(3):
DP[j+1][i%3] = max(DP[j][(i+1)%3]+l[j][i%3], DP[j][(i+2)%3]+l[j][i%3])
print(max(DP[N][0],DP[N][1],DP[N][2]))
|
p04012
|
s583640840
|
Accepted
|
from collections import Counter
s = list(input())
l = list(Counter(s).values())
for i in range(len(l)):
if l[i] % 2 == 1:
print('No')
exit()
print('Yes')
|
p03645
|
s499486065
|
Wrong Answer
|
N, M = map(int, input().split())
From = set()
To = set()
for _ in range(M):
a, b = map(int, input().split())
if a == 1:
From.add(b)
if b == N:
To.add(a)
if From.isdisjoint(To):
print("INPOSSIBLE")
else:
print("POSSIBLE")
|
p03069
|
s656702350
|
Wrong Answer
|
print(min(map(list(open(0))[1].count,"#.")))
|
p02922
|
s440167297
|
Wrong Answer
|
a, b = map(int, input().split())
count = 1
if b > 0:
while a < b:
a += a
count += 1
print(count)
else:
print(0)
|
p03077
|
s944128456
|
Wrong Answer
|
n=int(input())
l=list(int(input()) for _ in range(5))
print(n//min(l)+5)
|
p03681
|
s595921731
|
Accepted
|
n,m = map(int, input().split())
import math
mod = 10**9+7
if n==m:
ans = math.factorial(n) * math.factorial(m) *2
print(ans%mod)
elif abs(n-m)<2:
ans = math.factorial(n) * math.factorial(m)
print(ans%mod)
else:
print(0)
|
p02742
|
s324683222
|
Accepted
|
h, w = list(map(int, input().split()))
if h == 1 or w == 1:
print(1)
elif (h * w) % 2 == 0:
print((h * w) // 2)
else:
print(((h * w) // 2) + 1)
|
p02775
|
s749713258
|
Wrong Answer
|
n = input()
pay = ""
ret = ""
tmp = 0
for e in n[::-1]:
e = int(e)
e += tmp
if e <= 5:
pay += str(e)
ret += "0"
tmp = 0
else:
pay += str(0)
ret += str(10 - e)
tmp = 1
if tmp:
pay += str(tmp)
pay = pay[::-1]
ret = ret[::-1]
#print(pay, ret)
ans = 0
for e in pay:
ans += int(e)
for e in ret:
ans += int(e)
print(ans)
|
p04030
|
s963049091
|
Accepted
|
import sys
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
s = input()
stack = list()
for c in s:
if c == 'B':
if len(stack) > 0:
stack.pop()
else:
stack.append(c)
print(''.join(stack))
|
p03106
|
s334156739
|
Wrong Answer
|
a,b,k=map(int,input().split())
l=[]
for i in range(1,min(a,b)+1):
if a%i==0 and b%i==0:
l.append(i)
print(l[k-1])
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.