problem_id stringclasses 428
values | submission_id stringlengths 10 10 | status stringclasses 2
values | code stringlengths 5 816 |
|---|---|---|---|
p02793 | s631712650 | Wrong Answer | import numpy as np
from fractions import gcd
N=int(input())
A=list(map(int, input().split()))
A=np.array(A)
mod=10**9+7
def lcm(a,b):
return a//gcd(a,b)*b
LCM=1
for x in A:
LCM=lcm(LCM,x)
#print(LCM)
print(int((LCM//A).sum()%mod)) |
p03160 | s473072097 | Wrong Answer | import numpy as np
N = int(input())
heights = [int(i) for i in input().split()]
dp = np.full((N), np.Inf)
dp[0] = 0
dp[1] = heights[1] - heights[0]
for i in range(2, N):
dp[i] = min(
dp[i-2] + abs(heights[i] - heights[i-2]),
dp[i-1] + abs(heights[i] - heights[i-1]),
)
print(int(dp[N-1]))
|
p03773 | s900155690 | Accepted | a, b = map(int, input().split())
if a + b <= 23:
print(a + b)
else:
print((a + b) - 24) |
p02683 | s066783205 | Accepted | N, M, X= list(map(int, input().split()))
arr = [list(map(int, input().split())) for i in range(N)]
def rec(i, rikai, cost):
flag = True
for r in rikai:
if r <= 0: continue
else: flag = False
if flag:
return cost
if i == N:
return 10000000000000
use_rikai = [ rikai[j] - arr[i][j+1] for j in range(M) ]
use_cost = cost + arr[i][0]
return min(rec(i+1, use_rikai, use_cost), rec(i+1, rikai,cost))
rikai = [X for j in range(M)]
res = rec(0, rikai, 0)
if res >= 10000000000000:
print(-1)
else: print(res) |
p02711 | s325147886 | Accepted | N = input()
f = 'No'
for i in N:
if i == '7':
f = 'Yes'
print(f) |
p03105 | s156241705 | Accepted | a,b,c = map(int, input().split())
print(min(b//a,c)) |
p03625 | s005743568 | Accepted | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
lst1 = list(map(int,readline().split()))
ans = []
lst1.sort()
i = 0
while True:
if i >= n-1:
break
if lst1[i] == lst1[i+1]:
ans.append(lst1[i])
i += 1
i += 1
if len(ans) < 2:
print(0)
else:
print(ans[-1]*ans[-2]) |
p02657 | s663192055 | Wrong Answer | num1 = 100
num2 = 100
print(num1*num2) |
p03075 | s727080003 | Accepted | data = [int(input()) for i in range(5)]
k = int(input())
flag = True
for i in range(len(data)-1):
for j in range(i, len(data)):
if data[j]-data[i] > k:
flag = False
if flag:
print("Yay!")
else:
print(":(") |
p03387 | s181183522 | Accepted |
def main():
a = list(map(int, input().split()))
ans = 0
while True:
a.sort()
if a[0] == a[1] and a[1] == a[2]:
break
elif a[1] < a[2]:
a[0] += 1
a[1] += 1
else:
a[0] += 2
ans += 1
print(ans)
if __name__ == '__main__':
main()
|
p02717 | s500987953 | Wrong Answer | X,Y,Z = map(int,input().split())
print('{} {} {} '.format(Y,Z,X)) |
p02790 | s434449538 | Accepted | a, b = map(int, input().split())
if a > b:
print(str(b) * a)
else:
print(str(a) * b) |
p03817 | s280119229 | Wrong Answer | """
回転した後に得られる点数 = 上と下を向いている面以外の面に書かれている数
6→5→6→...と選んでいけばよさそう。
"""
X = int(input())
if X <= 6:
print(1)
elif X <= 11:
print(2)
else:
cnt = X // 11
X -= cnt * 11
if X == 0:
print(cnt * 2)
elif X < 6:
print(cnt * 2 + 1)
else:
print(cnt * 2 + 2)
|
p03456 | s025865966 | Accepted | from math import sqrt
a, b = input().split()
integer = int(a + b)
sqr_int = sqrt(integer)
if sqr_int.is_integer() == True:
print("Yes")
else:
print("No")
|
p03030 | s780495561 | Accepted | #!/usr/bin/python3
# -*- coding:utf-8 -*-
from collections import defaultdict
def main():
n = int(input())
sp = defaultdict(list)
sp2number = {}
for i in range(n):
s, p = input().strip().split()
p = int(p)
sp[s].append(p)
sp2number[(s, p)] = i + 1
for key in sorted(sp.keys()):
for score in sorted(sp[key], reverse=True):
print(sp2number[(key, score)])
if __name__=='__main__':
main()
|
p03385 | s049662187 | Wrong Answer | S = input()
if S in "a" and S in "b" and S in "c":
print("Yes")
else:
print("No") |
p03699 | s219304577 | Wrong Answer | import sys
input = sys.stdin.readline
n=int(input())
s=[int(input()) for i in range(n)]
s.sort()
ans=sum(s)
for i in range(1,n):
if ans%10!=0:
print(ans)
exit()
else:
if s[i]%10!=0:
ans-=s[i]
if i==n-1:
print(0)
|
p02663 | s569473566 | Wrong Answer | h1, m1, h2, m2, k = [int(i) for i in input().split()]
time = 60*h2+m2 - 60*h1+m1 - k
if time > 0:
print(time)
else:
print(0) |
p03455 | s936601060 | Accepted | a, b = map(int, input().split())
if (a*b)%2:
print("Odd")
else:
print("Even") |
p03673 | s683997140 | Accepted | n = int(input())
a = list(map(int, input().split()))
if n % 2 == 0:
for i in reversed(range(1, n, 2)):
print(a[i],end=" ")
for i in range(0,n-1,2):
print(a[i],end=" ")
elif n % 2 == 1:
for i in reversed(range(0, n, 2)):
print(a[i],end=" ")
for i in range(1, n, 2):
print(a[i],end=" ") |
p02772 | s037069503 | Accepted | n = int(input())
a = [int(i) for i in input().split()]
count1 =0
count2 = 0
for i in a:
if i%2==0:
count1+=1
if i%3==0 or i%5 == 0:
count2+=1
else:
pass
if count1 == count2:
print('APPROVED')
else:
print("DENIED") |
p03773 | s099112152 | Accepted | def coder(a,b):
if a + b < 24:
return a + b
else:
return ((a + b) % 24)
def main():
a , b = map(int, input().split())
print(coder(a , b))
if __name__ == '__main__':
main() |
p02601 | s075577724 | Accepted | a, b, c = map(int, input().split())
k = int(input())
ans = 0
while a >= b:
ans += 1
b *= 2
while b >= c:
ans += 1
c *= 2
print("Yes" if ans <= k else "No") |
p02910 | s169948413 | Wrong Answer | s=input()
flg=False
for i in range(len(s)):
if i%2==0 and s[i]=='R':
flg=True
if i%2==1 and s[i]=='L':
flg=True
if flg:
print('No')
else:
print('Yes')
|
p02958 | s179674210 | Accepted | n = int(input())
A = list(map(int, input().split( )))
cnt = 0
for i in range(n):
if A[i] != i+1:
cnt += 1
if cnt <= 2:
print('YES')
else:
print('NO')
|
p02817 | s982000934 | Accepted | test1, test2 = input().split()
ans = test2 + test1
print(ans) |
p03479 | s429653028 | Accepted | X,Y=map(int,input().split())
ans=0
while X<=Y:
X*=2
ans+=1
print(ans) |
p02572 | s467951014 | Accepted |
import collections
from functools import lru_cache
import bisect
INF = float("inf")
ZERO = 0
ONE = 1
def read():
return input().strip()
def readInt():
return int(input().strip())
def readList():
return list(map(int, input().strip().split()))
def solve(N, arr):
ans = 0
MOD = 10**9 + 7
totalSum = sum(arr) % MOD
currSum = 0
for num in arr:
currSum += num
ans = (ans + num * (totalSum - currSum)) % MOD
return ans % MOD
N = readInt()
arr = readList()
print(solve(N, arr))
|
p03317 | s895995898 | Wrong Answer | N,K=map(int,input().split())
A=list(map(int,input().split()))
M=K-1
if N%M==0:
print(N//M)
else:
print(N//M+1) |
p02640 | s132419269 | Accepted | import sys
x,y=list(map(int, input().split()))
for i in range(0,101):
for j in range(0,101):
if i+j==x and i*4+j*2==y:
print("Yes")
sys.exit()
print("No") |
p03475 | s995727780 | Accepted | 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):
t = 0
for j in range(i,N - 1):
if t < S[j]:
t = S[j]
elif t % F[j] == 0:
pass
else:
t = t + F[j] - (t % F[j])
t += C[j]
print(t) |
p02899 | s461865565 | Accepted | n = int(input())
a = list(map(int, input().split()))
b = sorted(enumerate(a), key=lambda x:x[1])
c = [b[i][0]+1 for i in range(n)]
d = [str(x) for x in c]
e = " ".join(d)
print(e) |
p02753 | s506295624 | Accepted | s = input()
if s == "AAA" or s == "BBB":
print("No")
else:
print("Yes") |
p02900 | s535299372 | Accepted | from fractions import gcd
a, b = map(int,input().split())
GCD = gcd(a,b)
ans = 1
for i in range(2, int(GCD ** 0.5) + 1):
if GCD%i == 0:ans += 1
while GCD%i == 0:
GCD //= i
if GCD != 1:ans += 1
print(ans) |
p02988 | s733465915 | Accepted | import sys
input = lambda: sys.stdin.readline().rstrip()
def solve():
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(n - 2):
if (p[i] < p[i + 1] and p[i + 1] < p[i + 2]) or (p[i] > p[i + 1] and p[i + 1] > p[i + 2]):
count += 1
print(count)
if __name__ == '__main__':
solve()
|
p02719 | s170361421 | Wrong Answer | N, K = [int(i) for i in input().split()]
n = N
c = True
while(c):
if n > K:
# n - abs(n - K) => n - (n - K) => K > 0
n = n - int(n / K) * K
elif n < K:
# n - abs(n - K) => n - (K - n) => 2n - K
if 2 * n - K > 0:
n = K - n
else:
c = False
else:
# n == K で n - abs(n - K) => n(変更後も同じ)
c = False
print(n) |
p02983 | s315276107 | Wrong Answer | l,r=map(int,input().split())
if r-l>2019:
print(0)
exit()
ans=int(10000000)
for i in range(l,r):
for j in range(i+1,r+1):
if ans>i*j:
ans=i*j
print(ans) |
p02578 | s304129145 | Accepted | INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
n=INT()
A=LIST()
ans=0
mina=0
for a in A:
mina=max(mina,a)
ans+=max(0,mina-a)
print(ans)
if __name__ == '__main__':
do() |
p02814 | s632432159 | Accepted | from fractions import gcd
from math import ceil
n,m=map(int,input().split())
a=list(map(int,input().split()))
c=len(bin(a[0]))-bin(a[0]).rfind("1")
for i in range(1,n):
if c!=len(bin(a[i]))-bin(a[i]).rfind("1"):
print(0)
exit()
g=a[0]
for i in range(n-1):
g=(g//gcd(g,a[i+1]))*(a[i+1]//gcd(g,a[i+1]))*gcd(g,a[i+1])
g//=2
print(ceil((m//g)/2))
|
p03633 | s939569138 | Accepted | import math
def lcm(x,y):
return x*y//math.gcd(x,y)
N = int(input())
T = int(input())
for i in range(1,N):
S = int(input())
T = lcm(S,T)
print(T) |
p02755 | s075030868 | Accepted | tax_a, tax_b = map(int, input().split())
ans = tax_b * 10
for i in range(9):
if int(ans * 0.08) == tax_a:
print(ans)
break
else:
ans += 1
else:
print('-1')
|
p03030 | s606087184 | Accepted | d = []
for i in range(int(input())):
s, p = input().split()
d += (i + 1, s, int(p)),
d.sort(key = lambda l: (l[1], -l[2]))
for i, _, __ in d:print(i) |
p03449 | s499452014 | Accepted | n = int(input())
a = []
for i in range(2):
a.append(list(map(int, input().split())))
# print(a)
ans = 0
for i in range(1, n+1):
total = sum(a[0][:i])+sum(a[1][i-1:])
if total > ans:
ans = total
print(ans)
|
p02995 | s432557433 | Wrong Answer | import sys
input = sys.stdin.readline
import fractions
def main():
A, B, C, D = list(map(int, input().split()))
Aone = A - 1
lcm = int(C / fractions.gcd(C, D) * D)
Bc = int(B / C)
Bd = int(B / D)
Blcm = int(B / lcm)
Bdec = Bc + Bd - Blcm
# print(Bc,Bd,Blcm)
Ac = int(Aone / C)
Ad = int(Aone / D)
Alcm = int(Aone / lcm)
Adec = Ac + Ad - Alcm
# print(Ac,Ad,Alcm)
print(B - A + 1 - (Bdec - Adec))
main() |
p02970 | s506302519 | Wrong Answer | def golden_apple(n, d):
ans = -(-n//(d*2))
return ans
def main():
n, d = map(int, input().split())
print(golden_apple(n, d))
if __name__ == '__main__':
main()
|
p02766 | s529982626 | Accepted | n, k = map(int, input().split())
c = 0
while n != 0:
n //= k
c += 1
print(c) |
p03131 | s894715271 | Accepted | k,a,b = map(int,input().split())
if b-a <= 1 or k <= a:
print(k+1)
else:
print(((k-(a+1))//2)*(b-a)+b+((k-(a+1))%2)) |
p02607 | s736150714 | Accepted | import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
a = LI()
ans = 0
for i, A in enumerate(a):
if (i+1) % 2 == 1:
if A % 2 == 1:
ans += 1
print(ans) |
p03951 | s826213305 | Wrong Answer | import sys
N = int(input())
s = input()
t = input()
ans = s+t
for i in range(N):
if s[i:N] == t[0:N-i]:
ans = s[0:i]+s[i:N]+t[N-i:N]
print(len(ans)) |
p03011 | s750992271 | Wrong Answer | P,Q,R = map(int, input().split())
A = [P+Q, P+R, Q+R]
print(A)
|
p02689 | s932192685 | Accepted | N, M = map(int,input().split())
H = list(map(int,input().split()))
A, B = [], []
for _ in range(M):
a, b = map(int,input().split())
A.append(a)
B.append(b)
L = [1] * N
for i in range(M):
ai = A[i] - 1
bi = B[i] - 1
if H[ai] > H[bi]:
L[bi] = 0
elif H[bi] > H[ai]:
L[ai] = 0
else:
L[ai], L[bi] = 0, 0
print(L.count(1)) |
p03417 | s715572296 | Accepted | N, M = [int(x) for x in input().split()]
def sol(N,M):
if N==0 or M==0:
return 0
elif N==1 or M==1:
return abs(abs(N-M)-1)
x = (abs(3-N)+1)*(M-2)
y = (abs(3-M)+1)*abs((N-2))
return min(x,y)
print(sol(N,M)) |
p03086 | s445359883 | Accepted | s = input().strip()
n = len(s)
acum = [0] * (n + 1)
acgt = ['A', 'C', 'G', 'T']
for i in range(1, n + 1):
if s[i - 1] in acgt:
acum[i] = acum[i - 1] + 1
else:
acum[0] = 0
print(max(acum))
|
p02948 | s322703553 | Accepted | import heapq
n , m = map(int, input().split())
ab=[[] for i in range(10**5)]
for i in range(n):
a , b = map(int, input().split())
ab[a-1].append(b*(-1))
que=[]
ans = 0
for i in range(m):
for b in ab[i]:
heapq.heappush(que,b)
if que:
ans+=heapq.heappop(que)
print(ans*(-1))
|
p02813 | s234925350 | Accepted | N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))
from itertools import permutations
from math import factorial
X=[i+1 for i in range(N)]
X_list = list(permutations(X))
P=tuple(P)
Q=tuple(Q)
ans=[0,0]
for j in range(factorial(N)):
if X_list[j]==P:
ans[0] = j
break
for k in range(factorial(N)):
if X_list[k]==Q:
ans[1] = k
break
print(abs(ans[0]-ans[1]))
|
p03479 | s217409205 | Accepted | x,y = map(int,input().split())
ans = 0
while x<=y:
x *= 2
ans += 1
print(ans) |
p03555 | s777316921 | Accepted | A = input()
B = input()
if A[0] == B[2] and A[1] == B[1] and A[2] == B[0]:
print('YES')
else:
print('NO') |
p03146 | s328161560 | Accepted | from sys import stdin
s = int(stdin.readline().strip())
mem = []
a = s
for i in range(1000000):
if a in mem:
print(i+1)
exit()
mem.append(a)
if a % 2 == 0: a = a // 2
else: a = 3 * a + 1 |
p03127 | s407420516 | Accepted | n = int(input())
A = list(map(int, input().split()))
def gcd(a, b):
while b != 0:
a, b = b, a % b
return a
# 初期値の設定
ans = A[0]
for i in range(1, n):
ans = gcd(ans, A[i])
print(ans) |
p02987 | s065445681 | Accepted | s=str(input())
l=[s[0],s[1],s[2],s[3]]
l.sort()
if l[0]==l[1] and l[2]==l[3] and l[0]!=l[2]:
print("Yes")
else:
print("No") |
p03723 | s359962914 | Accepted | a, b, c = list(map(int, input().split(' ')))
if a % 2 == 0 and a == b == c:
print(-1)
else:
count = 0
while True:
if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
print(count)
break
a, b, c, = (b + c) // 2, (c + a) // 2, (a + b) // 2
count += 1
|
p02861 | s887680871 | Wrong Answer | N = int(input())
pts = [(list(map(int,input().split()))) for _ in range(0,N)]
from itertools import combinations
def f(x1,y1,x2,y2):
dx = x2 - x1
dy = y2 - y1
return (dx**2+dy**2)**0.5
dst = 0
for i,j in combinations(range(0,N),2):
dst += f(pts[i][0], pts[i][1], pts[j][0], pts[j][1])
print(dst / (N // 2)) |
p02724 | s143789585 | Wrong Answer | s = int(input())
print((s//500)*1000 + ((s%500)%5)*5 ) |
p03835 | s740042051 | Wrong Answer | K, S = map(int, input().split())
res = 0
for x in range(K + 1):
for y in range(K + 1):
z = S- x + y
if z>=0 and z<=K:
res += 1
print(res) |
p03013 | s681365950 | Wrong Answer | MOD=10**9+7
n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
if 1 in a and 2 in a:
print(0)
exit()
elif 1 in a:
ans=[0,1]
elif 2 in a:
ans=[1,0]
else:
ans=[1,2]
for i in range(2,n):
if i+1 in a:
ans.append(0)
else:
s=(ans[-1]+ans[-2])%MOD
ans.append(s)
print(ans[-1]%MOD) |
p03493 | s565375562 | Accepted | print(input().count("1")) |
p03698 | s382931773 | Wrong Answer | s = input()
dif = True
for i in range(len(s)-1):
if s[i] == s[i+1]:
dif = False
print("yes" if dif else "no") |
p03161 | s648484460 | Accepted | import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
n,k = na()
h = na()
A = [0]+[float("inf")]*(n-1)
for i in range(1,n):
for j in range(max(0, i-k), i):
A[i] = min(A[i],A[j]+abs(h[i]-h[j]))
print(A[-1]) |
p02818 | s799614255 | Accepted | import sys
def stdin_parse_int():
a = list(map(int,input().split()))
return a
list = stdin_parse_int()
A = list[0]
B = list[1]
K = list[2]
if A > K:
print(str(A-K) + " " + str(B))
elif A+B > K:
print(str(0) + " " + str(A+B-K))
else:
print("0 0")
|
p03038 | s805418429 | Wrong Answer | N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
import bisect
for i in range(M):
B,C=map(int,input().split())
p=bisect.bisect_right(A,C)
for k in range(min(B,p-1)):
A[k]=C
A.sort()
print(sum(A)) |
p02946 | s807012535 | Accepted | k,x=map(int,input().split())
s=""
for i in range(-k+1,k):
s+=str(x+i)+' '
print(s) |
p03827 | s216847057 | Wrong Answer | x = int(input())
s = input()
li = []
c = 0
for i in range(x):
if s[i] == "I":
c += 1
li.append(c)
else:
c -= 1
li.append(c)
print(max(li)) |
p03644 | s906945833 | Accepted | N = int(input())
for i in range(7):
if 2**i <= N:
s = i
print(2**s) |
p03478 | s026029502 | Wrong Answer | n,a,b = map(int,input().split())
ans = 0
for i in range(n):
if a<=sum(map(int,list(str(i))))<=b:
ans += i
print(ans) |
p03438 | s191442168 | Accepted | N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
import math
count_1up = 0
count_2up = 0
for a, b in zip(A, B):
if a - b >= 0:
count_1up += a - b
else:
count_2up += math.ceil((b - a) / 2)
diff = sum(B) - sum(A)
# print(diff, count_1up, count_2up)
if diff < 0:
print("No")
elif diff < count_1up or diff < count_2up:
print("No")
else:
print("Yes") |
p02916 | s823691970 | Wrong Answer | N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
count=sum(B)
print(count)
for i in range(N-1):
if A[i]+1==A[i+1]:
count=count+C[A[i]-1]
print(count) |
p03657 | s148065473 | Wrong Answer | a,b = map(int, input().split())
if a % 3 == 0 or b % 3 == 0 or a+b % 3 == 0:
print("Possible")
else:
print("Impossible") |
p03385 | s959398255 | Accepted | def resolve():
s = sorted(input())
if s[0] == 'a' and s[1] == 'b' and s[2] == 'c':
print('Yes')
else:
print('No')
return
if __name__ == "__main__":
resolve()
|
p02910 | s269737627 | Accepted | S = input()
ok = 1
for i in range(len(S)):
if i % 2 == 1 and S[i] not in ['L', 'U', 'D']:
ok = 0
if i % 2 == 0 and S[i] not in ['R', 'U', 'D']:
ok = 0
print('Yes' if ok else 'No')
|
p02613 | s797434432 | Accepted | N = int(input())
AC=0
WA=0
TLE=0
RE=0
for i in range(N):
S = input()
if S == "AC":
AC+=1
elif S == "WA":
WA+=1
elif S == "TLE":
TLE +=1
else:
RE +=1
print("AC x "+str(AC))
print("WA x "+str(WA))
print("TLE x "+str(TLE))
print("RE x "+str(RE)) |
p02767 | s133493965 | Accepted | from statistics import mean
import math
n = int(input())
citizen = list(map(int,input().split()))
hostF = math.floor(mean(citizen))
hostC = math.ceil(mean(citizen))
ansF = 0
ansC = 0
for i in citizen:
ansF += (hostF-i)**2
ansC += (hostC-i)**2
ans = ansF if ansF<ansC else ansC
print(int(ans))
|
p02785 | s348418981 | Accepted | h,n=map(int,input().split())
x=[int(i) for i in input().split()]
y=sorted(x,reverse=True)
print(sum(y[n:])) |
p02676 | s186836188 | Accepted | import sys
K = int(input())
S = input()
if(len(S)<=K):
print(S)
else:
print(S[:K]+"...") |
p02973 | s652003375 | Accepted | import bisect
from collections import deque
N = int(input())
A = [int(input()) for _ in range(N)]
c = deque()
c.append(A[0])
for i in range(1, N):
j = bisect.bisect_right(c, A[i]-1)
if j == 0:
c.appendleft(A[i])
else:
c[j-1] = A[i]
print(len(c))
|
p02787 | s917220399 | Accepted | h,n = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(n)]
ma = max(a for a,b in ab)
dp = [10**10]*(h+ma+1)
dp[0] = 0
for i in range(1,h+ma+1):
dp[i] = min(dp[i-a]+b for a,b in ab)
print(min(dp[h:]))
|
p02693 | s267471610 | Accepted | K = int(input())
A, B = map(int, input().split())
for c in range(A, B + 1):
if c % K == 0:
print("OK")
break
else:
print("NG") |
p02833 | s104446591 | Accepted | # import math
N = int(input())
# Nが奇数の場合は-2していくと全て奇数になるので答えは0
# Nが偶数の場合を検討するべし
# Nが偶数の場合、明らかに2の倍数より5の倍数の方が少ないので5の倍数がいくつかで考える
if (N % 2 == 1):
print(0)
exit()
bunbo = 0
sum_5 = 0
while (10 * 5 ** bunbo) <= N:
sum_5 += N // (10 * 5**bunbo)
bunbo += 1
print(sum_5)
|
p02675 | s666605199 | Wrong Answer | n = int(input()) % 10
if n == 3:
print("bon")
elif n == 0 or 1 or 6 or 8:
print("pon")
else:
print("hon")
|
p02718 | s319706697 | Accepted | input_line = input().split(" ")
N=int(input_line[0])
M=int(input_line[1])
count=0
input_line = input().split(" ")
total=0
for i in range(len(input_line)):
total=total+int(input_line[i])
border=total/(4*int(M))
for i in range(len(input_line)):
if int(input_line[i])>=border:
count=count+1
if count>=M:
print("Yes")
else:
print("No")
# input_line=' '.join(input_line) |
p03645 | s840578087 | Accepted | N,M = map(int,input().split())
ans = 0
dic = {str(i):0 for i in range(1,N)}
for _ in range(M):
a,b = map(int,input().split())
if a == 1:
dic[str(b)] += 1
if dic[str(b)] == 2:
ans = 1
if b == N:
dic[str(a)] += 1
if dic[str(a)] == 2:
ans = 1
if ans == 0:
print('IMPOSSIBLE')
else:
print('POSSIBLE') |
p03779 | s753901529 | Accepted | x = int(input())
for i in range(x+1):
if (i*(i+1)) / 2 >= x:
print(i)
quit() |
p02813 | s084936233 | Accepted | from itertools import permutations
n = int(input())
a = [i+1 for i in range(n)]
a = permutations(a)
p = list(map(int, input().split()))
q = list(map(int, input().split()))
dict_order = sorted(a)
pi = dict_order.index(tuple(p))
qi = dict_order.index(tuple(q))
print(abs(pi - qi)) |
p02801 | s526252924 | Wrong Answer | C = input()
A = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in range(24):
if A[i] == C:
print(A[i+1]) |
p02677 | s528794983 | Accepted | A,B,H,M=map(int,input().split())
import math #三角関数・円周率
import numpy
H = H + M / 60
H_A = H / 12 * 360 * math.pi /180
M_A = M / 60 * 360 * math.pi / 180
H_x = math.cos(H_A) * A #針の先端の座標計算(中心基準)
H_y = math.sin(H_A) * A
M_x = math.cos(M_A) * B
M_y = math.sin(M_A) * B
a = numpy.array([H_x, H_y])
b = numpy.array([M_x, M_y])
u = b - a
print(numpy.linalg.norm(u)) |
p02963 | s139487741 | Wrong Answer | s = int(input())
x = s % 10 ** 9 * -1
y = s // (10 ** 9)
print(0, 0, 10 ** 9, 1, x, y) |
p02957 | s045470003 | Accepted | A,B,=map(int,input().split())
if (A+B)%2==0:
print((A+B)//2)
else:
print("IMPOSSIBLE") |
p02989 | s060413105 | Wrong Answer | n = int(input())
d = list(map(int,input().split()))
d.sort
i = int(len(d)/2)
if d[i] == d[i-1]:
print(0)
else:
print(d[i] - d[i-1]) |
p02835 | s330678672 | Accepted | li=list(map(int,input().split()))
if sum(li)>=22:
print('bust')
else:
print('win') |
p03693 | s581173789 | Accepted | # 入力 文字列3つ
r, g, b = input().split()
# 並べた数字が4の倍数か
rgb = r + g + b
if int(rgb)%4 :
print("NO")
else :
print("YES")
|
p02683 | s916019890 | Wrong Answer | import sys
import numpy as np
def Ii():return int(sys.stdin.buffer.read())
def Mi():return map(int,sys.stdin.buffer.readline().split())
def Li():return list(map(int,sys.stdin.buffer.readline().split()))
n,m,x = Mi()
a = []
b=[0]*m
b = np.array(b)
for i in range(n):
a.append(Li())
ans = 10**6
def DFS(cost,start,skill):
global ans
if min(skill) >= x:
ans = min(ans,cost)
return ans
for i in range(start,n):
DFS(cost+a[i][0],i+1,skill+np.array(a[i][1:]))
return ans
a = DFS(0,0,b)
if a == 10**6:
a = -1
print(a) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.