s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time stringlengths 1 5 | memory stringlengths 1 7 | code_size stringlengths 1 6 | code stringlengths 1 539k |
|---|---|---|---|---|---|---|---|---|---|---|---|
s743886120 | p03779 | u450339194 | 1561430957 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 307 | INF = float("inf")
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()
X = n()
dp = [0] * (X+1)
dp[1] = 1
for i in range(2, X+1):
if dp[i - dp[i-1]] < dp[i-1]:
dp[i] = dp[i-1]
else:
dp[i] = dp[i-1]+1
print(dp[X])
|
s299108132 | p03779 | u534953209 | 1559261767 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 75 | X = int(input())
i = 0
sum = 0
while sum < X:
i += 1
sum += i
print(i) |
s405332992 | p03779 | u502389123 | 1558713605 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 101 | X = int(input())
sum = 0
for i in range(1, N):
sum += i
if sum >= X:
break
print(i) |
s450800340 | p03779 | u623819879 | 1558240009 | Python | PyPy3 (2.4.0) | py | Runtime Error | 183 | 38384 | 85 | x=int(input())
for i in range(x**0.5+100):
if i*(i+1)//2>=x:
print(i)
break |
s373457737 | p03779 | u091051505 | 1555884384 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 170 | import bisect
x = int(input())
num_list = list(range(x))
a = [0]*x
a[0] = num_list[0]
for i in range(1,x):
a[i] = a[i-1] + num_list[i]
print(bisect.bisect_left(a, x)) |
s780785264 | p03779 | u159994501 | 1555710832 | Python | Python (3.4.3) | py | Runtime Error | 74 | 3928 | 210 | def an(a, b): # a is time b is place
if a > b:
return float('INF')
elif a == b:
return a
else:
return min(an(a + 1, b), an(a + 1, b - a))
X = int(input())
print(an(1, X))
|
s584353770 | p03779 | u844646164 | 1555021068 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 348 | import sys
f = open('ABC.txt', 'r')
sys.stdin = f
import bisect
n = int(input())
x = 0
i = 1
x_list = []
while x <= n:
x += i
if x > n:
break
x_list.append(x)
i += 1
if n == 2:
print(2)
else:
if n in x_list:
print(x_list.index(n)+1)"""
else:
idx = bisect.bisect_left(x_list, n)
idx -= 2
... |
s703539923 | p03779 | u091051505 | 1554348187 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3188 | 170 | import bisect
x = int(input())
num_list = list(range(x))
a = [0]*x
a[0] = num_list[0]
for i in range(1,x):
a[i] = a[i-1] + num_list[i]
print(bisect.bisect_left(a, x)) |
s257733492 | p03779 | u091051505 | 1554347717 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3060 | 170 | import bisect
x = int(input())
num_list = list(range(x))
a = [0]*x
a[0] = num_list[0]
for i in range(1,x):
a[i] = a[i-1] + num_list[i]
print(bisect.bisect_left(a, x)) |
s131582167 | p03779 | u785578220 | 1548365430 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 149 | a = int(input())
s = 0
if i < 3:print(a)
else:
for i in range(1,a):
s+=i
if s-i < a <= s:
print(i)
break |
s557080328 | p03779 | u513081876 | 1546133115 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 102 | X = int(input())
for i in range(1, 10**6):
if X <= 0.5 * i (i + 1):
print(i)
break |
s547607864 | p03779 | u944209426 | 1535630494 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 148 | x=int(input())
n=int((2*int(input()))**0.5)
if n*(n-1)<2*x<=n*(n+1):
print(n)
elif (n-1)*(n-2)<2*x<=n*(n-1):
print(n-1)
else:
print(n+1) |
s074698754 | p03779 | u807772568 | 1534263127 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 124 | a = int(input())
i = 1
j = 0
ans = 0
while True:
ans += 1
j += i
i += 1
if j >= a:
print(ans)
break |
s387055589 | p03779 | u333945892 | 1532479188 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 103 | X = int(input())
N = int(math.sqrt(2*X))-1
while True:
if N*(N+1)//2 >= X:
print(N)
break
N += 1 |
s813568988 | p03779 | u226746496 | 1529109294 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 112 | X = int(input())
for i in range(0, X):
result += (i+1)
if X >= result:
print(i+1)
break |
s582123504 | p03779 | u925364229 | 1518303482 | Python | Python (3.4.3) | py | Runtime Error | 25 | 2940 | 110 | X = int(input())
sumval = 0
for i in range(1,X):
sumval += i
if sumval >= X:
ans = i
break
print(ans)
|
s214544994 | p03779 | u943004959 | 1516302835 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3060 | 360 | from bisect import bisect_left, bisect_right, insort_left, insort_right
def solve():
x = int(input())
cumulative_sum = [(k * (k - 1)) // 2 for k in range(1, 46)]
target = bisect_left(cumulative_sum, x)
if x in cumulative_sum:
print(cumulative_sum.index(x))
else:
print(target - 1 + ... |
s327457241 | p03779 | u813450984 | 1515452239 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 109 | def f(n, l):
sum = 0
for i in range(1, n+1):
sum += i
if sum >= n:
return i
print(f(n, l)) |
s973563923 | p03779 | u495415554 | 1511844140 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 92 | https://www.lifehacker.jp/2017/11/171127_kakei_17.html?utm_source=dlvr.it&utm_medium=twitter |
s730644991 | p03779 | u817328209 | 1499239581 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 137 | X = int(input())
L = 0
for t in range(1, X) :
L += t
if L >= X :
print(t)
break |
s586258331 | p03779 | u817328209 | 1499239020 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 74 | X = int(input())
L = 0
for i in range(1, X) :
L += i
if L >= X :
|
s237809265 | p03779 | u351527281 | 1497580786 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 148 | num = int(input())
i = 1
while True:
bef = range(1,i)
i += 1
aft = range(1,i)
if bef < num <= aft:
print(i-1)
break
|
s348022778 | p03779 | u351527281 | 1497580682 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 147 | num = int(input())
i = 0
while True:
bef = range(1,i)
i += 1
aft = range(1,i)
if bef < num <= aft:
print(i-1)
break |
s555814402 | p03779 | u939822134 | 1492196579 | Python | Python (3.4.3) | py | Runtime Error | 31 | 2940 | 143 | import sys
X = int(input())
if X == 1:
print(1)
elif X > 1:
for i in range(2,1000000000):
if X <= i*(i + 1)/2:
t = i
break
print(i) |
s207419522 | p03779 | u939822134 | 1492187018 | Python | Python (3.4.3) | py | Runtime Error | 32 | 2940 | 141 | import sys
X = int(input())
if X == 1:
print(1)
elif X > 1:
for i in range(2,100000):
if X <= i*(i + 1)/2:
t = i
break
print(i)
|
s633310934 | p03779 | u026450699 | 1491350353 | Python | Python (2.7.6) | py | Runtime Error | 11 | 2568 | 359 | X = int(raw_input())
def makeValue(x, n):
if(n == 0):
return False
if(x == n):
return True
if(x == -n):
return True
if(makeValue(x - n, n - 1)):
return True
if(makeValue(x + n, n - 1)):
return True
return False
for i in range(1, X + 1):
if(makeValue... |
s614637677 | p03779 | u775600206 | 1491194649 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 101 | # -*- coding: utf-8 -*-
X= int(raw_input().split())
a = 0
while X >0:
a += 1
X -= a
print a |
s004503184 | p03779 | u775600206 | 1491194571 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 105 | # -*- coding: utf-8 -*-
X= map(int,raw_input().split())
a = 0
while X >0:
a += 1
X -= a
print a |
s780035138 | p03779 | u732844340 | 1489981740 | Python | Python (3.4.3) | py | Runtime Error | 73 | 4036 | 304 | y = []
x = 0
def slv(h, i):
if x == h or i >= x:
if x == h:
y.append(i - 1)
return
slv(h+i, i+1) # jump
slv(h, i+1) # stay
if __name__ == '__main__':
x = abs(int(input()))
slv(0, 0)
if len(y) == 0:
print(2)
else:
print(min(y)) |
s794608992 | p03779 | u732844340 | 1489980888 | Python | Python (3.4.3) | py | Runtime Error | 75 | 3976 | 299 | y = []
def slv(x,h,i):
if x == h or i >= x:
if x == h:
y.append(i)
return
slv(x,h+i,i+1) # jump
slv(x,h,i+1) # stay
if __name__ == '__main__':
x = int(input())
slv(abs(x),0,0)
if len(y) == 0:
print(2)
else:
print(min(y) - 1) |
s110556744 | p03779 | u732844340 | 1489980731 | Python | Python (3.4.3) | py | Runtime Error | 78 | 3952 | 2324 | y = []
def slv(x,h,i): ... |
s777535457 | p03779 | u181709987 | 1489962476 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 217 | import math
X = int(input())
n = math.sqrt(2*X) -1
def sum(a):
x = 0
for i in range(a+1):
x += i
return x
for i in range(n,X+1):
if sum(i)>= X:
result = i
break
print(result) |
s726296909 | p03779 | u762603420 | 1489891463 | Python | Python (2.7.6) | py | Runtime Error | 28 | 3556 | 331 | # -*- coding: utf-8 -*-
def check(t, n, idx):
if t == n + idx or t == n - idx:
return idx
if idx >= t and t > 0:
return t
elif t < 0 and idx * -1 <= t:
return idx
return min(check(t, n + idx, idx + 1), check(t, n - idx, idx + 1), check(t, n, idx + 1))
X = int(input())
print(chec... |
s942067376 | p03779 | u846552659 | 1489891150 | Python | Python (3.4.3) | py | Runtime Error | 76 | 4080 | 429 | # -*- coding:utf-8 -*-
def search(t, x, i):
# print('t:'+str(t)+' x:'+str(x)+' i:'+str(i))
global X
# print(l)
# print('X:'+str(X))
if x == X:
#l.append(t)
return t
elif x > X:
ans1 = search(i, x, i+1)
ans2 = search(i, x-i, i+1)
return min(ans1, ans2)
els... |
s565309695 | p03779 | u762603420 | 1489891084 | Python | Python (2.7.6) | py | Runtime Error | 27 | 3604 | 272 | # -*- coding: utf-8 -*-
def check(t, n, idx):
if t == n + idx or t == n - idx:
return idx
if idx >= t:
return t
return min(check(t, n + idx, idx + 1), check(t, n - idx, idx + 1), check(t, n, idx + 1))
X = int(raw_input())
print(check(X, 0, 1)) |
s558518750 | p03779 | u070154761 | 1489890624 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 322 | x = int(raw_input())
ans = 0
count = 0
half = x / 2
array = range(x + 1)
for i in range(x):
if x == 2 or x == 1:
break
if sum(array) == x:
break
elif sum(array[:len(array) - 2]) < x:
array.pop()
break
else:
array.pop()
count += 1
print array[len(array) - 1... |
s551398409 | p03779 | u070154761 | 1489889965 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 139 | x = int(raw_input())
ans = 0
count = 0
for i in range(x + 1):
ans += i
if ans >= x:
count = i
break
print count |
s737710397 | p03779 | u112002050 | 1489889791 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 143 | import math
X = int(input())
l = list(range(1,math.ceil(X / 2)))
while l:
if sum(l) < X:
print(len(l)+1)
break
l.pop()
|
s615607699 | p03779 | u622568141 | 1489888132 | Python | Python (3.4.3) | py | Runtime Error | 73 | 3960 | 230 | X = int(input())
def move(i, x):
if x == X:
return i
elif i > X:
return X+1
else:
if x > X:
return min([move(i+1, x-(i+1)), move(i+1, x)])
else:
return min([move(i+1, x+(i+1)), move(i+1, x)])
print((move(0,0)))
|
s605631762 | p03779 | u762603420 | 1489888086 | Python | Python (2.7.6) | py | Runtime Error | 24 | 3536 | 355 | # -*- coding: utf-8 -*-
def check(t, now, idx):
if t < idx:
return 99999999999
# use
use = 999999999999
if t == now + idx:
use = idx
elif t > now + idx:
use = check(t, now + idx, idx + 1)
# not use
nuse = check(t, now, idx + 1)
return min(use, nuse)
X = int(raw_... |
s400336464 | p03779 | u762603420 | 1489887864 | Python | Python (2.7.6) | py | Runtime Error | 23 | 3536 | 331 | # -*- coding: utf-8 -*-
def check(t, now, idx):
if t < idx:
return 99999999999
# use
use = -1
if t == now + idx:
use = idx
else:
use = check(t, now + idx, idx + 1)
# not use
nuse = check(t, now, idx + 1)
return min(use, nuse)
X = int(raw_input())
print(str(check... |
s776554042 | p03779 | u239375815 | 1489886652 | Python | Python (3.4.3) | py | Runtime Error | 72 | 4164 | 172 | def move(i=0,cx=0):
global m
if(cx+i==X):
m=min(m,i)
elif cx+i<X:
move(i+1,cx+i)
move(i+1,cx)
X=int(input())
m=10**9
move()
print(m)
|
s190968494 | p03780 | u792078574 | 1600923502 | Python | PyPy3 (7.3.0) | py | Runtime Error | 101 | 68568 | 1162 | from itertools import accumulate
import numpy as np
def main():
N, K = map(int, input().split())
As = list(map(int, input().split()))
dp = np.array([0] * (K+1))
dp[0] = 1
nonzeros = [np.array([0])]
for a in As:
ndp = np.array([0] * (K+1))
nonzero = []
for i in range... |
s916191854 | p03780 | u787059958 | 1600563385 | Python | Python (3.8.2) | py | Runtime Error | 2456 | 144184 | 1802 | def main():
N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))
rdp_shift = [N + 1] * K # rdp_shift[j] = (右からi個を使って部分和jを作れるような最初のi)
rdp_shift[0] = 0
rdp = [0] * K # rdp[i][j] = (a(-1),...,a(-i)の部分和でjを作れるか)
rdp[0] = 1
for i in range(N):
rdp2 = [0] * K
... |
s904850911 | p03780 | u787059958 | 1600554618 | Python | Python (3.8.2) | py | Runtime Error | 428 | 205548 | 615 | N, K = map(int, input().split())
A = sorted(map(int, input().split()))
sum_A = sum(A)
if sum_A < K:
print(len(A))
exit()
elif sum_A == K:
print(0)
exit()
dp = [[False] * len(A) for i in range(len(A))]
sum_A_list = []
for i in range(N):
if i == 0:
sum_A_list.append(A[i])
continue
... |
s309607244 | p03780 | u036104576 | 1598729801 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 9848 | 1341 | import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readl... |
s109505350 | p03780 | u036104576 | 1598727325 | Python | PyPy3 (7.3.0) | py | Runtime Error | 1414 | 230636 | 1249 | import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readl... |
s116819832 | p03780 | u107639613 | 1597812142 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2208 | 106580 | 1183 | import sys
def input(): return sys.stdin.readline().strip()
def main():
N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))
"""
(aが不要なカード)=(A-{a}からK-a以上の最小の部分和を取った時、それがK以上)
まで言い換えてドボン。。。
部分和の全列挙しなくても和がKまでで打ち切っていいんだから、ここでdpの発想が出なかったのは切腹。
まずは部分点解法を実装してみる。
"""
an... |
s072651500 | p03780 | u107639613 | 1597811826 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2208 | 107792 | 1248 | import sys
from bisect import bisect_left
def input(): return sys.stdin.readline().strip()
def main():
N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))
"""
(aが不要なカード)=(A-{a}からK-a以上の最小の部分和を取った時、それがK以上)
まで言い換えてドボン。。。
部分和の全列挙しなくても和がKまでで打ち切っていいんだから、ここでdpの発想が出なかったのは切腹。
... |
s352917027 | p03780 | u074220993 | 1597608860 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 10700 | 1338 | import collections
N, K = map(int, input().split())
a = [int(x) for x in input().split() if int(x) < K]
a.sort()
def renew_dp(dp, List, K): #Listの部分和がiならばdp[i]=True
for x in List:
dp_ = dp.copy()
for i in range(1,K):
if i-x < 0:
continue
if dp[i-x]:
... |
s250092134 | p03780 | u074220993 | 1597598138 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 45036 | 853 | N, K = map(int, input().split())
a = [int(x) for x in input().split() if int(x)<K]
def bfs(List, remain, K): #幅優先探索
over_K = K
for x in List:
if x == remain: #和がKとなる部分集合を構成できる場合
return 0
for x in List:
if over_K == 0: #over_K=0なら即リターン
return over_K
next_remai... |
s158055254 | p03780 | u895641117 | 1597095805 | Python | Python (3.8.2) | py | Runtime Error | 2211 | 219652 | 685 | n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
ok = n
ng = -1
while ok - ng > 1:
mid = (ok + ng) // 2
a[mid] ^= a[n - 1]
a[n - 1] ^= a[mid]
a[mid] ^= a[n - 1]
dp = [[False for j in range(k)] for i in range(n)]
dp[0][0] = True
for i in range(n - 1):
f... |
s729650551 | p03780 | u873915460 | 1595632944 | Python | PyPy3 (7.3.0) | py | Runtime Error | 111 | 74860 | 391 | N,K=map(int,input().split())
A=sorted(filter(lambda x:x<K,list(map(int,input().split()))))
N=len(A)
def judge(x):
DP=1
Z=(1<<K)-1
for i in range(N):
if i!=x:
DP=((DP|(DP<<A[i]))&Z)
r=0
for i in range(K-A[x],K):
r|=(DP&(1<<i))
return r
if judge(0):
print(0)
exit()
L,R,M=1,N,0
while L!=R:
... |
s782174089 | p03780 | u786020649 | 1595390517 | Python | Python (3.8.2) | py | Runtime Error | 73 | 9436 | 1472 | import sys
def biser(lst,func):
n=len(lst)
nh=n//2
if n==1:
if func(lst[0]):
return lst[0]
else:
return -1
if func(lst[nh]):
return biser(lst[nh:],func)
else:
return biser(lst[:nh],func)
def mkns(a,s,m):
if a==0:
return s
else... |
s959919414 | p03780 | u786020649 | 1595307761 | Python | Python (3.8.2) | py | Runtime Error | 2214 | 313616 | 1463 | import sys
sys.setrecursionlimit(4100000)
def biser(lst,func):
n=len(lst)
nh=n//2
if n==1:
if func(lst[0]):
return lst[0]
else:
return -1
if func(lst[nh]):
return biser(lst[nh:],func)
else:
return biser(lst[:nh],func)
def findminsum(lst,K,N)... |
s584133649 | p03780 | u786020649 | 1595307108 | Python | Python (3.8.2) | py | Runtime Error | 2217 | 314044 | 1391 | import sys
sys.setrecursionlimit(10000)
def biser(lst,func):
n=len(lst)
nh=n//2
if n==1:
return lst[0]
if func(nh):
return biser(lst[nh:],func)
else:
return biser(lst[:nh],func)
def findminsum(lst,K,N):
inf=10**6
dp=[[inf]*N for s in range(K+1)]
for s in range(... |
s616810890 | p03780 | u786020649 | 1595306925 | Python | Python (3.8.2) | py | Runtime Error | 2213 | 314456 | 1361 | import sys
def biser(lst,func):
n=len(lst)
nh=n//2
if n==1:
return lst[0]
if func(nh):
return biser(lst[nh:],func)
else:
return biser(lst[:nh],func)
def findminsum(lst,K,N):
inf=10**6
dp=[[inf]*N for s in range(K+1)]
for s in range(K+1):
for j in range(N... |
s076228924 | p03780 | u786020649 | 1595303381 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9096 | 984 | import sys
def findminsum(lst,K,N,dp):
for s in range(K+1):
for j in range(N):
if j==0 and s<=lst[j]:
dp[s][j]=lst[0]
elif s>lst[j] and j>0:
dp[s][j]=min(dp[s-lst[j]][j-1]+lst[j], dp[s][j-1])
elif s<=lst[j] and j>0:
dp[s][j... |
s363538031 | p03780 | u786020649 | 1595300166 | Python | Python (3.8.2) | py | Runtime Error | 388 | 204960 | 917 | import sys
def findminsum(lst,K,N):
inf=10**10
dp=[[inf]*N for s in range(K+1)]
for s in range(K+1):
for j in range(N):
if j==0 and s<=lst[j]:
ds[s][j]=lst[0]
elif s>lst[j] and j>0:
dp[s][j]=min(dp[s-lst[j]][j-1]+lst[j], dp[s][j-1])
... |
s615384881 | p03780 | u786020649 | 1595300122 | Python | Python (3.8.2) | py | Runtime Error | 27 | 8896 | 916 | import sys
def findminsum(lst,K,N):
inf=10**10
dp=[[inf]*N for s in range(K+1)]
for s in range(K+1):
for j in range(N):
if j==0 and s<=lst[j]
ds[s][j]=lst[0]
elif s>lst[j] and j>0:
dp[s][j]=min(dp[s-lst[j]][j-1]+lst[j], dp[s][j-1])
... |
s633754127 | p03780 | u893063840 | 1595084544 | Python | Python (3.8.2) | py | Runtime Error | 2210 | 156484 | 854 | import numpy as np
from numba import njit
n, k = map(int, input().split())
a = tuple(map(int, input().split()))
dp = np.zeros((n + 1, k), bool)
dp[0][0] = True
for i, e in enumerate(a, 1):
dp[i] = dp[i-1]
dp[i, e:] |= dp[i-1, :-e]
dp2 = np.zeros((n + 1, k), bool)
dp2[0][0] = True
for i, e in enumerate(a[::-1... |
s916073188 | p03780 | u893063840 | 1595083727 | Python | Python (3.8.2) | py | Runtime Error | 2209 | 187364 | 1088 | from numba import njit
@njit
def solve(n, k, a):
dp = [[0] * k for _ in range(n + 1)]
dp[0][0] = 1
for i, e in enumerate(a, 1):
for j in range(k):
dp[i][j] = dp[i-1][j]
for j in range(k - e):
if dp[i-1][j]:
dp[i][j+e] = 1
dp2 = [[0] * k for _ i... |
s129914045 | p03780 | u047796752 | 1594179628 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2247 | 1275964 | 715 | import sys
input = sys.stdin.readline
def judge(x):
b = [a[i] for i in range(N) if i!=x]
dp = [[0]*K for _ in range(N)]
dp[0][0] = 1
for i in range(N-1):
for j in range(K):
dp[i+1][j] += dp[i][j]
if j+b[i]<K:
dp[i+1][j+b[i]] += dp[i][j]
... |
s238829741 | p03780 | u144913062 | 1591305628 | Python | PyPy3 (2.4.0) | py | Runtime Error | 169 | 38384 | 1144 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int N, K;
cin >> N >> K;
vector<int> a(N);
REP(i, N) cin >> a[i];
vector... |
s858912470 | p03780 | u368796742 | 1590947181 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2135 | 490632 | 928 | n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
if a[0] >= k:
print(0)
exit()
if sum(a) < k:
print(n)
exit()
def search(m):
if m >= k:
return True
x = k-a[m]
dp = [[float("INF")]*(x+1) for i in range(n)]
dp[0][0] = 0
now = 0
for i in range(n):
... |
s797779768 | p03780 | u368796742 | 1590946168 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2136 | 529032 | 833 | n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
if a[0] >= k:
print(0)
exit()
def search(m):
if m >= k:
return True
x = k-a[m]
dp = [[float("INF")]*(x+1) for i in range(n)]
dp[0][0] = 0
now = 0
for i in range(n):
if i == m:
continue
... |
s977871764 | p03780 | u368796742 | 1590946097 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2146 | 523016 | 834 | n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
if a[0] >= k:
print(0)
exit()
def search(m):
if m >= k:
return True
x = k-a[m]
dp = [[float("INF")]*(x+1) for i in range(n)]
dp[0][0] = 0
now = 0
for i in range(n):
if i == m:
continue
... |
s035676346 | p03780 | u368796742 | 1590946029 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2139 | 513160 | 797 | n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
def search(m):
if m >= k:
return True
x = k-a[m]
dp = [[float("INF")]*(x+1) for i in range(n)]
dp[0][0] = 0
now = 0
for i in range(n):
if i == m:
continue
for j in range(x+1):
... |
s049605204 | p03780 | u368796742 | 1590945895 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2134 | 476936 | 838 | n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
if sum(a) < k:
print(n)
exit()
def search(m):
if m >= k:
return True
x = k-a[m]
dp = [[float("INF")]*(x+1) for i in range(n)]
dp[0][0] = 0
now = 0
for i in range(n):
if i == m:
continu... |
s095013842 | p03780 | u519923151 | 1589480453 | Python | Python (3.4.3) | py | Runtime Error | 2117 | 213748 | 631 |
n,k = map(int, input().split())
al = list(map(int, input().split()))
if sum(al) < k:
print(n)
exit()
res = 0
for h in range(n):
dp=[[0 for i in range(k)] for j in range(n)]
dp[0][0]=1
judge =0
newal = sorted(al)
xk = k-newal[h]
newal.pop(h)
for i in range(n-1):
for j in ra... |
s937928634 | p03780 | u519923151 | 1589480312 | Python | Python (3.4.3) | py | Runtime Error | 2117 | 213748 | 623 |
n,k = map(int, input().split())
al = list(map(int, input().split()))
if sum(al) < k:
print(n)
exit()
dp=[[0 for i in range(k)] for j in range(n)]
dp[0][0]=1
res = 0
for h in range(n):
judge =0
newal = sorted(al)
xk = k-newal[h]
newal.pop(h)
for i in range(n-1):
for j in range(k):
... |
s775040780 | p03780 | u519923151 | 1589480231 | Python | Python (3.4.3) | py | Runtime Error | 2117 | 213736 | 621 |
n,k = map(int, input().split())
al = list(map(int, input().split()))
if sum(al) < k:
print(n)
exit()
dp=[[0 for i in range(k)] for j in range(n)]
dp[0][0]=1
res = 0
for h in range(n):
judge =0
newal = sorted(al)
xk = k-newal[h]
newal.pop(h)
for i in range(n-1):
for j in range(k):
... |
s187436218 | p03780 | u519923151 | 1589479007 | Python | Python (3.4.3) | py | Runtime Error | 2129 | 414452 | 900 | n,k = map(int, input().split())
al = list(map(int, input().split()))
if sum(al) < k:
print(n)
exit()
newal = sorted(al)
for m in range(n):
if newal[m] >k:
cut = m
al = newal[:cut]
break
n = len(al)
dp=[[0 for i in range(k*2)] for j in range(n)]
dp[0][0]=1
res = 0
for h in range(n... |
s616091373 | p03780 | u519923151 | 1589478619 | Python | Python (3.4.3) | py | Runtime Error | 2130 | 414196 | 890 | n,k = map(int, input().split())
al = list(map(int, input().split()))
if sum(al) < k:
print(n)
exit()
newal = sorted(al)
for m in range(n):
if newal[m] >k:
cut = m
break
al = newal[:m]
n = len(al)
dp=[[0 for i in range(k*2)] for j in range(n)]
dp[0][0]=1
res = 0
for h in range(n):
jud... |
s493960813 | p03780 | u519923151 | 1589477712 | Python | Python (3.4.3) | py | Runtime Error | 2129 | 414712 | 897 | n,k = map(int, input().split())
al = list(map(int, input().split()))
if sum(al) < k:
print(n)
exit()
dp=[[0 for i in range(k*2)] for j in range(n)]
dp[0][0]=1
res = 0
for h in range(n):
if newal[h] > k:
pass
else:
judge =0
newal = sorted(al)
xk = k-newal[h]
newa... |
s715691118 | p03780 | u724687935 | 1587025921 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2106 | 49628 | 719 | N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
# [ok, ng) - Maximum
# (ng, ok] - Minimum
# ok が 最終的な答え
ok = N
ng = -1
while abs(ok - ng) > 1:
mid = (ok + ng) // 2
n = mid
dp = set()
dp.add(0)
ans = set(x for x in range(max(0, K - A[n] + 1), K))
for i in range(N):... |
s739324970 | p03780 | u724687935 | 1587023835 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2133 | 465800 | 624 | def solve(n):
global N, K
dp = [[0] * (K + 1) for _ in range(N + 1)]
dp[0][0] = 1
for i in range(N):
a = 0 if i == n else A[i]
for j in range(K + 1):
dp[i + 1][min(K, j + a)] |= dp[i][j]
dp[i + 1][j] |= dp[i][j]
rst = any(dp[N][k] for k in range(K - A[n], K))
... |
s461493376 | p03780 | u498487134 | 1584205983 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2106 | 41916 | 1342 | def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def main():
N,K=MI()
a=LI()#下位の連続するn枚が不要なはず
a.sort()
for i in range(N):#K以上ならば必要
if a[i]>=K:
a=a[:i]
N=len(a)
#x... |
s892766207 | p03780 | u141610915 | 1583806086 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2106 | 44764 | 555 | import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
def check(x):
dp = [0] * (K + 1)
dp[0] = 1
for i in range(N):
for j in range(K - 1, -1, -1):
if i == x: continue
if dp[j]:
dp[min(K, j + a[i])] = dp[j]
for j in range(max(... |
s542723987 | p03780 | u863442865 | 1583789405 | Python | Python (3.4.3) | py | Runtime Error | 543 | 12620 | 863 | import numpy as np
import itertools
N, K = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
def check(i): #i番目のカードを使わなかった時
dp = np.zeros(K, dtype = np.bool)
#dp[k]はkが作れる時True
#保持する情報はTrue/Falseのみで良いので1次元DPを上書きしていく(1回でまとめて)
dp[0] = True
for j in itertools.chain(a[:i], a[i+1:])... |
s936795142 | p03780 | u863442865 | 1583711547 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2129 | 427536 | 1391 | '''
1枚抜いてDPをN枚についてやれば良い, がこれでは間に合わない
そこで必要不要の境界を二分探索で探す
するとO(N^2K)→O(NKlogN)となって間に合う
もう1つの方法は分からない
'''
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000000)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combination... |
s112313096 | p03780 | u905582793 | 1583137950 | Python | PyPy3 (2.4.0) | py | Runtime Error | 195 | 40560 | 852 | from itertools import accumulate
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
acc = list(accumulate(a))
def maxsum(ls,k):
l = len(ls)
if l==0:
return 0
dp = [0 for i in range(l+1)]
dp[0] = 1
for i in range(1,l+1):
dp[i] = (dp[i-1]|(dp[i-1]<<ls[i-1]))&(1<<k)
for b in ra... |
s512308653 | p03780 | u905582793 | 1583137911 | Python | PyPy3 (2.4.0) | py | Runtime Error | 203 | 40560 | 850 | from itertools import accumulate
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
acc = list(accumulate(a))
def maxsum(ls,k):
l = len(ls)
if l==0:
return 0
dp = [0 for i in range(l+1)]
dp[0] = 1
for i in range(1,l+1):
dp[i] = (dp[i-1]|(dp[i-1]<<ls[i-1]))&1<<k
for b in rang... |
s613488585 | p03780 | u905582793 | 1583137686 | Python | PyPy3 (2.4.0) | py | Runtime Error | 169 | 39408 | 842 | from itertools import accumulate
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
acc = list(accumulate(a))
def maxsum(ls,k):
l = len(ls)
if l==0:
return 0
dp = [0 for i in range(l+1)]
dp[0] = 1
for i in range(1,l+1):
dp[i] = dp[i-1]|(dp[i-1]<<ls[i-1])
for b in range(k-1,-... |
s029904744 | p03780 | u905582793 | 1583137174 | Python | PyPy3 (2.4.0) | py | Runtime Error | 185 | 39408 | 709 | from itertools import accumulate
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
acc = list(accumulate(a))
def maxsum(ls,k):
l = len(ls)
if l==0:
return 0
dp = [0 for i in range(l+1)]
dp[0] = 1
for i in range(1,l+1):
dp[i] = dp[i-1]|(dp[i-1]<<ls[i-1])
for b in range(k-1,-... |
s841112728 | p03780 | u905582793 | 1583136929 | Python | PyPy3 (2.4.0) | py | Runtime Error | 175 | 39408 | 706 | from itertools import accumulate
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
acc = list(accumulate(a))
def maxsum(ls,k):
l = len(ls)
if l==0:
return 0
dp = [0 for i in range(l+1)]
dp[0] = 1
for i in range(1,l+1):
dp[i] = dp[i-1]|(dp[i-1]<<ls[i-1])
for b in range(k-1,-... |
s862281627 | p03780 | u905582793 | 1583136383 | Python | PyPy3 (2.4.0) | py | Runtime Error | 171 | 39408 | 682 | from itertools import accumulate
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
acc = list(accumulate(a))
def maxsum(ls,k):
l = len(ls)
dp = [0 for i in range(l+1)]
dp[0] = 1
for i in range(1,l+1):
dp[i] = dp[i-1]|(dp[i-1]<<ls[i-1])
for b in range(k-1,-1,-1):
if dp[-1] & 1... |
s826285184 | p03780 | u905582793 | 1583136229 | Python | PyPy3 (2.4.0) | py | Runtime Error | 173 | 39536 | 723 | from itertools import accumulate
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
acc = list(accumulate(a))
def maxsum(ls,k):
l = len(ls)
dp = [0 for i in range(l+1)]
dp[0] = 1
for i in range(1,l+1):
dp[i] = dp[i-1]|(dp[i-1]<<ls[i-1])
for b in range(k-1,-1,-1):
if dp[-1] & 1... |
s824646830 | p03780 | u190086340 | 1581883791 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2111 | 249608 | 1096 | def args():
N, K = tuple(map(int, input().split()))
Ai = tuple(map(int, input().split()))
return N, K, Ai
def solve(N, K, Ai):
sum_a = sum(Ai)
if sum_a < K:
return N
Ai = sorted(Ai)
x, y = N, K + 10
MEMO = [[None for _ in range(y)] for _ in range(x)]
def recur(ei, i, to... |
s865376390 | p03780 | u190086340 | 1581545551 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2140 | 589192 | 1565 | def args():
N, K = tuple(map(int, input().split()))
Ai = tuple(map(int, input().split()))
return N, K, Ai
def solve(N, K, Ai):
sum_a = sum(Ai)
if sum_a < K:
return N
Ai = sorted(Ai)
def search():
def recur(i, total, target_card, range_head):
if range_head <= ... |
s197993258 | p03780 | u190086340 | 1581544864 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2140 | 588936 | 1570 | def args():
N, K = tuple(map(int, input().split()))
Ai = tuple(map(int, input().split()))
return N, K, Ai
def solve(N, K, Ai):
sum_a = sum(Ai)
if sum_a < K:
return N
Ai = sorted(Ai)
def search():
def recur(i, total, target_card, range_head):
if range_head <= ... |
s915370680 | p03780 | u190086340 | 1581541142 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2140 | 587656 | 1429 | def args():
N, K = tuple(map(int, input().split()))
Ai = tuple(map(int, input().split()))
return N, K, Ai
def solve(N, K, Ai):
sum_a = sum(Ai)
if sum_a < K:
return N
Ai = sorted(Ai)
def search():
def recur(i, total, target_card, range_head):
if range_h... |
s056439559 | p03780 | u190086340 | 1581540897 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2140 | 586248 | 1515 | def args():
N, K = tuple(map(int, input().split()))
Ai = tuple(map(int, input().split()))
return N, K, Ai
def solve(N, K, Ai):
sum_a = sum(Ai)
if sum_a < K:
return N
Ai = sorted(Ai)
def search():
def recur(i, total, target_card, range_head):
if range_h... |
s257956910 | p03780 | u190086340 | 1581540197 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2111 | 248712 | 1594 | def args():
N, K = tuple(map(int, input().split()))
Ai = tuple(map(int, input().split()))
# print("N", N, "K", K)
# print(Ai)
# N, K = 5, 7
# Ai = [5, 2, 8, 11, 15]
return N, K, Ai
def solve(N, K, Ai):
sum_a = sum(Ai)
if sum_a < K:
return N
Ai = sorted(Ai)
d... |
s012232436 | p03780 | u353797797 | 1581108308 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 3572 | 961 | 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(ro... |
s157684673 | p03780 | u353797797 | 1581106977 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 260516 | 908 | 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(ro... |
s029041029 | p03780 | u672220554 | 1579279916 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2072 | 41584 | 985 | import bisect
def main():
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
l=0
r=n
d = {}
if sum(a)<k:
print(n)
else:
while l!=r:
i=(l+r)//2
ta = a[i]
if ta in d.values():
flag = d[ta]
e... |
s778206151 | p03780 | u672220554 | 1579198284 | Python | PyPy3 (2.4.0) | py | Runtime Error | 174 | 39664 | 839 | import bisect
def main():
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
l=0
r=n
if sum(a)<k:
print(n)
else:
while l!=r:
i=(l+r)//2
ta = a[i]
if ta>=k:flag=True
else:
na = a[:i]+a[i+1:]
... |
s003851154 | p03780 | u672220554 | 1579196648 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2107 | 45276 | 500 | import bisect
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
l=0
r=n
while l!=r:
i=(l+r)//2
ta = a[i]
na = a[:i]+a[i+1:]
dp = [False for _ in range(k+1)]
dp[0]=True
for j in range(n-1):
for m in range(k,0,-1):
if m-na[j]>=0:
dp[m]=dp[m]... |
s388616400 | p03780 | u672220554 | 1579191979 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2106 | 46360 | 543 | import bisect
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
fa = a[:bisect.bisect_left(a,k)]
fa.reverse()
nn = len(fa)
for i in range(nn):
flag = 0
ta = fa[i]
na = fa[:i]+fa[i+1:]
dp = [False for _ in range(k+1)]
dp[0]=True
for j in range(nn-1):
for l in range(k,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.