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
s202958068
p04013
u950708010
1556204546
Python
Python (3.4.3)
py
Runtime Error
2107
57460
564
def solve(): n,a = (int(i) for i in input().split()) x = list(int(i) for i in input().split()) tp = max(x) dp = [[[0 for i in range(n*tp +1)] for j in range(n+1)] for k in range(n+1)] query = a*n dp[0][0][0] = 1 for i in range(1,n+1): for j in range(n+1): for k in range(n*tp +1): #選ばない ...
s185093054
p04013
u619458041
1556069113
Python
Python (3.4.3)
py
Runtime Error
18
2940
160
import sys def main(): input = sys.stdin.readline n = int(input()) s = int(input()) return ans if __name__ == '__main__': print(main())
s882406396
p04013
u227082700
1555470657
Python
Python (3.4.3)
py
Runtime Error
2107
54004
395
n,a=map(int,input().split()) x=list(map(int,input().split())) X=sum(x) dp=[[[0]*(X+1)for j in range(n+1)]for i in range(n+1)] dp[0][0][0]=1 for i in range(1,n+1): xi=x[i-1] for j in range(n+1): for h in range(X+1): if h<xi:dp[i][j][h]=dp[i-1][j][h] if xi<=h and j>=1:dp[i][j][h]=dp[i-1][j][h]+d...
s252634381
p04013
u268516119
1555008362
Python
Python (3.4.3)
py
Runtime Error
757
55028
664
#x枚目まででy枚選んで合計がzになる場合の数dp[x][y][z] N,A=map(int,input().split()) x=[int(i) for i in input().split()] dp=[[[0]*(A*N+1) for i in range(N+1)]for k in range(N+2)] ans=0 dp[0][0][0]=1 for made,i in enumerate(dp): if made>N:break for maisu,j in enumerate(i): for wa,k in enumerate(j): if k and made<...
s809370876
p04013
u268516119
1555007625
Python
Python (3.4.3)
py
Runtime Error
754
56052
587
#x枚目まででy枚選んで合計がzになる場合の数dp[x][y][z] N,A=map(int,input().split()) x=[int(i) for i in input().split()] dp=[[[0]*(A*50) for i in range(N+2)]for k in range(N+2)] ans=0 dp[0][0][0]=1 for made,i in enumerate(dp): if made>N:break for maisu,j in enumerate(i): for wa,k in enumerate(j): if k:#made枚目までに...
s039556758
p04013
u360090862
1554572838
Python
Python (3.4.3)
py
Runtime Error
2109
61672
497
import numpy as np N,A=map(lambda x:int(x),input().split()) x=[int(i) for i in input().split()] dp=np.zeros((N+1,N+1,sum(x)+1)) def solve(j,k,s): if k==0 and j==0 and s==0: return 1 elif j>=1 and s<x[j-1] : dp[j,k,s]=solve(j-1,k,s) return dp[j,k,s] elif j>=1 and k>=1 and s>=x[j-1]: dp[j,k,s]=sol...
s996634679
p04013
u013408661
1554504330
Python
Python (3.4.3)
py
Runtime Error
21
3188
292
n,a=map(int,input().split()) x=list(map(int,input())) stack=[0]*5001 stack[2500-a]=1 ans=0 for i in x: i-=a for i in x: ans+=stack[2500-i+a] stack2=[i for i in stack] for j in range(5001): if 0<=j+i<=5000: stack2[j+i]+=stack[j] stack=[i for i in stack2] print(stack[2500])
s825980711
p04013
u279493135
1554412627
Python
Python (3.4.3)
py
Runtime Error
245
5360
1068
from sys import stdin input = stdin.readline N, A = [int(x) for x in input().rstrip().split()] x = [int(x) for x in input().rstrip().split()] X = max(max(x), A) # dp = [[[0]*(N*X+1) for _ in range(N+1)] for _ in range(N+1)] # for j in range(N+1): # for k in range(N+1): # for s in range(N*X+1): # if j == 0 and k...
s605302876
p04013
u315485238
1553974107
Python
Python (3.4.3)
py
Runtime Error
180
14328
361
import numpy as np N, A = list(map(int, input().split())) X = list(map(int, input().split())) dp = [np.array([[0]*(N*A+1) for _ in range(N+1)])] #dp[0]: [0, 0]~[N, N*A] for x in X: new_dp = dp[-1] new_dp[1:, x:] += dp[-1][0:N, 0:N*A+1-x] new_dp[1, x] += 1 dp.append(new_dp) #print(dp[-1]) print(sum([dp[...
s413703386
p04013
u315485238
1553974044
Python
Python (3.4.3)
py
Runtime Error
181
14336
360
import numpy as np N, A = list(map(int, input().split())) X = list(map(int, input().split())) dp = [np.array([[0]*(N*A+1) for _ in range(N+1)])] #dp[0]: [0, 0]~[N, N*A] for x in X: new_dp = dp[-1] new_dp[1:, x:] += dp[-1][0:N, 0:N*A+1-x] new_dp[1, x] += 1 dp.append(new_dp) print(dp[-1]) print(sum([dp[-...
s591536146
p04013
u315485238
1553973860
Python
Python (3.4.3)
py
Runtime Error
179
14328
361
import numpy as np N, A = list(map(int, input().split())) X = list(map(int, input().split())) dp = [np.array([[0]*(N*A+1) for _ in range(N+1)])] #dp[0]: [0, 0]~[N, N*A] for x in X: new_dp = dp[-1] new_dp[1:, x:] += dp[-1][0:N, 0:N*A+1-x] new_dp[1, x] += 1 dp.append(new_dp) #print(dp[-1]) print(sum([dp[...
s797950516
p04013
u315485238
1553973078
Python
Python (3.4.3)
py
Runtime Error
1067
65468
396
import numpy as np from scipy.ndimage.interpolation import shift N, A = list(map(int, input().split())) X = list(map(int, input().split())) dp = [np.array([[0]*(N*A+1) for _ in range(N+1)])] #dp[0]: [0][0]~[N][N*A] for x in X: new_dp = dp[-1] + shift(dp[-1], [1, x], cval=0) new_dp[1][x] += 1 dp.append(new_d...
s614258534
p04013
u315485238
1553972773
Python
Python (3.4.3)
py
Runtime Error
1040
64504
394
import numpy as np from scipy.ndimage.interpolation import shift N, A = list(map(int, input().split())) X = list(map(int, input().split())) dp = [np.array([[0]*(N*A+1) for _ in range(N)])] for i in range(N): new_dp = dp[-1]+ shift(dp[-1], [1, X[i]], cval=0) new_dp[0][X[i]]=new_dp[0][X[i]]+1 dp.append(new_dp...
s161630694
p04013
u543954314
1553289471
Python
Python (3.4.3)
py
Runtime Error
21
3828
260
n,a = map(int,input().split()) dp = [[0]*2000 for _ in range(n+1)] dp[0][1000] = 1 x = list(map(int,input().split())) for i in range(n): x[i] -= a for i in range(1,n+1): for j in range(2001): dp[i][j] = dp[i-1][j] + dp[i-1][j-x[i-1]] print(dp[n][1000])
s256183479
p04013
u185034753
1552795180
Python
Python (3.4.3)
py
Runtime Error
17
2940
670
#include<iostream> #include<vector> using namespace std; unsigned long long dp[51][51][2501]; int main(int argc, char const *argv[]) { int N, A; cin>>N>>A; vector<int> x(N+1); for(int i=0; i<N; i++) { cin >> x[i+1]; } dp[0][0][0] = 1; for(int j=1; j<=N; j++) { for(int k=...
s832871118
p04013
u185034753
1552752694
Python
Python (3.4.3)
py
Runtime Error
2105
30688
817
def zeros(*dim): import copy if len(dim)==0: return 0 else: d = dim[0] a = zeros(*dim[1:]) return [copy.deepcopy(a) for _ in range(d)] def solve(a, A): a = sorted(a) N = len(a) S = sum(a) dp = zeros(N+1, N+1, S+1) a.insert(0, float("inf")) # add dummy ...
s420912209
p04013
u030626972
1551591788
Python
Python (3.4.3)
py
Runtime Error
2107
56308
781
def main(): #入力 n, a = map(int,input().split()) x = [0] + list(map(int,input().split())) sum_max = (n)*(max(x))+1 #dp[i][j][k]:x1-xiからj枚選んで、合計をkにする選び方の数 dp = [[[0]*sum_max for _ in range(n+1)] for _ in range(n+1)] dp[0][0][0] = 1 for i in range(n+1): for j in range(n+1): ...
s590085780
p04013
u887207211
1550980435
Python
Python (3.4.3)
py
Runtime Error
18
3064
302
N, A = map(int,input().split()) X = list(map(int,input().split())) X = [int(x) - A for x in input().split()] dp = [[0 for _ in range(100*N+1)] for _ in range(N+1)] dp[0][50*N] = 1 for i in range(N): for j in range(50, 100*N+1-50): dp[i+1][j] = dp[i][j] + dp[i][j - X[i]] print(dp[N][50*N] - 1)
s614999193
p04013
u762955009
1550293688
Python
Python (3.4.3)
py
Runtime Error
131
5748
389
N, A = map(int, input().split()) x = list(map(int, input().split())) y = list(map(lambda n:n-A, x)) X = max(x) dp = [[0 for i in range(2*X*N + 1)] for j in range(N + 1)] for i in range(1, N + 1): dp[i][y[i - 1] + N*X] += 1 for j in range(len(dp[0])): dp[i][j] += dp[i - 1][j] if dp[i - 1][j] > ...
s554567361
p04013
u367130284
1549819723
Python
Python (3.4.3)
py
Runtime Error
22
3316
204
import collections as c n,a=map(int,input().split()) X=[int(x)-a for x in input().split()] C=c.Counter([0]) for x in X: itiji=Counter() for i,c in C.items(): itiji[i+x]+=c C+=itiji print(C[0]-1)
s409891608
p04013
u690536347
1548774168
Python
PyPy3 (2.4.0)
py
Runtime Error
427
92764
510
n,a=map(int,input().split()) *x,=map(int,input().split()) b=max(x) dp=[[[0]*(n*b+1) for i in range(n+1)] for _ in range(n+1)] for i in range(n+1): for j in range(n+1): for k in range(n*b+1): if i==0 and j==0 and k==0: dp[i][j][k]=1 elif i and k<x[i-1]: ...
s083476123
p04013
u166696759
1548566635
Python
Python (3.4.3)
py
Runtime Error
18
2940
662
#include <bits/stdc++.h> using namespace std; int main(){ int N, A; cin >> N >> A; vector<int> cards(N); int maxX = -1*(1<<30); for(int i=0; i<N; ++i){ cin >> cards[i]; maxX = max(maxX, cards[i]); cards[i] -= A; } const int M = N * maxX; vector<vector<long long> >...
s012863654
p04013
u171366497
1547692162
Python
Python (3.4.3)
py
Runtime Error
85
3976
1225
N,A=map(int,input().split()) x=input().split() for i in range(N): x[i]=int(x[i]) ans=0 y=[0 for i in range(N)] def check(ans,y): ave=0 for i in range(N): ave+=x[i]*y[i] if sum(y)!=0: ave=ave/sum(y) if sum(y)==0: ave=0 if ave==A:ans+=1 return ans def branch(ans,now,pr...
s958671899
p04013
u550943777
1547615958
Python
Python (3.4.3)
py
Runtime Error
2108
54004
615
N,A = map(int,input().split()) x = [0] + list(map(int,input().split())) X = max(x) dp = [[[0]*(N*X+1) for k in range(N+1)] for j in range(N+1)] for j in range(N+1): for k in range(N+1): for s in range(N*X+1): if j == 0 and k == 0 and s == 0 : dp[j][k][s] = 1 elif j >...
s503067161
p04013
u052332717
1545869973
Python
Python (3.4.3)
py
Runtime Error
1295
62960
429
n, a = map(int, input().split()) x = list(map(int, input().split())) M = max(x) dp = [[[0]*(n*M+1) for _ in range(n+1)] for _ in range(n+1)] dp[0][0][0] = 1 for j in range(n): for k in range(n+1): for s in range(n*M+1): if dp[j][k][s]: dp[j+1][k][s] += dp[j][k][s] ...
s760675121
p04013
u052332717
1545869919
Python
Python (3.4.3)
py
Runtime Error
1431
62960
429
n, a = map(int, input().split()) x = list(map(int, input().split())) M = max(x) dp = [[[0]*(n*M+1) for _ in range(n+1)] for _ in range(n+1)] dp[0][0][0] = 1 for j in range(n): for k in range(n+1): for s in range(n*M+1): if dp[j][k][s]: dp[j+1][k][s] += dp[j][k][s] ...
s878917025
p04013
u052332717
1545865235
Python
Python (3.4.3)
py
Runtime Error
219
5356
801
N, A = map(int, input().split()) X = list(map(lambda x: int(x) - A, input().split())) maxn = max(max(X), A) dp = [[0 for _ in range(2 * N * maxn + 1)] for _ in range(N + 1)] dp[0][N * maxn] = 1 for i in range(N): for k in range(2 * N * maxn + 1): dp[i + 1][k] = dp[i][k] if 0 <= k - X[i] <= 2 * N...
s875354580
p04013
u052332717
1545865199
Python
Python (3.4.3)
py
Runtime Error
221
7284
800
N, A = map(int, input().split()) X = list(map(lambda x: int(x) - A, input().split())) maxn = max(max(X), A) dp = [[0 for _ in range(2 * N * maxn + 1)] for _ in range(N + 1)] dp[0][N * maxn] = 1 for i in range(N): for k in range(2 * N * maxn + 1): dp[i + 1][k] = dp[i][k] if 0 <= k - X[i] <= 2 * N...
s162041917
p04013
u643840641
1545572017
Python
Python (3.4.3)
py
Runtime Error
2107
56436
425
n, a = map(int, input().split()) x = list(map(int, input().split())) sum = sum(x) dp = [[[0 for s in range(sum+1)] for k in range(n+1)] for i in range(n+1)] dp[0][0][0] = 1 for i in range(1, n+1): for k in range(n+1): for s in range(sum+1): if s >= x[i-1]: dp[i][k][s] = dp[i-1][k][s] + dp[i-1][k-1][s-x[i-1]] ...
s485028008
p04013
u782098901
1545404381
Python
Python (3.4.3)
py
Runtime Error
2107
58356
513
N, A = map(int, input().split()) # X = list(map(lambda x: int(x) - A, input().split())) X = list(map(int, input().split())) dp = [[[0 for _ in range(max(X) * N + 1)] for _ in range(N + 1)] for _ in range(N + 1)] dp[0][0][0] = 1 for i in range(N): for j in range(N): for k in range(max(X) * N + 1): ...
s033000812
p04013
u140251125
1543514577
Python
Python (3.4.3)
py
Runtime Error
36
3444
592
import collections # input n, a = map(int, input().split()) X = [int(i) - a for i in input().split()] S = collections.Counter([0, X[0]]) # Xから1枚以上選んで作ることが可能な和:作り方の場合の数 # 1枚も選ばない=0:1通り # X[0]のみ選ぶ=X[0]:1通り for i in X[1:]: # 選べるカードを増やしていく (X[0] ~ X[i] から選ぶ) S_temp = collections.Counter() for s, c in S.items(): ...
s774584993
p04013
u297109012
1540699413
Python
Python (3.4.3)
py
Runtime Error
2108
3064
963
import math from itertools import combinations def solve(N, A, Xs): diffs = [x - A for x in Xs] minus = [d for d in diffs if d < 0] minuses = {} plus = [d for d in diffs if d > 0] pluses = {} zero = [d for d in diffs if d == 0] for n in range(1, len(minus) + 1): for ns in combinat...
s274022112
p04013
u474270503
1538250242
Python
Python (3.4.3)
py
Runtime Error
18
3064
501
N,A=map(int, input().split()) x=[int(x) for x in input().split()] sort(x) W=sum(x) dp=[[[0]*(W+1) for _ in range(N+1)] for _ in range(N+1)] for j in range(N+1): dp[j][0][0]=1 for j in range(1,N+1): xj=x[j-1] for k in range(1, N+1): for s in range(1, W+1): if s<xj: dp[j][k...
s587645999
p04013
u474270503
1538248868
Python
Python (3.4.3)
py
Runtime Error
2107
58484
618
N,A=map(int, input().split()) x=list(map(int, input().split())) dp=[] for _ in range(N+1): dp.append([[0 for _ in range(N*max(x)+1)] for _ in range(N+1)]) for j in range(0,N+1): for k in range(0, N+1): for s in range(0, N*max(x)+1): if j>=1 and s<x[j-1]: dp[j][k][s]=dp[j-1][k...
s567728053
p04013
u474270503
1538248645
Python
Python (3.4.3)
py
Runtime Error
2107
56436
614
N,A=map(int, input().split()) x=list(map(int, input().split())) dp=[] for _ in range(N+1): dp.append([[0 for _ in range(sum(x)+1)] for _ in range(N+1)]) for j in range(0,N+1): for k in range(0, N+1): for s in range(0, sum(x)+1): if j>=1 and s<x[j-1]: dp[j][k][s]=dp[j-1][k][s]...
s799924492
p04013
u611249982
1537191911
Python
Python (3.4.3)
py
Runtime Error
2107
58484
472
n, a = [int(i) for i in input().split()] x = [int(i) for i in input().split()] nx = n * max(max(x), a) dp = [[[0 for k in range(nx + 1)] for j in range(n + 1)] for i in range(n + 1)] dp[0][0][0] = 1 for i in range(n): for j in range(n): for k in range(nx): if k + x[j] <= n * a: ...
s101066790
p04013
u957084285
1534446698
Python
Python (3.4.3)
py
Runtime Error
177
4980
358
n,a = map(int, input().split()) x = list(map(lambda x:int(x)-a, input().split())) y = max(x) dp = [[0]*(2*n*y+1) for _ in range(n+1)] dp[0][n*y] = 1 for k in range(n): for i in range(2*n*y+1): if i+x[k] < 0 or i+x[k] > 2*n*y: dp[k+1][i] = dp[k][i] else: dp[k+1][i] = dp[k][i]...
s905167957
p04013
u690536347
1534265881
Python
Python (3.4.3)
py
Runtime Error
2107
58484
522
n,a=map(int,input().split()) l=list(map(int,input().split())) x=max(l) dp=[[[0 for _ in range(n*x+1)] for _ in range(n+1)] for _ in range(n+1)] for j in range(n+1): for k in range(n+1): for s in range(n*x+1): if j==0 and k==0 and s==0: dp[j][k][s]=1 elif j>=1 and s<l[j-1]: dp[j][k][s]...
s627119270
p04013
u562935282
1534093390
Python
Python (3.4.3)
py
Runtime Error
2107
59760
662
def ary3(x, y, z, v): return [[[v for _ in range(z)] for _ in range(y)] for _ in range(x)] n, a = map(int, input().split()) x = list(map(int, input().split())) m = max(x) dp = ary3(n + 1, n + 1, m * n + 1, 0)#(選べる枚数(範囲)0 ~ n, 選んだ枚数0 ~ n, 合計0 ~ n * max(x)) = パターン数 for i in range(n + 1): dp[i][0][0] = 1 for i in ...
s497314873
p04013
u439396449
1532405387
Python
Python (3.4.3)
py
Runtime Error
2109
58612
537
from itertools import product N, A = map(int, input().split()) x = [int(x) for x in input().split()] max_x = max(max(x), A) dp = [[[0 for _ in range(N * max_x)] for _ in range(N + 1)] for _ in range(N + 1)] dp[0][0][0] = 1 for j, k, s in product(range(1, N + 1), range(N + 1), range(N * max_x)): if s < x[j - 1]: ...
s899198357
p04013
u439396449
1532404449
Python
Python (3.4.3)
py
Runtime Error
2107
56564
557
N, A = map(int, input().split()) x = [int(x) for x in input().split()] max_x = max(x) dp = [[[0 for _ in range((N + 1) * max_x)] for _ in range(N + 1)] for _ in range(N + 1)] dp[0][0][0] = 1 for j in range(1, N + 1): for k in range(N + 1): for s in range((N + 1) * max_x): if s < x[j - 1]: ...
s096371942
p04013
u415905784
1532404188
Python
Python (3.4.3)
py
Runtime Error
18
3064
699
import heapq N, A = map(int, input().split()) X = [int(x) - A for x in input().split()] for x in X: if x > 0: Xp.append(x) elif x < 0: Xm.append(-x) else: X0.append(x) limit = min(sum(Xp), sum(Xm)) Xp = [x for x in Xp if x <= limit] Xm = [x for x in Xm if x <= limit] R = [[0, 0] for x in range(limit +...
s557245995
p04013
u136090046
1532215255
Python
Python (3.4.3)
py
Runtime Error
17
2940
933
import itertools↲ ↲ n, a = map(int, input().split())↲ array = [int(x) for x in input().split()]↲ ↲ array2 = []↲ tmp ...
s905299871
p04013
u118605645
1531064254
Python
Python (3.4.3)
py
Runtime Error
2213
1810060
656
import itertools def get_all_comb(ary): r = [] for i in range(1, len(ary) + 1): r += list(itertools.combinations(ary, i)) return r N, A = (int(s) for s in input().split()) X = [int(s) for s in input().split()] lowers = [] i = 0 while X[i] < A: lowers.append((X[i])) i += 1 lowers = [x for...
s168093638
p04013
u559823804
1528951024
Python
Python (3.4.3)
py
Runtime Error
2107
56436
449
n,a=map(int,input().split()) x=list(map(int,input().split())) X=max(x) X=max(X,a) dp=[[[0 for _ in range(n*X+1)] for _ in range(51)] for _ in range(51)] dp[0][0][0]=1 for j in range(n): for k in range(n+1): for s in range(n*X+1): dp[j+1][k][s]+=dp[j][k][s] if x[j]+s<n*X+1: ...
s162908411
p04013
u846150137
1527121940
Python
Python (3.4.3)
py
Runtime Error
17
2940
375
n, a = [int(i) for i in input().split()] x = [int(i) for i in input().split()] dp=[[0 for i in range(a*n+1)] for j in range(n+1)] dp[0][0]=1 ans=0 f=0 for k in range(1,n+1): kx=x[k-1] f+=kx for i in range(k,0,-1): for j in range(kx,a*n+1): dp[i][j] += dp[i-1][j-kx] if j > f: break ...
s487406936
p04013
u846150137
1527121236
Python
Python (3.4.3)
py
Runtime Error
2109
14680
435
import numpy as np n, a = [int(i) for i in input().split()] x = [int(i) for i in input().split()] sx=sum(x) dp= np.zeros((n+1,sx+1),dtype='int32') #dp=[[0]*(n*a+1)]*(n+1) dp[0][0]=1 ans=0 f=0 for k in range(1,n+1): kx=x[k-1] f+=kx for i in range(k,0,-1): for j in range(kx,sx+1): dp[i][j] += dp[i-1][j-kx...
s610245692
p04013
u846150137
1527111339
Python
Python (3.4.3)
py
Runtime Error
2109
14568
425
import numpy as np n, a = [int(i) for i in input().split()] x = [int(i) for i in input().split()] dp= np.zeros((n+1,n*a+1),dtype=int) dp[0][0]=1 ans=0 f=0 for k in range(1,n+1): f+=x[k-1] for i in range(k,-1,-1): for j in range(0, f + 1): if j>=x[k-1] and i>=1: dp[i][j]= dp[i][j] + dp[i-1][j-x[k...
s883552179
p04013
u846150137
1527111045
Python
Python (3.4.3)
py
Runtime Error
1633
13160
428
import numpy as np n, a = [int(i) for i in input().split()] x = [int(i) for i in input().split()] sx=sum(x) dp= np.zeros((n+1,n*a+1),dtype=int) dp[0][0]=1 ans=0 f=0 for k in range(1,n+1): f+=k for i in range(k,-1,-1): for j in range(0, f + 1): if j>=x[k-1] and i>=1: dp[i][j]= dp[i][j] + dp[i-1][j...
s102090630
p04013
u846150137
1527110933
Python
Python (3.4.3)
py
Runtime Error
2108
13040
422
import numpy as np n, a = [int(i) for i in input().split()] x = [int(i) for i in input().split()] sx=sum(x) dp= np.zeros((n+1,n*a+1),dtype=int) dp[0][0]=1 ans=0 for k in range(1,n+1): for i in range(k,-1,-1): for j in range(0, sx * n + 1): if j>=x[k-1] and i>=1: dp[i][j]= dp[i][j] + dp[i-1][j-x[k-1...
s067346679
p04013
u846150137
1527110137
Python
Python (3.4.3)
py
Runtime Error
18
3064
419
n, a = [int(i) for i in input().split()] x = [int(i) for i in input().split()] dp= np.zeros((n+1,n+1,n*a+1),dtype=int) dp[0][0][0]=1 ans=0 for k in range(1,n+1): for i in range(0,k+1): for j in range(0,a * i+1): if j>=x[k-1] and i>=1: dp[k][i][j]= dp[k-1][i][j] + dp[k-1][i-1][j-x[k-1]] else:...
s212831457
p04013
u846150137
1527109788
Python
Python (3.4.3)
py
Runtime Error
151
12452
405
import numpy as np n, a = [int(i) for i in input().split()] x = [int(i) for i in input().split()] dp= np.zeros((n+1,s*n+1),dtype=int) dp[0][0]=1 ans=0 for k in range(1,n+1): for i in range(0,k+1): for j in range(0,s*n+1): if j>=x[k-1] and i>=1: dp[i][j]= dp[i][j] + dp[i-1][j-x[k-1]] else: ...
s170046804
p04013
u846150137
1527109705
Python
Python (3.4.3)
py
Runtime Error
149
14500
419
import numpy as np n, a = [int(i) for i in input().split()] x = [int(i) for i in input().split()] xs=sum(x) dp= np.zeros((n+1,xs*n+1),dtype=int) dp[0][0][0]=1 ans=0 for k in range(1,n+1): for i in range(0,k+1): for j in range(0,xs*n+1): if j>=x[k-1] and i>=1: dp[i][j]= dp[i][j] + dp[i-1][j-x[k-1]] ...
s924128898
p04013
u846150137
1527109599
Python
Python (3.4.3)
py
Runtime Error
2108
37092
447
import numpy as np n, a = [int(i) for i in input().split()] x = [int(i) for i in input().split()] xs=sum(x) dp= np.zeros((n+1,n+1,xs*n+1),dtype=int) dp[0][0][0]=1 ans=0 for k in range(1,n+1): for i in range(0,k+1): for j in range(0,xs*n+1): if j>=x[k-1] and i>=1: dp[k][i][j]= dp[k-1][i][j] + dp[k-1...
s194897703
p04013
u846150137
1527109542
Python
Python (3.4.3)
py
Runtime Error
2108
36964
446
import numpy as np n, a = [int(i) for i in input().split()] x = [int(i) for i in input().split()] xs=sum(x) dp= np.zeros((n+1,n+1,n*a+1),dtype=int) dp[0][0][0]=1 ans=0 for k in range(1,n+1): for i in range(0,k+1): for j in range(0,xs*n+1): if j>=x[k-1] and i>=1: dp[k][i][j]= dp[k-1][i][j] + dp[k-1]...
s966918474
p04013
u503901534
1526621094
Python
Python (3.4.3)
py
Runtime Error
18
3064
758
s = int(input()) sl = list(str(s)) sl_n = len(sl) - 1 l = ['a','b'] def a_or_b(x): if len(list(str(x[0]))) == sl_n: return x else: ll = [] for i in range(len(x)): ll.append(x[i] + 'a') for i in range(len(x)): ll.append(x[i] + 'b') x = ll re...
s536350045
p04013
u503901534
1525486911
Python
Python (3.4.3)
py
Runtime Error
17
2940
435
n, a = map(int,input().split()) x = list(map(int,input().split())) xx = [] for i in range(n): xx.append(x-a) X = max(xx) #dp def dp(j,t,l=xx): if j = 0 and t = n * X: return 1 elif j > 0 and t -l[j] < 0 or t- l[j] > 2* n * X: return dp(j-1,t,l=xx) elif j > 1 and 0 <= t-l[j] <= 2*n*X...
s559823355
p04013
u667024514
1524843790
Python
Python (3.4.3)
py
Runtime Error
17
3064
373
n = int(input()) a = sorted(map(int,input().split())) b = sorted(map(int,input().split())) c = sorted(map(int,input().split())) lis = [0] * n j = 0 for i in range(n): while j < n and a[j] < b[i]: j += 1 lis[i] = j li = [0] * n m = 0 j = 0 for i in range(n): while j < n and b[j] < c[i]: m +...
s269193579
p04013
u125205981
1524438201
Python
Python (3.4.3)
py
Runtime Error
181
4980
568
def main(): N, A = map(int, input().split()) X = tuple(map(int, input().split())) x = [i - A for i in X] nx = max(x) * N dp = [[0] * (2 * nx + 1) for _ in [0] * (N + 1)] for i in range(N + 1): for j in range(2 * nx + 1): if not i: if j == nx: ...
s810024471
p04013
u281303342
1524340107
Python
Python (3.4.3)
py
Runtime Error
2107
58484
617
N,A = map(int,input().split()) X = [0]+list(map(int,input().split())) sumX = sum(X) dp = [[[0 for _ in range(sumX+1)] for _ in range(N+1)] for _ in range(N+1)] dp[0][0][0] = 1 for i in range(1,N+1): for j in range(0,i+1): for k in range(sum(X)+1): if j==0 and k==0: dp[i][j][k] ...
s043980293
p04013
u281303342
1524339557
Python
Python (3.4.3)
py
Runtime Error
2107
61680
570
N,A = map(int,input().split()) X = [0]+list(map(int,input().split())) maxX = max(X) dp = [[[0 for _ in range(N*maxX+1)] for _ in range(N+1)] for _ in range(N+1)] dp[0][0][0] = 1 for i in range(1,N+1): for j in range(0,i+1): for k in range(N*maxX+1): if j==0 and k==0: dp[i][j][k...
s453971103
p04013
u075012704
1524276566
Python
Python (3.4.3)
py
Runtime Error
2108
54772
478
N, A = map(int, input().split()) X = list(map(int, input().split())) x_max = max(X) dp = [[[0]*(N*x_max+1) for i in range(N+1)] for i in range(N+1)] dp[0][0][0] = 1 for j in range(1, N+1): for k in range(N+1): for s in range(N*x_max+1): if X[j-1] <= s: dp[j][k][s] = dp[j-1][k][s...
s535561228
p04013
u952708174
1522618062
Python
Python (3.4.3)
py
Runtime Error
18
3060
419
def c_atcodeer_and_election_report(N, R): from math import ceil t = 1 # 高橋の票数 a = 1 # 青木の票数 for x, y in R: # t<=nx ∧ a<=ny を満たす最小のnを求める n = max(ceil(t / x), ceil(a / y)) t = n * x a = n * y return t + a N = int(input()) R = [[int(i) for i in input().split()] for j i...
s186447755
p04013
u651925006
1520964525
Python
Python (3.4.3)
py
Runtime Error
17
2940
80
a, b, c = input().split() print('YES' if a[-1]==b[0] and b[-1]==c[0] else 'NO')
s250090165
p04013
u764600134
1518366974
Python
Python (3.4.3)
py
Runtime Error
2027
61772
1045
# -*- coding: utf-8 -*- """ https://beta.atcoder.jp/contests/abc044/tasks/arc060_a """ import sys from sys import stdin from copy import copy, deepcopy input = stdin.readline def solve(N, A, cards): ans = 0 cards.append(0) cards.sort() W = max(cards) * N # dp[j][k][s]: j番目までのカードをk枚使って合計をsにする組み合わ...
s134611784
p04013
u952708174
1517167184
Python
Python (3.4.3)
py
Runtime Error
81
5748
418
def c_Tak_and_Cards(N, A, S): X = max(S) y = [x - A for x in S] dp = [[0 for _ in range(2 * N * X + 1)] for _ in range(N + 1)] dp[0][N * X] = 1 for j in range(N): for t in range(X, (2 * N - 1) * X): dp[j + 1][t] = dp[j][t] + dp[j][t - y[j]] return dp[N][N * X] - 1 N,A = [int(...
s129682693
p04013
u621935300
1514013520
Python
Python (2.7.6)
py
Runtime Error
2107
55676
525
N,A=map(int,raw_input().split()) x=[0]+map(int,raw_input().split()) #print x max_n=max(x) dp=[[[0]*(N*max_n+1) for k in range(N + 1)] for j in range(N+1)] #print dp for j in range(N+1): for k in range(N+1): for s in range(N*max_n+1): if j==k==s==0: dp[j][k][s]=1 elif j>=1 and s<x[j]: dp[j][k][s]=dp...
s093684778
p04013
u879309973
1495628106
Python
Python (2.7.6)
py
Runtime Error
1825
63360
408
import numpy as np N, A = map(int, raw_input().split()) x = map(int, raw_input().split()) dp = np.full((N+1, A+1, (N+1)*(A+1)), -1) def dfs(i, t, W): if t == 0: return int(W == 0) if i < 0: return 0 if dp[i, t, W] > -1: return dp[i, t, W] dp[i, t, W] = dfs(i-1, t, W) + dfs(i-1, ...
s636976868
p04013
u332385682
1490738752
Python
Python (3.4.3)
py
Runtime Error
129
54004
560
N, A = map(int, input().split()) x = [int(i) for i in input().split()] # 3d DP max_x = max(x) dp = [[[0] * (max_x * N + 1) for j in range(N + 1)] for i in range(N + 1)] dp[0][0][0] = 1 for i in range(0, N): for k in range(0, N + 1): for y in range(max_x * N + 1): ...
s881571500
p04013
u481333386
1489285611
Python
Python (3.4.3)
py
Runtime Error
18
3060
390
n, a = [int(e) for e in input().split()] lst = [int(e) for e in input().split()] def main(n, a, lst): count = 0 lst_len = len(lst) for i in range(1, i + 1): for j, _ in enumerate(lst): if lst_len <= j + i: break e = lst[j:j + i] if e // i == a: ...
s679741117
p04013
u332385682
1488400419
Python
Python (3.4.3)
py
Runtime Error
225
3444
612
import sys from collections import Counter def debug(x, table): for name, val in table.items(): if x is val: print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr) return None def solve(): N, A = map(int, input().split()) assert N <= 16 x = [int(i) for i in input(...
s195187262
p04013
u614550445
1485640939
Python
Python (3.4.3)
py
Runtime Error
1021
4208
362
N, A = [int(_) for _ in input().split()] x = sorted([int(_) for _ in input().split()]) dp = [[0] * (sum(x)+1) for j in range(N+1)] dp[0][0] = 1 for i in range(1, N+1): for j in list(range(1, N+1))[::-1]: for k in list(range(x[i-1], sum(x[:i])+1))[::-1]: dp[j][k] += dp[j-1][k - x[i-1]] print(...
s240276578
p04013
u831695469
1478859316
Python
Python (3.4.3)
py
Runtime Error
22
3064
323
n, a = map(int, raw_input().split()) X = map(int, raw_input().split()) dp = [[0]*(n*a+1) for i in xrange(n+1)] dp[0][0] = 1 for i in xrange(n): for j in xrange(i, -1, -1): for k in xrange(n*a, X[i]+1, -1): dp[j+1][k] += dp[j][k-X[i]] ans = 0 for i in xrange(1, n+1): ans += dp[i][i*a] print a...
s605216610
p04013
u664481257
1478645487
Python
Python (3.4.3)
py
Runtime Error
45
5388
1278
# -*- coding: utf-8 -*- # !/usr/bin/env python # vim: set fileencoding=utf-8 : """ # # Author: Noname # URL: https://github.com/pettan0818 # License: MIT License # Created: 火 11/ 8 17:04:53 2016 # Usage # """ from itertools import repeat from itertools import combinations import sys from statistics import m...
s398568631
p04013
u065683101
1475679579
Python
Python (3.4.3)
py
Runtime Error
1080
38900
550
from array import array def read(): return int(input()) def reads(sep=None): return list(map(int, input().split(sep))) def main(): n, a = reads() x = reads() s = sum(x) dp = [[array('I', [0]*3500) for j in range(n+1)] for i in range(n+1)] dp[0][0][0] = 1 for i in range(n): for...
s716220110
p04013
u343675824
1473557119
Python
Python (3.4.3)
py
Runtime Error
38
3064
1026
#include <bits/stdc++.h> #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--) #define REP(i,n) for(int i=0;i<(n);i++) #define RREP(i,n) for(int i=n-1;i>=0;i--) #define PB push_back #define MP make_pair #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(),(a).rend()...
s662166796
p04013
u212829728
1473092318
Python
Python (3.4.3)
py
Runtime Error
41
3316
1042
def app(numlist, A ): counter = 0 N = len(numlist) for i in range(1,N): counter += f(numlist, i, A*i) return counter def f(numlist, rest, sum): result = 0 numset = set(numlist) if rest == 1: return numlist.count(sum) elif rest == 2: for big in numset: if (sum - big in numset) and (bi...
s138112581
p04013
u442810826
1472456886
Python
Python (2.7.6)
py
Runtime Error
30
2568
1438
rom itertools import combinations n,a=map(int,raw_input().split()) x=map(int,raw_input().split()) el_plus = [] el_minus = [] sum_plus_dict = {"def":None} sum_minus_dict = {"def":None} x = [el - a for el in x] count_zero = 0 count = 0 for i in range(len(x)): if x[i] > 0: el_plus.append(x[i]) elif x[i]...
s078914664
p04013
u442810826
1472455880
Python
Python (2.7.6)
py
Runtime Error
28
2696
1351
from itertools import combinations n,a=map(int,raw_input().split()) x=map(int,raw_input().split()) el_plus = [] el_minus = [] sum_plus_dict = {"def":None} sum_minus_dict = {"def":None} x = [el - a for el in x] count_zero = 0 count = 0 for i in range(len(x)): if x[i] > 0: el_plus.append(x[i]) elif x[i...
s849215541
p04013
u123756661
1472434241
Python
Python (2.7.6)
py
Runtime Error
473
4612
276
n,a=map(int,raw_input().split()) x=map(int,raw_input().split()) ans=0 for i in range(1<<n): chk=0 t=bin(i)[2:] t='0'*(n-len(t))+t for j,p in enumerate(t): if p=='1': chk+=x[j] if chk!=0 and chk==a*t.count('1'): ans+=1 print ans
s009355390
p04014
u825685913
1600745759
Python
Python (3.8.2)
py
Runtime Error
429
9380
508
#自分の回答 import math def digit(b, n): if n < b: return n else: return digit(b, math.floor(n/b)) + n % b n, s = int(input()), int(input()) if n == s: print(n+1) exit() if n < s: print(-1) exit() for i in range(2, int(math.sqrt(n)) + 2): if digit(i, n) == s: print(i...
s100018785
p04014
u825685913
1600745317
Python
Python (3.8.2)
py
Runtime Error
433
9692
508
#自分の回答 import math def digit(b, n): if n < b: return n else: return digit(b, math.floor(n/b)) + n % b n, s = int(input()), int(input()) if n == s: print(n+1) exit() if n < s: print(-1) exit() for i in range(2, int(math.sqrt(n)) + 2): if digit(i, n) == s: print(i...
s984660441
p04014
u825685913
1600744680
Python
Python (3.8.2)
py
Runtime Error
428
9392
506
#自分の回答 import math def digit(b, n): if n < b: return n else: return digit(b, math.floor(n/b)) + n % b n, s = int(input()), int(input()) if n == s: print(n+1) exit() if n < s: print(-1) exit() for i in range(2, int(math.sqrt(n) + 1)): if digit(i, n) == s: print(i...
s401456114
p04014
u825685913
1600744464
Python
Python (3.8.2)
py
Runtime Error
431
9476
483
import math def digit(b, n): if n < b: return n else: return digit(b, math.floor(n/b)) + n % b n, s = int(input()), int(input()) if n == s: print(n+1) exit() if n < s: print(-1) exit() for i in range(2, int(math.sqrt(n))): if digit(i, n) == s: print(i) e...
s407215184
p04014
u969708690
1599275046
Python
Python (3.8.2)
py
Runtime Error
27
9112
102
n=int(input()) s=int(input()) if n==s: print(n+1) exit() if (n+3)//2<=s: print(-1) exit() ewew
s461030622
p04014
u074220993
1599106043
Python
Python (3.8.2)
py
Runtime Error
285
9612
496
n, s = int(input()), int(input()) f = lambda b,n:n if n < b else n%b + f(b,n//b) import math ans = n+2 for b in range(2,math.ceil(math.sqrt(n))): #O(√n)の全探索 if f(b,n) == s: ans = b; break else: for p in range(math.ceil(math.sqrt(n))): #n=pb+q (b>√n, p+q=s)に基づいたO(√n)の全探索 q = s-p if p > 0...
s533095829
p04014
u533039576
1597252447
Python
PyPy3 (7.3.0)
py
Runtime Error
2207
74736
539
def func(b, n): res = 0 while n > 0: res += n % b n //= b return res def solve(): n = int(input()) s = int(input()) if n == s: return n + 1 # elif n < s: # return -1 for b in range(2, n + 1): if b**2 > n: break if func(b, n)...
s950581888
p04014
u758815106
1595830542
Python
Python (3.8.2)
py
Runtime Error
388
9196
442
import math n = int(input()) s = int(input()) r = 0 if n == s: print(n + 1) exit() nn = int(math.sqrt(n)) + 1 for i in range(2, nn): nt = n st = 0 while nt > 0: st += nt % i nt //= i if st == s: print(i) exit() for i in range(nn, 0, -1): nt = n ...
s329214318
p04014
u758815106
1595830427
Python
PyPy3 (7.3.0)
py
Runtime Error
114
75104
480
import math n = int(input()) s = int(input()) r = 0 if n == s: print(n + 1) exit() elif n < s: print(-1) exit() nn = int(math.sqrt(n)) + 1 for i in range(2, nn): nt = n st = 0 while nt > 0: st += nt % i nt //= i if st == s: print(i) exit() for ...
s426873946
p04014
u758815106
1595829262
Python
Python (3.8.2)
py
Runtime Error
483
9188
554
import math n = int(input()) s = int(input()) r = 0 if n == s: print(n + 1) exit() elif n < s: print(-1) exit() elif s == 1: print(n) exit() nn = int(math.sqrt(n)) + 1 for i in range(2, nn): nt = n st = 0 while nt > 0: st += nt % i nt //= i if st == s: ...
s011869719
p04014
u726872801
1595660496
Python
Python (3.8.2)
py
Runtime Error
2206
9648
856
import sys import heapq, math from itertools import zip_longest, permutations, combinations, combinations_with_replacement from itertools import accumulate, dropwhile, takewhile, groupby from functools import lru_cache from copy import deepcopy N, S = [int(input()), int(input())] def solve1(): i = 2 while i ...
s232264597
p04014
u786020649
1594407897
Python
Python (3.8.2)
py
Runtime Error
59
9120
618
import sys import math def divlist(n): sl=[] ll=[] for x in range(1,int(math.sqrt(n))+1): if n%x==0: sl.append(x) ll.append(n//x) ll.reverse() sl.extend(ll) return sl def f(b,n): if n<b: return n else: return f(b,n//b)+(n%b) def main(n,s): if...
s410403577
p04014
u786020649
1594407539
Python
Python (3.8.2)
py
Runtime Error
28
9056
547
import sys import math n=int(sys.stdin.readline().strip()) s=int(sys.stdin.readline().strip()) def divlist(n): sl=[] ll=[] for x in range(1,int(math.sqrt(n))+1): if n%x==0: sl.append(x) ll.append(n//x) ll.reverse() sl.extend(ll) return sl def f(b,n): if n<b: ...
s636813106
p04014
u203843959
1590546623
Python
PyPy3 (2.4.0)
py
Runtime Error
240
40684
405
import sys n=int(input()) s=int(input()) if n==s: print(n+1) sys.exit(0) def f(b,n): ret=0 while n: ret+=n%b n//=b return ret for b in range(2,int(n**0.5)+1): ss=f(b,n) if ss==s: print(b) sys.exit(0) #n=pb+q for p in range(1,int(n**0.5)+1): q=s-p b=(n-q)//p if q<0 or (n-q)%p!=0: ...
s780288528
p04014
u888100977
1590112909
Python
Python (3.4.3)
py
Runtime Error
313
20884
615
n = int(input()) s = int(input()) import sys sys.setrecursionlimit(20000) import math def f(b, n): # print(b, n) if n<b: return n else: x = f(b, n//b) + n%b return x # print(f(100000000000,100000000000)) ans = 0 # if n<s: # print(-1) # exit() if n==s: print(n+1) exit...
s523173150
p04014
u888100977
1590112373
Python
Python (3.4.3)
py
Runtime Error
309
4020
504
n = int(input()) s = int(input()) import math def f(b, n): # print(b, n) if n<b: return n else: x = f(b, n//b) + n%b return x ans = 0 if n<s: print(-1) exit() for b in range(2,int(math.sqrt(n))+500): if f(b, n) == s: ans = b print(ans) ex...
s704641649
p04014
u888100977
1590112350
Python
PyPy3 (2.4.0)
py
Runtime Error
360
52592
504
n = int(input()) s = int(input()) import math def f(b, n): # print(b, n) if n<b: return n else: x = f(b, n//b) + n%b return x ans = 0 if n<s: print(-1) exit() for b in range(2,int(math.sqrt(n))+500): if f(b, n) == s: ans = b print(ans) ex...
s762984161
p04014
u915647268
1588667512
Python
Python (3.4.3)
py
Runtime Error
537
3188
355
n = int(input()) s = int(input()) sq = n**.5 ans = '-1' for b in range(2, int(sq)+1): sum = 0 tmp = n while tmp//b != 0: sum += tmp%b tmp //= b sum += tmp if sum == s: ans = b break if ans == '-1': for p in range(int(sq), 0, -1): b = (n-s+p)/p if b % 1 == 0: b = int(b) q = n%b if p+q == s: ...
s427491459
p04014
u308918401
1588637868
Python
Python (3.4.3)
py
Runtime Error
18
2940
177
def f(b,n): if n<b: return(n) else: return(f(b,int(n/b))+n%b) n=int(input()) s=int(inout()) t=-1 for i in range(n-2): if f(i+2,n)==s: t=i+2 break print(t)
s136893337
p04014
u915647268
1587822431
Python
Python (3.4.3)
py
Runtime Error
547
3064
360
n = int(input()) s = int(input()) sq = n**.5 ans = '-1' for b in range(2, int(sq)+1): sum = 0 tmp = n while tmp//b != 0: sum += tmp%b tmp //= b sum += tmp if sum == s: ans = b break if ans == '-1': for p in range(int(sq), 0, -1): b = (n-s+p)/p if b.is_integer(): b = int(b) q = n%b if p+q ==...