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
s979107813
p03780
u310678820
1576434254
Python
PyPy3 (2.4.0)
py
Runtime Error
1473
426504
1256
class cumsum: def __init__(self, A): self.n = len(A) self.data = [0]*self.n for i in range(self.n): self.data[i] = self.data[i-1]+A[i] def query(self, l, r): if n<=l: return 0 if r<0: return 0 if l<0: x = 0 e...
s527490876
p03780
u819048695
1575837163
Python
PyPy3 (2.4.0)
py
Runtime Error
1552
60892
569
import itertools def fff(x): dp=[0]*k dp[0]=1 for u in itertools.chain(a[:x],a[x+1:]): h=dp[:] for i in range(u,k): h[i]=h[i]|dp[i-u] dp=h cnt=0 for i in range(k-a[x],k): cnt+=dp[i] if cnt==0: return True else: return False n,k=ma...
s301231111
p03780
u819048695
1575836893
Python
PyPy3 (2.4.0)
py
Runtime Error
1301
61916
591
import itertools def fff(x): dp=[0]*k dp[0]=1 for u in itertools.chain(a[:x],a[x+1:]): h=dp[:] for i in range(u,k): h[i]=max(h[i],dp[i-u]) dp=h for i in range(k-a[x],k): if dp[i]==1: return False break else: return True ...
s726494935
p03780
u819048695
1573607314
Python
PyPy3 (2.4.0)
py
Runtime Error
168
38384
496
import itertools import numpy as np n,k=map(int,input().split()) a=list(map(int,input().split())) a.sort() #必要ないならTrueを返す def test(i): b=itertools.chain(a[:i],a[i+1:]) dp=[False]*k dp[0]=True for u in b: dp[u:]=np.logical_or(dp[u:],dp[:-u]) return not any(dp[-a[i]:]) low=0 high=n-1 wh...
s574100359
p03780
u819048695
1573493001
Python
PyPy3 (2.4.0)
py
Runtime Error
2107
58716
718
def f(x): global a dp=[0]*k dp[0]=1 for i in range(n): if i==x: continue else: h=[0]*k b=a[i] for i in range(k): if dp[i]==1: h[i]=1 if i+b<k: h[i+b]=1 ...
s544659942
p03780
u467736898
1572929557
Python
Python (3.4.3)
py
Runtime Error
1857
2089796
639
import numpy as np N, K = map(int, input().split()) A = list(map(int, input().split())) dp1 = np.zeros((N+1, K), dtype=bool) dp1[0][0] = 1 for i, a in enumerate(A, 1): dp1[i, :] = dp1[i-1, :] dp1[i, a:] += dp1[i-1, :-a] dp2 = np.zeros((N+1, K), dtype=bool) dp2[N][0] = 1 for i, a in zip(range(N-1, -1, -1), A[::-...
s176690770
p03780
u803848678
1572905594
Python
PyPy3 (2.4.0)
py
Runtime Error
186
39920
627
import numpy as np def main(): def check(m): DP = np.full(k+1, False) DP[0] = True for i in range(n): if i == m: continue DP[a[i]:] = np.logical_or(DP[a[i]:], DP[:k+1-a[i]]) return any(DP[i] for i in range(k-a[m], k)) n,k = map(int, input...
s332125690
p03780
u803848678
1572903364
Python
Python (3.4.3)
py
Runtime Error
841
598876
897
import numpy as np n,k = map(int, input().split()) a = list(map(int, input().split())) a = [i for i in a if i <k] n = len(a) DP1 = [[False]*(k+1) for i in range(n+1)] DP1 = np.full((n+1, k+1), False) DP1[0][0] = True DP2 = [[False]*(k+1) for i in range(n+1)] DP2 = np.full((n+1, k+1), False) DP2[0][0] = True for i i...
s984961077
p03780
u042802884
1572595652
Python
PyPy3 (2.4.0)
py
Runtime Error
2132
465032
826
N,K=map(int,input().split()) a=[None] a.extend(list(map(int,input().split()))) # K以上の整数が書かれたカードは,不必要ではない。 # print(a) #DB # dp[i][j]=i枚目のカードを使用して合計がjになったことがあるか(1<=i<=N,0<=j<=2K-2) dp=[[False for j in range(2*K-1)] for i in range(N+1)];dp[0]=None for i2 in range(1,N+1): t=a[i2] dp[i2][t]=True for i1 in range...
s598170805
p03780
u892251744
1570240000
Python
Python (3.4.3)
py
Runtime Error
2129
414580
753
N, K = map(int, input().split()) a = list(map(int, input().split())) a.sort() dp = [[10 ** 11 for _ in range(2*K-1)] for _ in range(N+1)] for i in range(N+1): dp[i][0] = 10 ** 10 for i in range(N): for j in range(K): if dp[i][j] < 10 ** 10 + 1: dp[i+1][j] = min(dp[i+1][j], dp[i][j]) ...
s354134707
p03780
u892251744
1570236533
Python
PyPy3 (2.4.0)
py
Runtime Error
2144
632968
1173
def main(): N, K = map(int, input().split()) a = list(map(int, input().split())) a.sort() num = [0] * K c = 0 ok = float('inf') for i, ai in enumerate(a): if ai >= K: a = a[:i] else: num[ai] += 1 c += ai if c >= K: ok = ...
s285963194
p03780
u310678820
1570060386
Python
PyPy3 (2.4.0)
py
Runtime Error
2160
817544
1307
N, K = map(int, input().split()) a = sorted(list(map(int, input().split()))) for i in range(N): if a[i]<=K: n = i else: break if n == 0: print(0) exit() N = n+1 a = a[:N] dp1 = [[0]*(K+1) for _ in range(N+1)] dp2 = [[0]*(K+1) for _ in range(N+1)] dp1[0][0] = 1 dp2[-1][0] = 1#i~Nまで使う for ...
s794211261
p03780
u588341295
1569390595
Python
PyPy3 (2.4.0)
py
Runtime Error
2194
1458428
1599
# -*- coding: utf-8 -*- import sys from collections import defaultdict from bisect import bisect_left def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): retur...
s444203798
p03780
u423585790
1567101238
Python
PyPy3 (2.4.0)
py
Runtime Error
2129
410760
2255
#!/usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random import itertools sys.setrecursionlimit(10**5) stdin = sys.stdin bisect_left = bisect.bisect_left bisect_right = bisect.bisect_right def LI(): re...
s623327021
p03780
u423585790
1567100866
Python
PyPy3 (2.4.0)
py
Runtime Error
2124
334088
2224
#!/usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random import itertools sys.setrecursionlimit(10**5) stdin = sys.stdin bisect_left = bisect.bisect_left bisect_right = bisect.bisect_right def LI(): re...
s696337125
p03780
u423585790
1567100825
Python
PyPy3 (2.4.0)
py
Runtime Error
2126
346888
2279
#!/usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random import itertools sys.setrecursionlimit(10**5) stdin = sys.stdin bisect_left = bisect.bisect_left bisect_right = bisect.bisect_right def LI(): re...
s860668982
p03780
u423585790
1567100628
Python
PyPy3 (2.4.0)
py
Runtime Error
2125
349832
2278
#!/usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random import itertools sys.setrecursionlimit(10**5) stdin = sys.stdin bisect_left = bisect.bisect_left bisect_right = bisect.bisect_right def LI(): re...
s867125714
p03780
u423585790
1567100477
Python
PyPy3 (2.4.0)
py
Runtime Error
2122
301320
2249
#!/usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random import itertools sys.setrecursionlimit(10**5) stdin = sys.stdin bisect_left = bisect.bisect_left bisect_right = bisect.bisect_right def LI(): re...
s492855097
p03780
u423585790
1567100394
Python
PyPy3 (2.4.0)
py
Runtime Error
2124
301576
2288
#!/usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random import itertools sys.setrecursionlimit(10**5) stdin = sys.stdin bisect_left = bisect.bisect_left bisect_right = bisect.bisect_right def LI(): re...
s693916019
p03780
u423585790
1567100330
Python
PyPy3 (2.4.0)
py
Runtime Error
2122
301320
2232
#!/usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random import itertools sys.setrecursionlimit(10**5) stdin = sys.stdin bisect_left = bisect.bisect_left bisect_right = bisect.bisect_right def LI(): re...
s904990853
p03780
u947883560
1566065401
Python
Python (3.4.3)
py
Runtime Error
2116
199540
1053
#!/usr/bin/env python3 import sys INF = float("inf") def solve(N: int, K: int, a: "List[int]"): a.sort() count = 0 ng = -1 ok = N while abs(ok - ng) > 1: j = (ok + ng) // 2 A = a[:j]+a[j+1:] # print(A) DP = [[False]*K for _ in range(N-1)] if A[0] < K: ...
s277825414
p03780
u947883560
1566065289
Python
Python (3.4.3)
py
Runtime Error
2116
200948
1076
#!/usr/bin/env python3 import sys from itertools import accumulate INF = float("inf") def solve(N: int, K: int, a: "List[int]"): a.sort() # print(a) count = 0 ng = -1 ok = N while abs(ok - ng) > 1: j = (ok + ng) // 2 A = a[:j]+a[j+1:] # print(A) DP = [[False]*K ...
s532241748
p03780
u947883560
1566064424
Python
Python (3.4.3)
py
Runtime Error
2116
201204
1175
#!/usr/bin/env python3 import sys from itertools import accumulate INF = float("inf") def solve(N: int, K: int, a: "List[int]"): a.sort() count = 0 ng = -1 ok = N while abs(ok - ng) > 1: j = (ok + ng) // 2 A = a[:j]+a[j+1:] # print(A) DP = [[False]*K for _ in range(...
s387012452
p03780
u947883560
1566064408
Python
Python (3.4.3)
py
Runtime Error
2116
201588
1163
#!/usr/bin/env python3 import sys from itertools import accumulate INF = float("inf") def solve(N: int, K: int, a: "List[int]"): count = 0 ng = -1 ok = N while abs(ok - ng) > 1: j = (ok + ng) // 2 A = a[:j]+a[j+1:] # print(A) DP = [[False]*K for _ in range(N-1)] ...
s583000110
p03780
u947883560
1566064224
Python
Python (3.4.3)
py
Runtime Error
2116
199412
1084
#!/usr/bin/env python3 import sys from itertools import accumulate INF = float("inf") def solve(N: int, K: int, a: "List[int]"): count = 0 for j in range(N): A = a[:j]+a[j+1:] # print(A) DP = [[False]*K for _ in range(N-1)] for i in range(N-1): if A[i] < K: ...
s072485993
p03780
u794250528
1565900606
Python
PyPy3 (2.4.0)
py
Runtime Error
2182
1030536
512
n, k = map(int, input().split()) a = list(map(int, input().split())) a.sort() def ok(x): dp = [[0] * k for _ in range(n + 1)] dp[0][0] = 1 for i in range(n): for j in range(k): dp[i + 1][j] += dp[i][j] if i != x and j + a[i] < k: dp[i + 1][j + a[i]] += dp[i][...
s280492144
p03780
u634461820
1563312145
Python
Python (3.4.3)
py
Runtime Error
2127
236460
957
#import numpy as np MAX_INT = int(10e10) N,K = list(map(int,input().split())) cards = list(map(int,input().split())) cards.sort() cards += [MAX_INT] #print(cards) memo = [None]*5010 dp = [[0]*K for i in range(N+2)] left = -1 right = N while right - left > 1: middle = (left+right)//2 if memo[cards[middle]] == True ...
s043803023
p03780
u511965386
1563154016
Python
PyPy3 (2.4.0)
py
Runtime Error
2111
121436
436
N, K = map(int, input().split()) a = [int(i) for i in input().split()] a.sort() ret = [0] * N def rec(i, s, m) : if s >= K : if s - m < K : return True return False if i == N : return False c1 = rec(i + 1, s + a[i], min(m, a[i])) c2 = rec(i + 1, s, m) ...
s657315607
p03780
u511965386
1563153864
Python
PyPy3 (2.4.0)
py
Runtime Error
2111
143236
455
N, K = map(int, input().split()) a = [int(i) for i in input().split()] a.sort() ret = [0] * N def rec(i, s, m) : print(i, s, m) if s >= K : if s - m < K : return True return False if i == N : return False c1 = rec(i + 1, s + a[i], min(m, a[i])) c2 = re...
s478371709
p03780
u456353530
1562784777
Python
PyPy3 (2.4.0)
py
Runtime Error
2170
1117832
982
N, K = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() ans = 0 for i in range(N): if a[-1 -i] < K: break ans += 1 n = N - ans D = [] re = a[0] cnt = 0 for i in range(n): if re == a[i]: cnt += 1 else: D.append([re, cnt]) cnt = 1 re = a[i] else: D.append([re, cnt]) L...
s268264780
p03780
u167751176
1561164003
Python
Python (3.4.3)
py
Runtime Error
2117
215668
774
def main(): N, K = map(int,input().split()) A = list(map(int,input().split())) A.sort() l, r = 0, N-1 while l < r: m = (l+r)>>1 p = True if m == 0 and solve(N, K, A[1:], A[0]): l = m+1 continue if solve(N, K, A[:m]+A[m+1:], A[m]): l = m+1 else: r = m if l == N-1 and solve(N, K, A[:N-1], A[N-...
s852999696
p03780
u167751176
1561163819
Python
Python (3.4.3)
py
Runtime Error
2118
215668
709
def main(): N, K = map(int,input().split()) A = list(map(int,input().split())) A.sort() l, r = 0, N-1 while l < r: m = (l+r)>>1 p = True if solve(N, K, A[:m]+A[m+1:], A[m]): l = m+1 else: r = m if l == N-1 and solve(N, K, A[:N-1], A[N-1]): l = N print(l) def solve(n, k, a, ai): dp = [[False fo...
s770571126
p03780
u059210959
1558308944
Python
Python (3.4.3)
py
Runtime Error
2117
218060
1088
# encoding:utf-8 import copy import random import bisect #bisect_left これで二部探索の大小検索が行える import fractions #最小公倍数などはこっち import math mod = 10**9+7 N,K = map(int,input().split()) a = [int(i) for i in input().split()] cnt = 0 # if sum(a) < K: # cnt = len(a) # print(cnt) # exit() # a.sort() def solve(rest_min...
s610713062
p03780
u059210959
1558307640
Python
Python (3.4.3)
py
Runtime Error
2104
6796
1079
# encoding:utf-8 import copy import random import bisect #bisect_left これで二部探索の大小検索が行える import fractions #最小公倍数などはこっち import math mod = 10**9+7 N,K = map(int,input().split()) a = [int(i) for i in input().split()] cnt = 0 # if sum(a) < K: # cnt = len(a) # print(cnt) # exit() a.sort() #あるインデックスのものをのぞいて,その...
s857349453
p03780
u059210959
1558307561
Python
Python (3.4.3)
py
Runtime Error
2104
6736
1035
# encoding:utf-8 import copy import random import bisect #bisect_left これで二部探索の大小検索が行える import fractions #最小公倍数などはこっち import math mod = 10**9+7 N,K = map(int,input().split()) a = [int(i) for i in input().split()] cnt = 0 # if sum(a) < K: # cnt = len(a) # print(cnt) # exit() a.sort() #あるインデックスのものをのぞいて,その...
s309809802
p03780
u075012704
1556846462
Python
Python (3.4.3)
py
Runtime Error
18
3188
1774
def main(): def accumulate(X): ret = [X[0]] for x in X[1:]: ret.append(ret[-1] + x) return ret N, K = map(int, raw_input().split()) A = list(map(int, raw_input().split())) # K以上の数はすべて必要なのでA未満の数だけを考える A = sorted([a for a in A if a < K], reverse=True) N =...
s558309204
p03780
u052499405
1555637159
Python
Python (3.4.3)
py
Runtime Error
2116
201324
654
n, k = [int(item) for item in input().split()] a = sorted([int(item) for item in input().split()], reverse=True) max_k = min(sum(a), 5000) def check_needed(index): memo = [[0] * (max_k + 1) for _ in range(n+1)] memo[0][0] = 1 for i in range(n): for j in range(max_k + 1): if memo[i][j] =...
s872211730
p03780
u319818856
1554499127
Python
Python (3.4.3)
py
Runtime Error
2116
201076
585
def no_need(N: int, K: int, A: list) -> int: count = 0 for i in range(N): dp = [[False] * (K + 1) for _ in range(N)] dp[0][0] = True for n, a in enumerate(A[:i] + A[i+1:]): for k in range(K + 1): dp[n+1][k] = dp[n][k] if a <= k: ...
s965559575
p03780
u319818856
1554495864
Python
Python (3.4.3)
py
Runtime Error
2104
3572
620
def no_need(N: int, K: int, A: list) -> int: count = 0 for i in range(N): # s[i] を要素の和が i 以上の部分集合の個数とする。 s = [0] * (K + 1) s[0] = 1 for a in A[:i] + A[i+1:]: for k in range(K, -1, -1): s[min(K, a + k)] += s[k] s[0] = 0 for k in range(...
s494317973
p03780
u695811449
1554195827
Python
PyPy3 (2.4.0)
py
Runtime Error
518
53596
867
import sys import copy input = sys.stdin.readline N,K=map(int,input().split()) A=list(map(int,input().split())) A.sort() SUM=0 for a in A: SUM+=a if SUM>=K: MAX_NO_NEED=a break else: print(N) sys.exit() A=[a for a in A if a<K] L=len(A) MIN=-1 MAX=A.index(MAX_NO_NEED)-1 whi...
s896694834
p03780
u562016607
1545086111
Python
PyPy3 (2.4.0)
py
Runtime Error
2124
317448
1032
N,K=map(int,input().split()) a=[int(i) for i in input().split()] if N==1: if K-a[0]<=0: print(1) else: print(0) def dp(i): res=[[0 for k in range(K)] for j in range(N-1)] L=[] for j in range(N): if i!=j: L.append(j) for j in range(N-1): for k in range(...
s099225767
p03780
u562016607
1544041426
Python
PyPy3 (2.4.0)
py
Runtime Error
2118
317064
1120
N,K=map(int,input().split()) a=[int(i) for i in input().split()] if N==1: if K-a[0]<=0: print(1) else: print(0) def dp(i): res=[[0 for k in range(K)] for j in range(N-1)] L=[] for j in range(N): if i!=j: L.append(j) for j in range(N-1): for k in range(...
s280974298
p03780
u562016607
1544041417
Python
Python (3.4.3)
py
Runtime Error
2117
214388
1120
N,K=map(int,input().split()) a=[int(i) for i in input().split()] if N==1: if K-a[0]<=0: print(1) else: print(0) def dp(i): res=[[0 for k in range(K)] for j in range(N-1)] L=[] for j in range(N): if i!=j: L.append(j) for j in range(N-1): for k in range(...
s057620758
p03780
u920299620
1543239399
Python
Python (3.4.3)
py
Runtime Error
18
2940
1458
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for(int i = 0;i < n;i++) #define REPR(i, n) for(int i = n;i >= 0;i--) #define FOR(i, m, n) for(int i = m;i < n;i++) #define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++) typedef long long llong; char moji[26]={'a','b','c','d','e','f','g','h'...
s983988441
p03780
u170201762
1540874638
Python
Python (3.4.3)
py
Runtime Error
17
3064
512
N,K = map(int,input().split()) a = list(map(int,input().split())) a.sort() if a[0] >= K: print(0) exit() a = [a[i] for i in range(N) if a[i]<K] a.reverse() N = len(a) ans = N dp = [False]*K dp[0] = True Smax = 0 for i in range(N): a_ = a[i] if Smax + a_ >= K: ans = N-i-1 updated = False ...
s390657044
p03780
u170201762
1540858670
Python
Python (3.4.3)
py
Runtime Error
19
3572
268
N,K = map(int,input().split()) a = list(map(int,input().split())) a.sort() for i in range(N): i = N-i-1 for j in range(K): if j < a[i]: dp[i][j] = dp[i+1][j] else: dp[i][j] = max(dp[i+1][j],dp[i+1][j-a[i]]+a[i]) print(0)
s170050503
p03780
u170201762
1540857395
Python
Python (3.4.3)
py
Runtime Error
159
12620
399
N,K = map(int,input().split()) a = list(map(int,input().split())) a.sort() import numpy as np b = np.cumsum(np.array(a)) if b[-1] < K: print(N) exit() elif b[0] >= K: print(0) exit() import bisect i = bisect.bisect(b,K) w = K-a[i] b = b[:i] while b[-1] >= w: i = bisect.bisect(b,w) w -= a[i] ...
s972804523
p03780
u170201762
1540854631
Python
Python (3.4.3)
py
Runtime Error
20
3572
277
N,K = map(int,input().split()) a = list(map(int,input().split())) a.sort() w = 0 for i in range(N): w += a[i] if w >= K: break if w < K: print(N) else: a = a[:i+1] for j in range(i): w -= a[j] if w < K: break print(j)
s972202666
p03780
u201234972
1538797774
Python
Python (3.4.3)
py
Runtime Error
19
3572
212
N, K = map( int, input().split()) A = list( map( int, input().split())) RA = A.sort( reverse = True) s = 0 ans = 0 for a in RA: if s+a < K: s += A ans += 1 else: ans = 0 print(ans)
s232147521
p03780
u608088992
1538666948
Python
Python (3.4.3)
py
Runtime Error
2107
125472
764
import copy N, K = map(int, input().split()) A = [int(_) for _ in input().split()] A.sort() Inf = 5001 def DP(i, K, L, memo = {}): if i == 0: return (True if K == 0 else False) try: return memo[(i, K)] except KeyError: if DP(i-1, K-L[i-1], L, memo) or DP(i-1, K, L, memo): ...
s478637289
p03780
u608088992
1538665207
Python
Python (3.4.3)
py
Runtime Error
2107
126996
719
import copy N, K = map(int, input().split()) A = [int(_) for _ in input().split()] A.sort() Inf = 5001 def DP(i, K, L, memo = {}): if i == 0 and K == 0: return True elif i == 0: return False try: return memo[(i, K)] except KeyError: if DP(i-1, K-L[i-1], L, memo) or DP(i-...
s160965494
p03780
u631277801
1536317951
Python
PyPy3 (2.4.0)
py
Runtime Error
177
38640
1022
# 入力 file = open("g080D.txt", "r") stdin = file import sys stdin = sys.stdin def li(): return [int(x) for x in stdin.readline().split()] def li_(): return [int(x)-1 for x in stdin.readline().split()] def lf(): return [float(x) for x in stdin.readline().split()] def ls(): return stdin.readline().split() def ns(): retu...
s885956098
p03780
u334712262
1535507677
Python
PyPy3 (2.4.0)
py
Runtime Error
2107
71020
3305
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from pprint import pprint from collections import Counter, defaultdict, deque import queue from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combina...
s112941507
p03780
u329709276
1529138218
Python
Python (3.4.3)
py
Runtime Error
20
3572
203
N,K = map(int,input().split()) a = sorted(map(int,input().split())) count = N s = 0 for i in range(N-1,-1,-1): if s + N[i] < K: s += N[i] else: count = min(i,count) print(count)
s090247063
p03780
u329709276
1529137015
Python
PyPy3 (2.4.0)
py
Runtime Error
2130
425736
1170
N,K = map(int,input().split()) a = list(map(int,input().split())) dp1 = [[False]*K for _ in range(N)] dp2 = [[False]*K for _ in range(N)] # dp[x][y] x枚目まで使った時にyに出来るか # K-ai <= ai < K となる部分集合を探す dp1[0][a[0]] = True dp1[0][0] = True for i in range(1,N): for j in range(K): dp1[i][j] = dp1[i-1][j] or (j-a[i] ...
s067688091
p03780
u329709276
1529109928
Python
Python (3.4.3)
py
Runtime Error
20
3572
360
N,K = map(int,input().split()) a = list(map(int,input().split())) a_sum = sum(a) if a_sum < K: print(N) exit() if a_sum == K: print(0) exit() count = 0 L = [i for i in a if i < K] L_sum = sum(L) if L_sum < K: print(len(K)) exit() if L_sum == K: print(0) exit() for i in L: if L_sum - ...
s807408039
p03780
u329709276
1529109624
Python
Python (3.4.3)
py
Runtime Error
20
3572
360
N,K = map(int,input().split()) a = list(map(int,input().split())) a_sum = sum(a) if a_sum < K: print(N) exit() if a_sum == K: print(0) exit() count = 0 L = [i for i in a if i < K] L_sum = sum(L) if L_sum < K: print(len(N)) exit() if a_sum == K: print(0) exit() for i in L: if L_sum - ...
s691120126
p03780
u391475811
1523307213
Python
Python (3.4.3)
py
Runtime Error
2114
1097360
407
import bisect N,K=map(int,input().split()) A=[int(x) for x in input().split()] A.sort() def solve(a,K): if A[a]>=K: return False bits=1 for i in range(len(A)): if i!=a: bits|= bits<<A[i] cnt = (1<<A[a])-1 bits >>= (K-A[a]) if bits&cnt: return False else: return True for i in range...
s664673152
p03780
u425351967
1507654774
Python
Python (3.4.3)
py
Runtime Error
2117
199284
480
N, K = [int(n) for n in input().split()] A = [int(n) for n in input().split()] A.sort() res = [] for n_ex in range(N): dp = [[False] * K for n in range(N+1)] dp[0][0] = True for n in range(N): for k in range(0, K): dp[n+1][k] = dp[n][k] if n != n_ex: for k in range(0, K - A[n]): if ...
s696254298
p03780
u425351967
1507652970
Python
PyPy3 (2.4.0)
py
Runtime Error
2135
439816
480
N, K = [int(n) for n in input().split()] A = [int(n) for n in input().split()] A.sort() res = [] for n_ex in range(N): dp = [[False] * K for n in range(N+1)] dp[0][0] = True for n in range(N): for k in range(0, K): dp[n+1][k] = dp[n][k] if n != n_ex: for k in range(0, K - A[n]): if ...
s929659765
p03780
u425351967
1507652963
Python
Python (3.4.3)
py
Runtime Error
2116
201076
480
N, K = [int(n) for n in input().split()] A = [int(n) for n in input().split()] A.sort() res = [] for n_ex in range(N): dp = [[False] * K for n in range(N+1)] dp[0][0] = True for n in range(N): for k in range(0, K): dp[n+1][k] = dp[n][k] if n != n_ex: for k in range(0, K - A[n]): if ...
s724833913
p03780
u425351967
1507647504
Python
Python (3.4.3)
py
Runtime Error
2116
201076
522
N, K = [int(n) for n in input().split()] A = [int(n) for n in input().split()] A.sort() res = [] for n_ex in range(N): A_tmp = A.copy() A_tmp.pop(n_ex) dp = [[False] * K for n in range(N)] dp[0][0] = True for cnt in range(1, N): for k in range(0, K): dp[cnt][k] = dp[cnt-1][k] for k in range(0...
s419006732
p03780
u619384481
1504841009
Python
Python (2.7.6)
py
Runtime Error
1145
3032
849
ini=map(int,raw_input().split()) a=map(int,raw_input().split()) b=[] for i in a: b.append(i) b.sort() c=[] while True: sum=0 add=0 for i in b: sum+=i if sum<ini[1] and len(c)>=1: b.append(c[-1]) c.pop(-1) c.reverse() while True: sum=0 f...
s017907565
p03780
u063962277
1497157758
Python
Python (3.4.3)
py
Runtime Error
2120
263688
473
N, K = map(int, input().split()) a = [int(i) for i in input().split()] ok = [] for i in range(N): b = a.copy() del b[i] dp = [[0 for y in range(K)] for x in range(N-1)] for x in range(N-1): if b[x] < K: dp[x][b[x]] = 1 for y in range(K): dp[x][y] += dp[x-1][y] ...
s866803227
p03780
u683479402
1494365275
Python
Python (3.4.3)
py
Runtime Error
2121
275060
661
#ABC56 D #1245870 N,K = map(int, input().split()) A = sorted(list(map(int, input().split()))) l = 0 r = N while(r > l): s = int((l+r)/2) if A[s] > K: r = s continue si = False dp = [[False for i in range(K+2)] for j in range(K+2)] dp[0][0] = True for i in range(1,N): fo...
s170010213
p03780
u683479402
1494332060
Python
Python (3.4.3)
py
Runtime Error
2117
213876
671
#ABC56 D input nk = list(map(int, input().split())) N = nk[0] K = nk[1] A = sorted(list(map(int, input().split()))) count = 0 for a in A: new_a = A[:] new_a.remove(a) dp = [[-1 for i in range(N)] for j in range(K+1)] for i in range(N): dp[0][i] = True for i in range(1,K+1): dp[i][0...
s421000923
p03780
u580316060
1491318763
Python
Python (3.4.3)
py
Runtime Error
2104
39328
1043
def whatIsMinNumber(X_copy,K): pickupNum = X_copy[len(X_copy)//2] X_rest = X[:] X_rest.remove(pickupNum) if can_do_number(X_rest,0,K-pickupNum,K-1): if len(X_copy) > 2: return whatIsMinNumber(X_copy[len(X_copy)//2+1:len(X_copy)],K) else: return pickupNum else:...
s945310354
p03780
u580316060
1491317398
Python
Python (3.4.3)
py
Runtime Error
2104
39328
987
def whatIsMinNumber(X_copy,K): pickupNum = X_copy[len(X_copy)//2] X_rest = X[:] X_rest.remove(pickupNum) if can_do_number(X_rest,0,K-pickupNum,K-1): if len(X_copy) > 2: return whatIsMinNumber(X_copy[len(X_copy)//2+1:len(X_copy)],K) else: return pickupNum else:...
s657698371
p03780
u580316060
1491313234
Python
Python (3.4.3)
py
Runtime Error
2104
39344
1096
def whatIsMinNumber(X_copy,K): pickupNum = X_copy[len(X_copy)//2] X_rest = X[:] X_rest.remove(pickupNum) if can_do_number(X_rest,pickupNum,K,K+pickupNum-1): if len(X_copy) > 2: return whatIsMinNumber(X_copy[len(X_copy)//2+1:len(X_copy)],K) else: return pickupNum ...
s782855056
p03780
u209647862
1490921086
Python
Python (3.4.3)
py
Runtime Error
2104
3700
764
#!/usr/bin/env python # -*- coding: utf-8 -*- import array n, k = map(int, input().split()) cards = list(map(int, input().split())) needs = 0 for i, val in enumerate(cards): if val >= k: needs += 1 continue c_without_i = cards[:i] + cards[i + 1:] dp = array.array('b', [0] * k) dp2 ...
s892532253
p03780
u040380068
1490509255
Python
Python (2.7.6)
py
Runtime Error
13
2948
499
def calc(lst, k): sum = 0 i = 0 while sum < k and i < len(inptsort): sum += lst[i] i += 1 if sum < k: return i else: df = sum - k sum2 = 0 j = 0 while sum2 < df and j < i: sum2 += lst[j] j += 1 if lst[j-1] != lst[j]: return j else: j -= 1 while j >= 1: if lst[j-1] != ...
s296013610
p03780
u982653403
1490305279
Python
Python (3.4.3)
py
Runtime Error
2104
4140
560
n, k = map(int, input().split()) a = sorted(filter(lambda x: x < k, map(int, input().split()))) def check(start, end, l): s = set() s.add(0) for i in l: for x in s.copy(): if start <= i + x and i + x < end: return True if i + x < start: s.add...
s382689856
p03780
u982653403
1490305051
Python
Python (3.4.3)
py
Runtime Error
2104
4140
577
#### TLE #### n, k = map(int, input().split()) a = sorted((filter(lambda x: x < k, map(int, input().split())))) def check(start, end, l): s = set() s.add(0) for i in l: for x in s.copy(): if start <= i + x and i + x < end: return True if i + x < start: ...
s980173126
p03780
u908424816
1490130071
Python
Python (2.7.6)
py
Runtime Error
281
2948
416
def main(): N, K = map(int, raw_input().split()) cards = map(int, raw_input().split()) c = [] while sum(c) <= K: c.append(cards.pop(cards.index(min(cards)))) if len(cards) == 0 and sum(c) < K: print len(c) return 0 count = 0 while sum(c) >= K: c.p...
s085971508
p03780
u795179699
1489978994
Python
Python (3.4.3)
py
Runtime Error
2130
411380
1364
#!/usr/local/bin/python3 import bisect (n, k) = tuple(map(int, input().split(' '))) a = list(map(int, input().split(' '))) a = sorted(a) l = bisect.bisect_left(a, k) a = a[0:l] minsum = k - a[-1] stf = [[False for j in range(k)] for i in range(l)] stb = [[False for j in range(k)] for i in range(l)] stf[0][a[0]] = ...
s042729492
p03780
u795179699
1489952949
Python
Python (3.4.3)
py
Runtime Error
2105
17216
2076
#!/usr/local/bin/python3 import bisect (n, k) = tuple(map(int, input().split(' '))) a = list(map(int, input().split(' '))) a = sorted(a) i = bisect.bisect_left(a, k) a = a[0:i] ct = {} ad = [] prevnum = 0 cc = 1 for i in a: if prevnum != i: ct[prevnum] = cc ad.append(i) prevnum = i ...
s083171665
p03780
u795179699
1489952581
Python
Python (3.4.3)
py
Runtime Error
2105
17856
2031
#!/usr/local/bin/python3 import bisect (n, k) = tuple(map(int, input().split(' '))) a = list(map(int, input().split(' '))) a = sorted(a) i = bisect.bisect_left(a, k) a = a[0:i] ct = {} ad = [] prevnum = 0 cc = 1 for i in a: if prevnum != i: ct[prevnum] = cc ad.append(i) prevnum = i ...
s019737048
p03780
u608297208
1489940523
Python
PyPy3 (2.4.0)
py
Runtime Error
173
38384
740
import itertools N,K = map(int,input().split()) A = list(map(int,input().split())) A.sort() need = [] iranaiko = [] for a in A: if a >= K: need.append(a) elif a in need: need.append(a) elif a in iranaiko: pass else: z = 0 B = A[:] B.re...
s323041396
p03780
u314057689
1489891160
Python
Python (3.4.3)
py
Runtime Error
20
3572
688
def main(): global K,N,A,AM N, K = map(int, input().split()) A = list(map(int, input().split())) A.sort() flag = (max(A) >= K) # よい部分集合がないということはない AM = sum(A) if not flag and AM < K: # よい集合が存在しない print(len(A)) return print(binary_search_for_integer(len(A)-1, -1)-1) ...
s004933751
p03780
u204637741
1489890933
Python
Python (3.4.3)
py
Runtime Error
223
3572
260
a, b=map(int,input().split()) s=list(map(int,input().split())) k=1 if(sum(s)<b): print(a) k=2 s.sort() ss=list(filter(lambda x: x < b, s)) i=int(0) while(k==1): del ss[0] if(sum(ss)==b): i=i+1 print(i) k=2 elif(sum(ss)<=b): print(i) k=2 i=i+1
s317574875
p03780
u787988531
1489890853
Python
Python (2.7.6)
py
Runtime Error
11
3076
121
K = int(raw_input().split(" ")[1]) d = map(int, raw_input()) s = sum(d) c = 0 for i in d: if s - i > K: c += 1 print c
s171427437
p03780
u204637741
1489890832
Python
Python (3.4.3)
py
Runtime Error
235
3572
259
a, b=map(int,input().split()) s=list(map(int,input().split())) s.sort() if(sum(s)<b): print(a) k=2 ss=list(filter(lambda x: x < b, s)) i=int(0) k=1 while(k==1): del ss[0] if(sum(ss)==b): i=i+1 print(i) k=2 elif(sum(ss)<=b): print(i) k=2 i=i+1
s712403321
p03780
u204637741
1489890811
Python
Python (3.4.3)
py
Runtime Error
20
3572
260
a, b=map(int,input().split()) s=list(map(int,input().split())) s.sort() if(sum(ss)<b): print(a) k=2 ss=list(filter(lambda x: x < b, s)) i=int(0) k=1 while(k==1): del ss[0] if(sum(ss)==b): i=i+1 print(i) k=2 elif(sum(ss)<=b): print(i) k=2 i=i+1
s230862285
p03780
u723654028
1489890491
Python
Python (3.4.3)
py
Runtime Error
2104
4520
441
def calcsum(a, K, i, d=0, s=0): if K - a[i] <= s < K: return True elif i == d: return calcsum(a, K, i, d+1, s) elif d == len(a): return False else: return calcsum(a, K, i, d+1, s) | calcsum(a, K, i, d+1, s+a[d]) N, K = map(int, input().split()) a = list(map(int, inp...
s360601217
p03780
u743272507
1489889527
Python
Python (3.4.3)
py
Runtime Error
3521
19956
690
n,k = map(int,input().split()) a = list(map(int, input().split())) sm = sum(a) if k>sm: print(n) else: table = [[0] for i in range(2*k)] table[0] = [-1] for elm in a: idxlist = [] for i in range(2*k): if table[i] != [0]: if i+elm<2*k: idxlist.a...
s540749317
p03781
u344122377
1591321254
Python
Python (3.4.3)
py
Runtime Error
76
4236
202
import math n = int(input()); dp = [] def dfs(x, i) : dp[i] = dp[i-1] + i if dp[i] >= n : return i return dfs(dp[i], i+1) sz = int(math.sqrt(n)) + 10 dp = [0] * sz ans = dfs(0, 1) print(ans)
s802034625
p03781
u813174766
1582770869
Python
Python (3.4.3)
py
Runtime Error
17
2940
69
n=int(input()) i=int(sqrt(n))//2 while(i*(i+1)//2<n): i+=1 print(i)
s014285065
p03781
u273010357
1582173911
Python
Python (3.4.3)
py
Runtime Error
158
12496
282
import itertools import numpy as np X = int(input()) L = list(range(X)) L = list(itertools.accumulate(L)) def getNearestValue(list, num): idx = np.abs(np.asarray(list) - num).argmin() return list[idx] tmp = getNearestValue(L, X) tmp1 = abs(X-tmp) print(L.index(tmp)+tmp1)
s850896058
p03781
u941407962
1581049324
Python
PyPy3 (2.4.0)
py
Runtime Error
167
38384
728
N, K = map(int, input().split()) A = list(map(int, input().split())) A = [a for a in A if a <K] N = len(A) dp2 = [1] + [0]*K dpm = [[0]*(K+1) for _ in range(N+1)] dpm[0][0] = 1 for i, a in enumerate(A): for j in range(K, -1, -1): dpm[i+1][j] = dpm[i][max(0, j-a)] + dpm[i][j] #print(dpm) r = 0 for i, a in e...
s825745364
p03781
u691896522
1575573271
Python
Python (3.4.3)
py
Runtime Error
19
3060
212
import itertools import bisect x = int(input()) acc = list(itertools.accumulate(list(range(1, x+1)))) index = bisect.bisect_left(acc, x) #print(acc) if acc[index] == x: print(index+1) else: print(index+1)
s672999882
p03781
u152452056
1575329279
Python
Python (3.4.3)
py
Runtime Error
17
2940
1198
#include <bits/stdc++.h> using namespace std; // 287644PV #define FIXED_FLOAT(x) std::fixed <<std::setprecision(6)<<(x) const long long mod = 1000000007; void addSelf(long long&x, long long y) { x+= y; if(x >= mod) x-=mod; } void subSelf(long long&x, long long y) { x -= y; if(x < 0) x +...
s549661249
p03781
u109617108
1574815783
Python
PyPy3 (2.4.0)
py
Runtime Error
162
38256
69
X=int(input()) i=1 sum1=1 while sum<X: i+=1 sum1=sum1+i print(i)
s187884056
p03781
u109617108
1574815051
Python
PyPy3 (2.4.0)
py
Runtime Error
166
38256
120
X=int(input()) import numpy as np dp=np.array([0]*X) i=0 while X not in dp: i+=1 dp+=np(dp+np.array(X*[i])) print(i)
s934774456
p03781
u292746386
1574812512
Python
Python (2.7.6)
py
Runtime Error
256
16520
646
import numpy as np N, K = map(int, raw_input().split()) A = np.array(map(int, raw_input().split())) A = np.sort(A) Sum = A.sum() if Sum < K: print N else: # Find the Smallest Necessary Number # SmallNec = N-1 A_cumsum = np.concatenate(([0], np.cumsum(A))) # SubSet A[0:I] I = np.where(A_cumsum<K...
s497572686
p03781
u292746386
1574808405
Python
Python (2.7.6)
py
Runtime Error
221
16264
428
import sys import numpy as np N, K = map(int, raw_input().split()) A = np.array(map(int, raw_input().split())) A = np.sort(A) Sum = A.sum() if Sum < K: print N sys.exit() A_cumsum = np.concatenate(([0], np.cumsum(A))) I = np.where(A_cumsum<K)[0][-1] + 1 Sum_ = A_cumsum[I] while Sum_ > K: for J in xrang...
s087612011
p03781
u543954314
1571323074
Python
Python (3.4.3)
py
Runtime Error
17
3064
603
def main(): n,k = map(int,input().split()) a = list(filter(lambda x:x<k,list(map(int,input().split())))) n = len(a) a.sort(reverse=True) ng = -1 ok = n while ok-ng > 1: mid = (ok+ng)//2 dp = [False]*(k+1) dp[0] = True f = 0 for j in range(n): if j == mid: continue w...
s600510772
p03781
u463655976
1569667813
Python
Python (3.4.3)
py
Runtime Error
18
2940
101
x = int(input()) t = (-1 + math.sqrt(1 + 8 * x)) if t % 2 == 0: print(t//2) else: print(t//2+1)
s384522490
p03781
u230265105
1567035796
Python
Python (3.4.3)
py
Runtime Error
17
2940
61
x = int(input()) i = 0 while x>0 i = i+1 x = x-i print(i)
s097337857
p03781
u230265105
1567035286
Python
Python (3.4.3)
py
Runtime Error
17
2940
57
x = int(input()) i=0 while x>0 i++ x=x-i print(i)
s755550709
p03781
u778814286
1564261248
Python
PyPy3 (2.4.0)
py
Runtime Error
177
38640
724
###template### import sys def input(): return sys.stdin.readline().rstrip() from collections import defaultdict, Counter from itertools import product, groupby, count, permutations, combinations from math import pi, sqrt, ceil, floor from collections import deque from bisect import bisect, bisect_left, bisect_right fro...