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
s714944906
p04012
u023229441
1551237589
Python
Python (3.4.3)
py
Runtime Error
18
2940
96
s=input() s=list(s) for i in s: if s.count(s[i])%2==1: print("No") exit() print("Yes")
s105399236
p04012
u952130512
1550487885
Python
Python (3.4.3)
py
Runtime Error
18
2940
181
w=input() s=[0]*123 for i in len(w): s[ord(w[i-1])]+=1 c=1 for i in range(97,97+26): if s[i]%2==1: c=0 break if c==1: print("Yes") else: print("No")
s973379677
p04012
u952130512
1550487225
Python
Python (3.4.3)
py
Runtime Error
17
2940
246
w=input() s=[0]*123 while len(w)==0: for i in range(97,97+26): if chr(i)==w[0]: s[i]+=1 w=w[1:] c=1 for i in range(97,97+26): if s[i]%2!=0: c=0 break if c==1: print("Yes") else: print("No")
s643497576
p04012
u952130512
1550487153
Python
Python (3.4.3)
py
Runtime Error
17
2940
272
w=input() s=[0]*123 while len(w)==0: for i in range(97,97+26): if chr(i)==w[0]: s[i]+=1 w=w[1:] c=1 for i in range(97,97+26): if s[i]%2==0: continue else: c=0 break if c=1: print("Yes") else: print("No")
s015845746
p04012
u952130512
1550487090
Python
Python (3.4.3)
py
Runtime Error
17
2940
273
w=input() s=[0]*123 while(len(w)==0): for i in range(97,97+26): if chr(i)==w[0]: s[i]+=1 w=w[1:] c=1 for i in range(97,97+26): if s[i]%2==0: continue else: c=0 break if c=1: print("Yes") else: print("No")
s035876876
p04012
u518064858
1550383497
Python
Python (3.4.3)
py
Runtime Error
18
2940
150
s=input() p=list(set(list(s))) a=[] for i in p: a.append(s.count(i)) for x in a: if x%2!==0: print("No") exit() print("Yes")
s842754421
p04012
u518064858
1550383448
Python
Python (3.4.3)
py
Runtime Error
17
2940
148
s=input() p=list(set(list(s))) a=[] for i in p a.append(s.count(i)) for x in a: if x%2!==0: print("No") exit() print("Yes")
s248515623
p04012
u367130284
1549828729
Python
Python (3.4.3)
py
Runtime Error
18
2940
85
d={c:list(input()) for c in "abc"} s="a" while d[s]: s=d[s].pop(0) print(s.upper())
s563909811
p04012
u089032001
1546369176
Python
Python (3.4.3)
py
Runtime Error
18
2940
137
from collection import Counter S = Counter(list(input())) for k, v in S.items(): if v % 2 == 1: print("No") exit() print("Yes")
s815643729
p04012
u762420987
1545619198
Python
Python (3.4.3)
py
Runtime Error
18
3060
480
//https://atcoder.jp/contests/abc044/tasks/abc044_b //044-BをC++でといてみる #include<iostream> #include<algorithm> #include<string> #include<map> using namespace std; int main(void){ string w; cin >> w; map<char,int> mp; int i; for (i = 0; i < w.size(); i++){ mp[w[i]] += 1; } for (pair<char,int> x :mp){ if (x.second%2 != 0){ cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }
s665057068
p04012
u782098901
1545496668
Python
Python (3.4.3)
py
Runtime Error
17
2940
369
#include <iostream> #include <map> #include <string> using namespace std; int main() { string w; cin >> w; map<char, int> count; for (auto s : w) { count[s] += 1; } for (auto itr = count.begin(); itr != count.end(); itr++) { if (itr->second % 2 == 1) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }
s649604466
p04012
u284854859
1545419652
Python
Python (3.4.3)
py
Runtime Error
19
3064
685
n,a = map(int,input().split()) x = list(map(int,input().split())) #dp[j][k][s] = (x0...xj からk枚選んでxiの合計をsにするような選び方の総数) dp = [[[0 for s in range(a*n+1) ] for k in range(n+1) ] for j in range(n)] for j in range(n): dp[j][0][0]=1 if x[0]<= a*n: dp[j][1][x[0]] = 1 for j in range(n-1): for k in range(n+1): for s in range(a*n+1): if k>j+2: dp[j+1][k][s]=0 elif s>=x[j+1] and k>= 1: dp[j+1][k][s]=dp[j][k][s] + dp[j][k-1][s-x[j+1]] else: dp[j+1][k][s]=dp[j][k][s] res = 0 for i in range(1,n+1): res += dp[n-1][i][a*i] print(1)
s526178871
p04012
u397531548
1541557884
Python
Python (3.4.3)
py
Runtime Error
17
2940
136
from collections import Counter num=Counter(input()) ans="YES" for X in num.values(): if X%2!=0: ans="NO" print(ans)
s442940448
p04012
u432805419
1541474219
Python
Python (3.4.3)
py
Runtime Error
17
2940
135
a = list(input()) b = list(set(a)) for i in range(b): if a.count(b[i]) % 2 != 0: print("No") break else: print("Yes")
s656426363
p04012
u657913472
1537906390
Python
Python (3.4.3)
py
Runtime Error
17
2940
90
s=input();c=[f=0]*26 for i in s:c[ord(i)-97]+=1 for i in c:f+=i%2 print("YNeos"[(f>0)::2])
s163787253
p04012
u657913472
1537906369
Python
Python (3.4.3)
py
Runtime Error
17
2940
88
s=input();c=[f=0]*26 for i in s:c[ord(i)-97]+=1 for i in c:f+=i%2 print("YNeos"[!!f::2])
s802251633
p04012
u787562674
1536535893
Python
Python (3.4.3)
py
Runtime Error
17
2940
114
w = input()) for s in set(w): if w.count(s) % 2 != 0: print('No') break else: print('Yes')
s824817002
p04012
u409064224
1530229110
Python
Python (3.4.3)
py
Runtime Error
17
3060
328
s = input() #l = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] l = [] roll = ord('z')-ord('a') for i in range(roll): l.append(0) for i in range(len(s)): num = ord(s[i]) l[num-97] += 1 #print(num) for i in range(roll): if l[i]%2 != 0: print("No") break else: print("Yes")
s745936581
p04012
u409064224
1530228978
Python
Python (3.4.3)
py
Runtime Error
17
3064
328
s = input() #l = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] l = [] roll = ord('z')-ord('a') for i in range(roll): l.append(0) for i in range(len(s)): num = ord(s[i]) l[num-97] += 1 #print(num) for i in range(roll): if l[i]%2 != 0: print("No") exit() else: print("Yes")
s678137372
p04012
u894440853
1528375448
Python
Python (3.4.3)
py
Runtime Error
17
2940
80
S = input() print("Yes" if all([S.count(e) % 2 == 0 for e in set(S)] else "No"))
s611582427
p04012
u894440853
1528375139
Python
Python (3.4.3)
py
Runtime Error
18
2940
118
S = input() S_elements = set(s) for e in S_elements: if S.count(e) % 2 != 0: print("No") exit() print("Yes")
s064906723
p04012
u573970531
1524631005
Python
Python (3.4.3)
py
Runtime Error
17
3060
169
in1 = list(input()) in1.sort() i = 1 flg = True while i <= len(in1): if in1[i] != in1[i-1]: flg = False break i+=2 if flg: print("Yes") else: print("No")
s969827905
p04012
u027622859
1522515216
Python
Python (3.4.3)
py
Runtime Error
17
2940
5
hthth
s165707929
p04012
u773981351
1521245115
Python
Python (3.4.3)
py
Runtime Error
17
2940
157
from collections import Counter word = input() c = Counter(word) counts = c.values() if all(map(lambda x: x % 2 == 0, counts)) print('Yes') else print('No')
s518824699
p04012
u419874471
1492287179
Python
Python (3.4.3)
py
Runtime Error
17
2940
148
w = input() m = Map() for t in w: m[t] = m.get(t, 0) + 1 for c, cnt in m: if cnt % 2 == 1: print("No") exit() print("Yes")
s776198063
p04012
u419874471
1491932838
Python
Python (3.4.3)
py
Runtime Error
17
3060
333
#!/usr/bin/env python #coding:utf-8 def input_strs(): return input().split(" ") def input_nums(): return [int(i) for i in input_strs()] w = input() ok = True h = Map() for c in w: p = 0 for k in w: if c == k: p += 1 ok = ok and (p % 2 == 0) if ok: print("Yes") else: print("No")
s398708205
p04012
u419874471
1491932463
Python
Python (3.4.3)
py
Runtime Error
17
3060
315
#!/usr/bin/env python #coding:utf-8 def input_strs(): return input().split(" ") def input_nums(): return [int(i) for i in input_strs()] w = input() ok = True h = Map() for i in w: h[i] = h.get(i, 0) + 1 for key in h: ok = ok and (h[key] % 2 == 0) if ok: print("Yes") else: print("No")
s602689309
p04012
u312012633
1484982105
Python
Python (3.4.3)
py
Runtime Error
26
3316
256
from collections import defaultdict def is_beautiful(s): d = defaultdict(int) for c in input(): d[c] += 1 for v in d.values(): if v % 2: return False return True print("YES" if is_beautiful(input()) else "NO")
s942463303
p04012
u830390742
1481430684
Python
Python (2.7.6)
py
Runtime Error
16
2568
112
from collections import Counter print 'Yes' if all(v % 2 == 0 for v in Counter(raw_input()).values())) else 'No'
s411379669
p04012
u831695469
1478720103
Python
Python (3.4.3)
py
Runtime Error
23
3064
310
w = input() l = list(w) l.sort() ans = "Yes" for i in range(len(l)/2): if l[2*i] != l[2*i+1]: ans = "No" break print(ans)
s835231184
p04012
u831695469
1478720051
Python
Python (3.4.3)
py
Runtime Error
22
3064
308
w = input() l = list(w) l.sort() ans = "Yes" for i in range(len(l)): if l[2*i] != l[2*i+1]: ans = "No" break print(ans)
s747029221
p04012
u133038626
1475362430
Python
Python (3.4.3)
py
Runtime Error
23
3064
102
o = "Yes" for v in collections.Counter(input().strip()).values(): if v % 2 != 0: o = "No" print(o)
s354551257
p04012
u514826602
1473172197
Python
Python (3.4.3)
py
Runtime Error
39
3064
193
w = list(input()) w.sort() isBeautiful = True length = len(w) for i in range(0, length, 2): if w[i] is not w[i + 1]: isBeautiful = False break print('Yes' if isBeautiful else 'No')
s544757469
p04012
u914627967
1473109242
Python
Python (3.4.3)
py
Runtime Error
40
3188
389
a,b,c,d,e,f,g,h,i,j,k=0,1,2,3,4,5,6,7,8,9,10 l,m,n,o,p,q,r,s,t,u,v,w,x,y,z=11,12,13,14,15,16,17,18,19,20,21,22,23,24,25 W=input() W=list(W) L=len(W) lis=[0 for s in range(25)] if L%2!=0: print("No")#奇数個の場合はあり得ない else: for s in range(L): temp=W[s] lis[eval(temp)]+=1 for s in range(26): if lis[s]%2!=0: print("No") break if s==26-1: print("Yes")
s262205650
p04012
u030110634
1472759137
Python
Python (3.4.3)
py
Runtime Error
61
4084
155
import string import sys w = raw_input() for c in string.ascii_lowercase: if w.count(c) % 2 == 1: print("No") sys.exit() print("Yes")
s894699935
p04012
u732844340
1472433260
Python
Python (3.4.3)
py
Runtime Error
41
3064
161
flag = 0 counter = Counter(w) for word, cnt in counter.most_common(): if cnt % 2 != 0: flag = 1 print("NO") if flag == 0: print("YES")
s505928963
p04013
u806976856
1600484271
Python
PyPy3 (7.3.0)
py
Runtime Error
212
135596
449
n,a=map(int,input().split()) x=list(map(int,input().split())) A=max(x) x.insert(0,-1) dp=[[[0]*(n+1) for _ in range(n*A+1)] for i in range(n+1)] dp[1][x[1]][1]=1 dp[1][0][0]=1 for i in range(1,n): q=x[i+1] for s in range(n*A+1): for k in range(i+1): if s+q<=n*A: dp[i+1][s+q][k+1]+=dp[i][s][k] dp[i+1][s][k]+=dp[i][s][k] ans=0 i=1 while i<=n: ans+=dp[n][a*(i)][i] i+=1 print(ans)
s913984672
p04013
u381585104
1600071300
Python
Python (3.8.2)
py
Runtime Error
2208
82816
1098
class Combination: def __init__(self, n, mod): self.n = n self.mod = mod self.fac = [1 for i in range(self.n + 1)] self.finv = [1 for i in range(self.n + 1)] for i in range(2, self.n+1): self.fac[i] = (self.fac[i - 1] * i) % self.mod self.finv[i] = (self.finv[i-1] * pow(i, -1, self.mod)) % self.mod def comb(self, n, m): return self.fac[n] * (self.finv[n-m] * self.finv[m] % self.mod) % self.mod def iparse(): return list(map(int, input().split())) if __name__ == "__main__": n, a = iparse() x = iparse() dp = [[[0 for i in range(sum(x) + 10)] for j in range(n + 10)] \ for k in range(n + 10)] dp[0][0][0] = 1 for i in range(n): for j in range(n + 1): for k in range(sum(x) + 1): if j >= 1 and k - x[i] >= 0: dp[i + 1][j][k] = dp[i][j][k] + dp[i][j - 1][k - x[i]] else: dp[i+1][j][k] = dp[i][j][k] ans = 0 for i in range(n): ans += dp[n][i + 1][(i+1)*a] print(ans)
s848248834
p04013
u350093546
1599327066
Python
PyPy3 (7.3.0)
py
Runtime Error
152
119960
363
n,a=map(int,input().split()) lst=list(map(int,input().split())) z=len(lst) dp=[[[0]*2501 for i in range(51)] for j in range(z+1)] dp[0][0][0]=1 for i in range(z): x=lst[i] for j in range(i+1): for k in range((i+1)*50): dp[i+1][j][k]+=dp[i][j][k] dp[i+1][j+1][k+x]+=dp[i][j][k] ans=0 for i in range(50): ans+=dp[-1][i][i*a] print(ans-1)
s691407182
p04013
u161134623
1599029949
Python
Python (3.8.2)
py
Runtime Error
25
9156
561
def function(b, n): if n < b: return n else: return function(b, n//b) + n % b from math import sqrt def divs(n): d=[] for x in range(1,int(sqrt(n))+1): if n%x==0: d.extend([x,n//x]) d=list(set(d)) d.sort() return d def main(): n = int(input()) s = int(input()) if n < s: return("-1") elif n == s: return(n+1) else: ds = divs(n - s) for x in ds: if s == function(x+1,n): return(x+1) else: return("-1") print(main())
s414464503
p04013
u787059958
1598625113
Python
Python (3.8.2)
py
Runtime Error
1942
71596
574
N, A = map(int, input().split()) X = [0] + list(map(int, input().split())) max_X = max(X) dp = [[[0 for k in range((N + 1) * max_X)] for j in range(N + 1)] for i in range(N + 1)] for i in range(N + 1): dp[i][0][0] = 1 for j in range(1, N + 1): for k in range(1, j + 1): for s in range((N + 1) * max_X): if s < X[j]: dp[j][k][s] = dp[j - 1][k][s] elif s >= X[j]: dp[j][k][s] = dp[j - 1][k - 1][s - X[j]] + dp[j - 1][k][s] ans = 0 for k in range(1, N + 1): ans += dp[N][k][k * A] print(ans)
s684639795
p04013
u787059958
1598624807
Python
Python (3.8.2)
py
Runtime Error
1953
71604
560
N, A = map(int, input().split()) X = [0] + list(map(int, input().split())) dp = [[[0 for k in range((N + 1) * max(X))] for j in range(N + 1)] for i in range(N + 1)] for i in range(N + 1): dp[i][0][0] = 1 for j in range(1, N + 1): for k in range(1, j + 1): for s in range((N + 1) * max(X)): if s < X[j]: dp[j][k][s] = dp[j - 1][k][s] elif s >= X[j]: dp[j][k][s] = dp[j - 1][k - 1][s - X[j]] + dp[j - 1][k][s] ans = 0 for k in range(1, N + 1): ans += dp[N][k][k * A] print(ans)
s547682933
p04013
u191874006
1598024434
Python
PyPy3 (7.3.0)
py
Runtime Error
102
79760
950
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collections import deque from operator import itemgetter from itertools import permutations mod = 10**9 + 7 inf = float('inf') def I(): return int(sys.stdin.readline()) def LI(): return list(map(int,sys.stdin.readline().split())) n, a = LI() x = LI() dp = [[[0] * (250+1) for _ in range(n+1)] for _ in range(n+1)] dp[0][0][0] = 1 for i in range(n+1): xi = x[i-1] for j in range(250+1): for k in range(i): dp[i][k][j] = dp[i-1][k][j] for j in range(xi, 250+1): for k in range(1, i+1): dp[i][k][j] += dp[i-1][k-1][j-xi] ans = 0 for i in range(1, n+1): ans += dp[-1][i][i*a] print(ans)
s104264882
p04013
u489959379
1597463106
Python
PyPy3 (7.3.0)
py
Runtime Error
188
118220
666
import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): n, a = map(int, input().split()) X = list(map(int, input().split())) MAX = sum(X) + 1 dp = [[[0] * MAX for _ in range(n + 1)] for _ in range(n + 1)] dp[0][0][0] = 1 for i in range(1, n + 1): x = X[i - 1] for j in range(n): for k in range(MAX): dp[i][j][k] += dp[i - 1][j][k] if k + x < MAX: dp[i][j + 1][k + x] += dp[i - 1][j][k] res = 0 for j in range(1, n + 1): res += dp[-1][j][a * j] print(res) if __name__ == '__main__': resolve()
s385643419
p04013
u188745744
1596085813
Python
Python (3.8.2)
py
Runtime Error
2207
60904
504
N,A= list(map(int,input().split())) l=list(map(int,input().split())) max_l=max(l) DP=[[[0]*(max_l*N+1) for _ in range(N+1)] for j in range(N+1)] DP[0][0][0]=1 for i in range(0,N+1):#カード全体の枚数 for j in range(0,N+1): for k in range(0,N*max_l+1): if i >= 1 and k<l[i-1]: DP[i][j][k]=DP[i-1][j][k] elif j >= 1 and i>=1 and k>=l[i-1]: DP[i][j][k]=DP[i-1][j][k]+DP[i-1][j-1][k-l[i-1]] ans=0 for j in range(1,i): ans+=DP[N][j][j*A] print(ans)
s555936601
p04013
u311379832
1595994453
Python
Python (3.8.2)
py
Runtime Error
1023
71404
477
N, A = map(int, input().split()) x = 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(N): for j in range(N + 1): for k in range(N * A + 1): if dp[i][j][k] == 0: continue dp[i + 1][j][k] += dp[i][j][k] dp[i + 1][j + 1][k + x[i]] += dp[i][j][k] ans = 0 for i in range(1, N + 1): ans += dp[N][i][A * i] print(ans)
s236517936
p04013
u551857719
1595868597
Python
Python (3.8.2)
py
Runtime Error
25
9376
1687
#!/usr/bin/python # -*- coding: UTF-8 -*- from collections import defaultdict from operator import mul from functools import reduce def combinations_count(n, r): r = min(r, n - r) numer = reduce(mul, range(n, n - r, -1), 1) denom = reduce(mul, range(1, r + 1), 1) return numer // denom def subset_sum(numbers, target, partial=[], partial_sum=0): if partial_sum == target: yield partial if partial_sum >= target: return for i, n in enumerate(numbers): remaining = numbers[i + 1:] yield from subset_sum(remaining, target, partial + [n], partial_sum + n) def _main(): N, A = get_ints() xn = get_array() xn.sort() xna = [i - A for i in xn] xnn = [i for i in xna if i < 0] xnp = [i for i in xna if i > 0] xn0 = [i for i in xna if i == 0] xn0_p = 0 for i in range(len(xn0)): xn0_p += combinations_count(len(xn0), i) n = defaultdict(list) p = defaultdict(list) xnn = list(map(abs, xnn)) for j in range(1, sum(xnn) + 1): gen = subset_sum(xnn, j) try: while 1: nl = gen.__next__() n[j].append(nl) except StopIteration: pass for k in n.keys(): gen = subset_sum(xnp, k) try: while 1: pl = gen.__next__() p[k].append(pl) except StopIteration: pass ss = set(n.keys()) & set(p.keys()) xn_p = 0 for s in ss: xn_p += len(n[s]) * len(p[s]) if xnn and xnp: print(f"{(xn0_p+1) * (xn_p+1) - 1=}") else: print(f"{xn0_p=}") if __name__ == "__main__": _main()
s510981029
p04013
u758815106
1595718126
Python
Python (3.8.2)
py
Runtime Error
1760
69196
515
N, A = map(int, input().split()) x = list(map(int, input().split())) maxint = 50 * max(x) dp = [[[0] * (maxint + 1) for _ in range(N + 1)] for _ in range(N + 1)] dp[0][0][0] = 1 for xi, xe in enumerate(x, 1): for j in range(xi+1): for k in range(maxint + 1): dp[xi][j][k] = dp[xi - 1][j][k] if j >= 0 and k >= xe: dp[xi][j][k] += dp[xi - 1][j - 1][k - xe] res = 0 for i in range(1, N+1): res += dp[N][i][i * A] print(res)
s805199471
p04013
u968166680
1595070787
Python
PyPy3 (7.3.0)
py
Runtime Error
89
75160
591
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N, A, *X = map(int, read().split()) M = sum(X) dp = [[0] * (M + 1) for j in range(N + 1)] dp[0][0] = 1 for i in range(N): for j in range(N, 0, -1): for k in range(X[i], M + 1): dp[j][k] += dp[j - 1][k - X[i]] ans = 0 for j in range(1, min(50, M // A) + 1): ans += dp[j][A * j] print(ans) return if __name__ == '__main__': main()
s503799018
p04013
u968166680
1595070690
Python
PyPy3 (7.3.0)
py
Runtime Error
377
80420
582
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N, A, *X = map(int, read().split()) M = sum(X) dp = [[0] * (M + 1) for j in range(N + 1)] dp[0][0] = 1 for i in range(N): for j in range(N, 0, -1): for k in range(X[i], M + 1): dp[j][k] += dp[j - 1][k - X[i]] ans = 0 for j in range(1, M // A + 1): ans += dp[j][A * j] print(ans) return if __name__ == '__main__': main()
s092859440
p04013
u968166680
1595070346
Python
PyPy3 (7.3.0)
py
Runtime Error
373
75540
582
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N, A, *X = map(int, read().split()) M = sum(X) dp = [[0] * (M + 1) for j in range(N + 1)] dp[0][0] = 1 for i in range(N): for j in range(N, 0, -1): for k in range(X[i], M + 1): dp[j][k] += dp[j - 1][k - X[i]] ans = 0 for j in range(1, M // A + 1): ans += dp[j][A * j] print(ans) return if __name__ == '__main__': main()
s039290245
p04013
u968166680
1595070158
Python
PyPy3 (7.3.0)
py
Runtime Error
93
75352
577
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N, A, *X = map(int, read().split()) M = sum(X) dp = [[0] * (M + 1) for j in range(N + 1)] dp[0][0] = 1 for i in range(N): for j in range(N, 0, -1): for k in range(X[i], M + 1): dp[j][k] += dp[j - 1][k - X[i]] ans = 0 for j in range(1, N + 1): ans += dp[j][A * j] print(ans) return if __name__ == '__main__': main()
s204940097
p04013
u786020649
1594355047
Python
Python (3.8.2)
py
Runtime Error
2205
9312
958
from collections import deque n,a=map(int,input().split()) cards=list(map(int,input().split())) noz=[x-a for x in cards].count(0) pl=[x-a for x in cards if x-a>0] nl=[a-x for x in cards if x-a<0] sl=[pl,nl][len(nl)<=len(pl)] ll=[pl,nl][len(pl)<len(nl)] sl.sort() ll.sort() sumfunc = lambda n, l: sum([l[x]*((n>>x)&1) for x in range(len(l))]) ssl=sum(sl) sll=sum(ll) sumsl=[0 for _ in range(ssl)] sumll=[0 for _ in range(sll)] sumsl[sl[-1]-1]=1 sumll[ll[-1]-1]=1 for i in range(1,2**(len(sl)-1)): s=sumfunc(i,sl) sumsl[s-1]+=1 sumsl[s+sl[-1]-1]+=1 for i in range(1,2**(len(ll)-1)): s=sumfunc(i,ll) sumll[s-1]+=1 sumll[s+ll[-1]-1]+=1 count=sum([x*y for x,y in zip(sumsl, sumll)]) # count=0 # p=sum([not sumsl[-1]<sumfunc(2**i,ll) for i in range(1,len(ll)+1)]) # q=sum([sumsl[0]>=sumfunc(2**i-1,ll) for i in range(1,len(ll)+1)]) # count=[sumfunc(j,ll) in sumsl for j in range(2**q-1,2**p)].count(True) print((count+1)*(2**noz)-1)
s542843230
p04013
u786020649
1594349814
Python
Python (3.8.2)
py
Runtime Error
2206
24484
758
from collections import deque n,a=map(int,input().split()) cards=list(map(int,input().split())) noz=[x-a for x in cards].count(0) pl=[x-a for x in cards if x-a>0] nl=[a-x for x in cards if x-a<0] sl=[pl,nl][len(nl)<=len(pl)] ll=[pl,nl][len(pl)<len(nl)] sl.sort() ll.sort() sumfunc = lambda n, l: sum([l[x]*((n>>x)&1) for x in range(len(l))]) sumsl=[sumfunc(i,sl) for i in range(1,2**len(sl))] sumll=[sumfunc(i,ll) for i in range(1,2**len(ll))] # count=0 # p=sum([not sumsl[-1]<sumfunc(2**i,ll) for i in range(1,len(ll)+1)]) # q=sum([sumsl[0]>=sumfunc(2**i-1,ll) for i in range(1,len(ll)+1)]) # count=[sumfunc(j,ll) in sumsl for j in range(2**q-1,2**p)].count(True) count=0 count=sum([x==y for x in sumsl for y in sumlll]) print((count+1)*(2**noz)-1)
s586679958
p04013
u786020649
1594344638
Python
Python (3.8.2)
py
Runtime Error
2206
18568
643
from collections import deque n,a=map(int,input().split()) cards=list(map(int,input().split())) noz=[x-a for x in cards].count(0) pl=[x-a for x in cards if x-a>0] nl=[a-x for x in cards if x-a<0] sl=[pl,nl][len(nl)<=len(pl)] ll=[pl,nl][len(pl)<len(nl)] sl.sort() ll.sort() sumfunc = lambda n, l: sum([l[x]*((n>>x)&1) for x in range(len(l))]) sumsl=[sumfunc(i,sl) for i in range(1,2**len(sl))] count=0 p=sum([not sumsl[-1]<sumfunc(2**i,ll) for i in range(1,len(ll)+1)]) q=sum([sumsl[0]>=sumfunc(2**i-1,ll) for i in range(1,len(ll)+1)]) count=[sumfunc(j,ll) in sumsl for j in range(2**q-1,2**p)].count(True) print((count+1)*(2**noz)-1)
s102200702
p04013
u786020649
1594341091
Python
Python (3.8.2)
py
Runtime Error
2206
18416
645
from collections import deque n,a=map(int,input().split()) cards=list(map(int,input().split())) noz=[x-a for x in cards].count(0) pl=[x-a for x in cards if x-a>0] nl=[a-x for x in cards if x-a<0] sl=[pl,nl][len(nl)<=len(pl)] ll=[pl,nl][len(pl)<len(nl)] sl.sort() ll.sort() nsl=len(sl) nll=len(ll) sumsl=[sum([sl[x]*((i>>x)&1) for x in range(nsl)]) for i in range(1,2**nsl)] # print(sl,ll,sumsl) count=0 for i in range(1,nll+1): if sumsl[-1]< sum([ll[x]*(((2**i)>>x)&1) for x in range(nll)]): continue count=[sum([ll[x]*((j>>x)&1) for x in range(nll)]) in sumsl for j in range(1,2**i)].count(True) print((count+1)*(2**noz)-1)
s599348131
p04013
u786020649
1594340323
Python
Python (3.8.2)
py
Runtime Error
2206
18588
647
from collections import deque n,a=map(int,input().split()) cards=list(map(int,input().split())) noz=[x-a for x in cards].count(0) pl=[x-a for x in cards if x-a>0] nl=[a-x for x in cards if x-a<0] sl=[pl,nl][len(nl)<=len(pl)] ll=[pl,nl][len(pl)<len(nl)] sl.sort() ll.sort() nsl=len(sl) nll=len(ll) sumsl=[sum([sl[x]*((i>>x)&1) for x in range(nsl)]) for i in range(1,2**nsl)] # print(sl,ll,sumsl) count=0 for i in range(1,nll+1): if sumsl[-1]< sum([ll[x]*(((2**i)>>x)&1) for x in range(nll)]): continue for j in range(1,2**i): s=sum([ll[x]*((j>>x)&1) for x in range(nll)]) count+=(s in sumsl) print((count+1)*(2**noz)-1)
s067379302
p04013
u786020649
1594338534
Python
Python (3.8.2)
py
Runtime Error
2206
18600
691
from collections import deque n,a=map(int,input().split()) cards=list(map(int,input().split())) def is2power(n): if n==1: return True if n%1==1: return False else: is2power(n//2) noz=[x-a for x in cards].count(0) pl=[x-a for x in cards if x-a>0] nl=[a-x for x in cards if x-a<0] sl=[pl,nl][len(nl)<=len(pl)] ll=[pl,nl][len(pl)<len(nl)] sl.sort() ll.sort() nsl=len(sl) nll=len(ll) sumsl=[sum([sl[x]*((i>>x)&1) for x in range(nsl)]) for i in range(1,2**nsl)] count=0 for i in range(1,2**nll): s=sum([ll[x]*((i>>x)&1) for x in range(nll)]) if is2power(i) and s>sumsl[-1]: continue count+=(s in sumsl) print((count+1)*(2**noz)-1)
s633721625
p04013
u786020649
1594338183
Python
Python (3.8.2)
py
Runtime Error
2206
18260
711
from collections import deque n,a=map(int,input().split()) cards=list(map(int,input().split())) def is2power(n): if n==1: return True if n%1==1: return False else: is2power(n//2) noz=[x-a for x in cards].count(0) pl=[x-a for x in cards if x-a>0] nl=[a-x for x in cards if x-a<0] sl=[pl,nl][len(nl)<=len(pl)] ll=[pl,nl][len(pl)<len(nl)] sl.sort() ll.sort() nsl=len(sl) nll=len(ll) sumsl=[] for i in range(1,2**nsl): sumsl.append(sum([sl[x]*((i>>x)&1) for x in range(nsl)])) count=0 for i in range(1,2**nll): s=sum([ll[x]*((i>>x)&1) for x in range(nll)]) if is2power(i) and s>sumsl[-1]: continue count+=(s in sumsl) print((count+1)*(2**noz)-1)
s626843540
p04013
u391589398
1594261191
Python
Python (3.8.2)
py
Runtime Error
981
69196
668
n, a = map(int, input().split()) X = tuple(map(int, input().split())) dp = [[[0] * (n*max(X)+1) for _ in range(n+1)] for _ in range(n+1)] dp[0][0][0] = 1 for i in range(n): # i枚目までで for j in range(n): # j枚のカードを選んで for s in range(n*max(X)+1): # 合計がsになるパターン if dp[i][j][s] == 0: continue # i枚目のカードが選ばれない場合 dp[i+1][j][s] += dp[i][j][s] # i枚目のカードが選ばれる場合 dp[i+1][j+1][s+X[i]] += dp[i][j][s] ans = 0 for k in range(1, n+1): ans += dp[n][k][k*a] print(ans)
s093729951
p04013
u793430793
1593294870
Python
Python (3.8.2)
py
Runtime Error
2208
62408
457
#ABC044C #重要 N,A=map(int,input().split()) a=list(map(int,input().split())) dp=[] dp=[[[0 for k in range(N*A)] for j in range(A+1)]for i in range(N+1)] dp[0][0][0]=1 for i in range(len(a)): for j in range(len(a)): for k in range(N*A): if k>=a[i]: dp[i+1][j+1][k]+=dp[i][j][k-a[i]] else: dp[i+1][j][k]+=dp[i][j][k] ans=0 for i in range(N+1): ans += dp[N][j][j*A] print(ans)
s476986325
p04013
u793430793
1593294606
Python
Python (3.8.2)
py
Runtime Error
1717
306476
518
#ABC044C #重要 N,A=map(int,input().split()) a=list(map(int,input().split())) dp=[] dp=[[[0 for i in range(111)] for j in range(111)]for k in range(N*A)] dp[0][0][0]=1 for i in range(N): for j in range(len(a)): for k in range(N*A): if k>=a[i]: #i+1番目の数字a[i]を足せるかも dp[i+1][j+1][k]+=dp[i][j][k-a[i]] else: #入る可能性はない dp[i+1][j][k]+=dp[i][j][k] ans=0 for i in range(N+1): ans += dp[N][j][j*A] print(ans)
s078700779
p04013
u249372595
1592774868
Python
Python (3.8.2)
py
Runtime Error
430
89616
482
N,A=list(map(int,input().split())) x = list(map(int,input().split())) dp=[[[0 for _ in range(55)] for _ in range(55)] for _ in range(2555)] dp[0][0][0]=1 for j in range(N):#x1~xjのカードから for k in range(N):#k枚選び for s in range(A*N):#xの合計をsになるようにしたい if dp[j][k][s] == 0: continue dp[j+1][k][s] += dp[j][k][s] dp[j+1][k+1][s+x[j]] += dp[j][k][s] ans=0 for k in range(1,N+1): ans+=dp[N][k][k*A] print(ans)
s158909362
p04013
u249372595
1592774583
Python
Python (3.8.2)
py
Runtime Error
432
89668
460
N,A=list(map(int,input().split())) x = list(map(int,input().split())) dp=[[[0 for _ in range(55)] for _ in range(55)] for _ in range(2555)] dp[0][0][0]=1 for j in range(N):#x1~xjのカードから for k in range(N):#k枚選び for s in range(A*N):#xの合計をsになるようにしたい dp[j+1][k][s] += dp[j][k][s] if s >= x[j]: dp[j+1][k+1][s] += dp[j][k][s-x[j]] ans=0 for k in range(1,N+1): ans+=dp[N][k][k*A] print(ans)
s060642815
p04013
u102367647
1592400422
Python
Python (3.4.3)
py
Runtime Error
307
22428
1645
import sys import numpy as np import random from decimal import Decimal import itertools import re import bisect from collections import deque, Counter from functools import lru_cache sys.setrecursionlimit(10**9) INF = 10**13 def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def I(): return int(sys.stdin.buffer.readline()) def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split() def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8') def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def LSR(n): return [LS() for i in range(n)] def SRL(n): return [list(S()) for i in range(n)] def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)] def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ') def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w] def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w] MOD = 1000000007 def main(): n, a = LI() x_list = np.array(LI()) nx = n*max(x_list+[a]) y_list = x_list - a dp = np.full((n+1,2*nx+1),None) def dfs(j,t): dp_value = dp[j,t] if dp_value == None: if j == 0 and t == nx: dp_value = 1 elif j >= 1 and (y_list[j-1] < t - 2*nx or y_list[j-1] > t): dp_value = dfs(j-1, t) elif j >= 1 and 0 <= t - y_list[j-1] <= 2*nx: dp_value = dfs(j-1, t) + dfs(j-1, t-y_list[j-1]) else: dp_value = 0 dp[j,t] = dp_value return int(dp_value) print(dfs(n, nx) -1) if __name__ == '__main__': main()
s920431845
p04013
u811436126
1591419884
Python
Python (3.4.3)
py
Runtime Error
2062
69524
385
n, a = map(int, input().split()) x = list(map(int, input().split())) dp = [[[0] * 3000 for _ in range(50)] for _ in range(50)] dp[0][0][0] = 1 for i in range(n): for j in range(n): for k in range(n * a): dp[i + 1][j][k] += dp[i][j][k] dp[i + 1][j + 1][k + x[i]] += dp[i][j][k] ans = 0 for i in range(1, n): ans += dp[n][i][a * i] print(ans)
s565876696
p04013
u987170100
1591408279
Python
Python (3.4.3)
py
Runtime Error
19
3064
273
N, A = map(int, input().split()) lst = [int(x) - A for x in input().split()] dp = [[0] * (2 * N + 1) for _ in range(N + 1)] dp[0][1 * N] = 1 for i in range(N): for j in range(1, 2 * N + 1 - 1): dp[i + 1][j] = dp[i][j] + dp[i][j - lst[i]] print(dp[N][1 * N] - 1)
s456838979
p04013
u987170100
1591408255
Python
Python (3.4.3)
py
Runtime Error
21
3064
284
N, A = map(int, input().split()) lst = [int(x) - A for x in input().split()] dp = [[0] * (2 * N + 1) for _ in range(N + 1)] dp[0][1 * N] = 1 for i in range(N): for j in range(1, 2 * N + 1 - 1): dp[i + 1][j] = dp[i][j] + dp[i][j - lst[i]] print(dp[N][1 * N] - 1) print(dp)
s967561733
p04013
u086503932
1591059296
Python
Python (3.4.3)
py
Runtime Error
2107
57460
656
#!/usr/bin/env python3 def main(): N, A = map(int, input().split()) x = list(map(int, input().split())) X = max(x) dp = [[[0]*(N*X +1) 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*X+1): if s >= x[j-1] and k >= 1: dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j-1]] else:# x[j]を選ぶと合計sにできない dp[j][k][s] = dp[j-1][k][s] ans = 0 for i in range(N): ans += dp[N][i+1][(i+1)*A] print(ans) if __name__ == "__main__": main()
s394042000
p04013
u225388820
1590477166
Python
PyPy3 (2.4.0)
py
Runtime Error
402
93404
508
n,a=map(int,input().split()) x=list(map(int,input().split())) # dp[j][k][s]=(x1,...,xjからk枚選んでx[i]の合計をsにするような選び方の総数) dp=[[[0]*2500 for i in range(51)] for j in range(51)] dp[0][0][0]=1 for i in range(n): for j in range(n+1): for k in range(2500): if k<x[i]: dp[i+1][j][k]=dp[i][j][k] else: dp[i+1][j][k]=dp[i][j][k]+dp[i][j-1][k-x[i]] ans=0 for i in range(1,n+1): ans+=dp[n][i][i*a] print(ans)
s492688158
p04013
u054556734
1589946327
Python
Python (3.4.3)
py
Runtime Error
279
20496
964
import numpy as np import scipy.sparse as sps import scipy.misc as spm import collections as col import functools as func import itertools as ite import fractions as frac import math as ma import copy as cp import sys def sinput(): return sys.stdin.readline() def iinput(): return int(sinput()) def imap(): return map(int, sinput().split()) def fmap(): return map(float, sinput().split()) def iarr(): return list(imap()) def farr(): return list(fmap()) def sarr(): return sinput().split() n,a = imap() x = np.array(iarr()) - a # dp[i][和 + NA] # 本来のSの範囲は、1N-NAから50N-NA # 負の数はdp範囲外なのでNAたすと、1Nから50N # 和0のときは dp[n][0+NA] dp = np.zeros((n+1, 50*n+1)).astype(int) dp[0][n*a] = 1 for i in range(n): for s in range(50*n+1): dp[i+1][s] = dp[i][s] + dp[i][s-x[i]] if 50*N>= s-x[i] >=0 else dp[i][s] ans = dp[n][n*a] - 1 #実際は初期条件の0個選ぶパターンを除外 print(ans)
s322854469
p04013
u054556734
1589916808
Python
Python (3.4.3)
py
Runtime Error
753
15988
1003
import numpy as np import scipy.sparse as sps import scipy.misc as spm import collections as col import functools as func import itertools as ite import fractions as frac import math as ma import copy as cp import sys def sinput(): return sys.stdin.readline() def iinput(): return int(sinput()) def imap(): return map(int, sinput().split()) def fmap(): return map(float, sinput().split()) def iarr(): return list(imap()) def farr(): return list(fmap()) def sarr(): return sinput().split() n,a = imap() x = np.array(iarr()) - a # dp[i][和 + NA] # 本来のSの範囲は、1N-NAから50N-NA # 負の数はdp範囲外なのでNAたすと、1Nから50N # 和0のときは dp[n][0+NA] dp = np.zeros((n+1, 50*n+3)).astype(int) #50*n+1だめ、なんで!?????? dp[0][n*a] = 1 for i in range(n): for s in range(50*n+1): dp[i+1][s] = dp[i][s] + dp[i][s-x[i]] if s-x[i]>=0 else dp[i][s] ans = dp[n][n*a] - 1 #実際は初期条件の0個選ぶパターンを除外 print(ans)
s298347476
p04013
u054556734
1589914801
Python
Python (3.4.3)
py
Runtime Error
743
15988
961
import numpy as np import scipy.sparse as sps import scipy.misc as spm import collections as col import functools as func import itertools as ite import fractions as frac import math as ma import copy as cp import sys def sinput(): return sys.stdin.readline() def iinput(): return int(sinput()) def imap(): return map(int, sinput().split()) def fmap(): return map(float, sinput().split()) def iarr(): return list(imap()) def farr(): return list(fmap()) def sarr(): return sinput().split() n,a = imap() x = np.array(iarr()) - a # dp[i][和 + NA] # 本来のSの範囲は、n*(1-a)からn*(50-a) # 負の数はdp半以外なのでNAたすと、1*nから50*N # 和0のときは dp[n][0+NA] dp = np.zeros((n+1, 50*n+1)).astype(int) dp[0][n*a] = 1 for i in range(n): for s in range(50*n+1): dp[i+1][s] = dp[i][s] + dp[i][s-x[i]] if s-x[i]>=0 else dp[i][s] ans = dp[n][n*a] - 1 #実際は初期条件の0個選ぶパターンを除外 print(ans)
s217342301
p04013
u054556734
1589914768
Python
Python (3.4.3)
py
Runtime Error
739
20668
962
import numpy as np import scipy.sparse as sps import scipy.misc as spm import collections as col import functools as func import itertools as ite import fractions as frac import math as ma import copy as cp import sys def sinput(): return sys.stdin.readline() def iinput(): return int(sinput()) def imap(): return map(int, sinput().split()) def fmap(): return map(float, sinput().split()) def iarr(): return list(imap()) def farr(): return list(fmap()) def sarr(): return sinput().split() n,a = imap() x = np.array(iarr()) - a # dp[i][和 + NA] # 本来のSの範囲は、n*(1-a)からn*(50-a) # 負の数はdp半以外なのでNAたすと、1*nから50*N # 和0のときは dp[n][0+NA] dp = np.zeros((n+1, 50*n+1)).astype(int) dp[0][n*a] = 1 for i in range(n): for s in range(2*n*a+1): dp[i+1][s] = dp[i][s] + dp[i][s-x[i]] if s-x[i]>=0 else dp[i][s] ans = dp[n][n*a] - 1 #実際は初期条件の0個選ぶパターンを除外 print(ans)
s819566144
p04013
u054556734
1589914736
Python
Python (3.4.3)
py
Runtime Error
935
19256
981
import numpy as np import scipy.sparse as sps import scipy.misc as spm import collections as col import functools as func import itertools as ite import fractions as frac import math as ma import copy as cp import sys def sinput(): return sys.stdin.readline() def iinput(): return int(sinput()) def imap(): return map(int, sinput().split()) def fmap(): return map(float, sinput().split()) def iarr(): return list(imap()) def farr(): return list(fmap()) def sarr(): return sinput().split() n,a = imap() x = np.array(iarr()) - a # dp[i][和 + NA] # 本来のSの範囲は、n*(1-a)からn*(50-a) # 負の数はdp半以外なのでNAたすと、1*nから50*N # 和0のときは dp[n][0+NA] dp = np.zeros((n+1, 50*n+1)).astype(int) dp[0][n*a] = 1 for i in range(n): for s in range(2*n*a+1): print(i,s) dp[i+1][s] = dp[i][s] + dp[i][s-x[i]] if s-x[i]>=0 else dp[i][s] ans = dp[n][n*a] - 1 #実際は初期条件の0個選ぶパターンを除外 print(ans)
s408105487
p04013
u054556734
1589914692
Python
Python (3.4.3)
py
Runtime Error
941
18456
1005
import numpy as np import scipy.sparse as sps import scipy.misc as spm import collections as col import functools as func import itertools as ite import fractions as frac import math as ma import copy as cp import sys def sinput(): return sys.stdin.readline() def iinput(): return int(sinput()) def imap(): return map(int, sinput().split()) def fmap(): return map(float, sinput().split()) def iarr(): return list(imap()) def farr(): return list(fmap()) def sarr(): return sinput().split() n,a = imap() x = np.array(iarr()) - a xsum = sum(x) # dp[i][和 + NA] # 本来のSの範囲は、n*(1-a)からn*(50-a) # 負の数はdp半以外なのでNAたすと、1*nから50*N # 和0のときは dp[n][0+NA] dp = np.zeros((n+1, 50*n+1)).astype(int) dp[0][n*a] = 1 for i in range(n): for s in range(2*n*a+1): print(i,s) dp[i+1][s] = dp[i][s] + dp[i][s-x[i]] if s-x[i]>=0 else dp[i][s] print(dp) ans = dp[n][n*a] - 1 #実際は初期条件の0個選ぶパターンを除外 print(ans)
s937711662
p04013
u054556734
1589891447
Python
Python (3.4.3)
py
Runtime Error
307
19400
821
import numpy as np import scipy.sparse as sps import scipy.misc as spm import collections as col import functools as func import itertools as ite import fractions as frac import math as ma import copy as cp import sys def sinput(): return sys.stdin.readline() def iinput(): return int(sinput()) def imap(): return map(int, sinput().split()) def fmap(): return map(float, sinput().split()) def iarr(): return list(imap()) def farr(): return list(fmap()) def sarr(): return sinput().split() n,a = imap() x = np.array(iarr()) - a # 和は -49*nから49*nまでで、49たせば0 - 98の99個 # 和0のときは49*nたして、dp[n][0+50*n]が答え dp = np.zeros((n+1, 100)) dp[0, :] = 1 for i in range(n): for s in range(100): dp[i+1][s] = dp[i][s] + dp[i][s-x[i]] if s-x[i]>=0 else dp[i][s] print(dp)
s843456675
p04013
u835534360
1589746941
Python
Python (3.4.3)
py
Runtime Error
2109
63560
440
import numpy as np n,avea=tuple(map(lambda x:int(x),input().split())) x=np.array(list(map(lambda x:int(x),input().split()))) dp=np.zeros((n+1,n+1,max(x)*n+1), dtype=int) dp[:,0,0]=1 c=0 for i in range(n): for j in range(i): for k in range(max(x)*(i+1)): if k-x[i]>=0: dp[i+1,j,k]=dp[i,j,k]+dp[i,j-1,k-x[i]] else: dp[i+1,j,k]=dp[i,j,k] c+=dp[i+1,j,j*avea] print(c)
s320316782
p04013
u867848444
1589686695
Python
PyPy3 (2.4.0)
py
Runtime Error
319
101980
803
n, a = map(int,input().split()) x = list(map(int,input().split())) dp = [[[0] * n for i in range(n * a + 1)] for i in range(n)] for i in range(n): for j in range(n * a + 1): for k in range(n): if i == 0 and x[0] < n * a + 1: dp[0][x[0]][0] = 1 break else: if j == 0: if k == 0: dp[i][x[i]][0] += 1 continue if dp[i - 1][j][k] == 0:continue dp[i][j][k] += dp[i - 1][j][k] if not(0 <= j + x[i] < n * a + 1):continue dp[i][j + x[i]][k + 1] += dp[i - 1][j][k] cnt = 0 for i in range(n * a + 1): if i != 0 and i % a == 0: temp = i // a cnt += dp[-1][i][temp - 1] print(cnt)
s519067629
p04013
u867848444
1589686628
Python
PyPy3 (2.4.0)
py
Runtime Error
311
101852
782
n, a = map(int,input().split()) x = list(map(int,input().split())) dp = [[[0] * n for i in range(n * a + 1)] for i in range(n)] for i in range(n): for j in range(n * a + 1): for k in range(n): if i == 0: dp[0][x[0]][0] = 1 break else: if j == 0: if k == 0: dp[i][x[i]][0] += 1 continue if dp[i - 1][j][k] == 0:continue dp[i][j][k] += dp[i - 1][j][k] if not(0 <= j + x[i] < n * a + 1):continue dp[i][j + x[i]][k + 1] += dp[i - 1][j][k] cnt = 0 for i in range(n * a + 1): if i != 0 and i % a == 0: temp = i // a cnt += dp[-1][i][temp - 1] print(cnt)
s676228810
p04013
u867848444
1589685250
Python
PyPy3 (2.4.0)
py
Runtime Error
892
124252
800
n, a = map(int,input().split()) x = list(map(int,input().split())) dp = [[[0] * n for i in range(n * a + 1)] for i in range(n)] #print(*dp, sep='\n') for i in range(n): for j in range(n * a + 1): for k in range(n): if i == 0: dp[0][x[0]][0] = 1 else: if j == 0 and k == 0: dp[i][x[i]][0] += 1 continue if dp[i - 1][j][k] == 0:continue dp[i][j][k] += dp[i - 1][j][k] if not(0 <= j + x[i] < n * a + 1):continue for l in range(n - 1): dp[i][j + x[i]][l + 1] += dp[i - 1][j][l] cnt = 0 for i in range(n * a + 1): if i != 0 and i % a == 0: temp = i // a cnt += dp[-1][i][temp - 1] print(cnt)
s952465052
p04013
u480300350
1589659906
Python
PyPy3 (2.4.0)
py
Runtime Error
2112
138556
4716
#!/usr/bin/env python3 import sys # import math # from string import ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits # import re # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s) # from operator import itemgetter # itemgetter(1), itemgetter('key') # from collections import deque # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate() # from collections import defaultdict # subclass of dict. defaultdict(facroty) # from collections import Counter # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter) # from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn). # from heapq import nlargest, nsmallest # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn). # from itertools import count, cycle, repeat # count(start[,step]), cycle(iter), repeat(elm[,n]) # from itertools import groupby # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])] # from itertools import starmap # starmap(pow, [[2,5], [3,2]]) returns [32, 9] from itertools import product, permutations # product(iter, repeat=n), permutations(iter[,r]) # from itertools import combinations, combinations_with_replacement # from itertools import accumulate # accumulate(iter[, f]) # from functools import reduce # reduce(f, iter[, init]) # from functools import lru_cache # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed) from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]). # from copy import deepcopy # to copy multi-dimentional matrix without reference # from fractions import gcd # for Python 3.4 (previous contest @AtCoder) def main(): mod = 1000000007 # 10^9+7 inf = float('inf') # sys.float_info.max = 1.79...e+308 # inf = 2 ** 64 - 1 # (for fast JIT compile in PyPy) 1.84...e+19 sys.setrecursionlimit(10**6) # 1000 -> 1000000 def input(): return sys.stdin.readline().rstrip() def ii(): return int(input()) def mi(): return map(int, input().split()) def mi_0(): return map(lambda x: int(x)-1, input().split()) def lmi(): return list(map(int, input().split())) def lmi_0(): return list(map(lambda x: int(x)-1, input().split())) def li(): return list(input()) def calc_pattern(seq, num): ''' seq の要素を取り出して和を num にする場合の数 ''' cnt = 0 n = len(seq) mid = n // 2 left = seq[:mid] left_all = [] for p in product([True, False], repeat=mid): left_all.append(sum([left[i] for i in range(mid) if p[i]])) right = seq[mid:] right_all = [] for p in product([True, False], repeat=n-mid): right_all.append(sum([right[i] for i in range(n-mid) if p[i]])) right_all.sort() for i in left_all: if i <= num: cnt += bisect_right(right_all, num-i) - bisect_left(right_all, num-i) # debug # if num == 1: # print(f"{seq} {left} {right} {left_all} {right_all}") return cnt n, a = mi() L = lmi() diff = [elm - a for elm in L] diff_neg = list(map(lambda x: - x, filter(lambda x: x < 0, diff))) diff_zero = list(filter(lambda x: x == 0, diff)) diff_pos = list(filter(lambda x: x > 0, diff)) ans = 0 # pos, neg から 1 つも選ばない ans += pow(2, len(diff_zero)) - 1 # diff_zero の全てを選ばないのは許されぬ # pos, neg から 選ぶ ... diff_zero から選ぶものは 2 ^ len(diff_zero) 通り if len(diff_pos) != 0 or len(diff_neg) != 0: possible_max = min(sum(diff_pos), sum(diff_neg)) possible_min = max(min(diff_pos), min(diff_neg)) for i in range(possible_min, possible_max + 1): pattern_pos = calc_pattern(diff_pos, i) pattern_neg = calc_pattern(diff_neg, i) # debug # if pattern_pos > 0 and pattern_neg > 0: # print(f"{i} {pattern_pos} {pattern_neg}") ans += pattern_pos * pattern_neg * pow(2, len(diff_zero)) print(ans) if __name__ == "__main__": main()
s490142856
p04013
u102126195
1588878637
Python
PyPy3 (2.4.0)
py
Runtime Error
491
98524
647
n, a = map(int, input().split()) x = list(map(int, input().split())) x = [0] + x dp = [[[0 for _ in range(max(x)*n+1)] for _ in range(n+1)] for _ in range(n+1)] x.sort() for j in range(n+1): for k in range(n+1): for s in range(max(x)*n+1): if j == 0 and k == 0 and s == 0: dp[j][k][s] = 1 elif j >= 1 and s < x[j]: dp[j][k][s] = dp[j-1][k][s] elif j >= 1 and k >= 1 and s >= x[j]: dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j]] else: dp[j][k][s] = 0 ans = 0 for k in range(1, n+1): ans += dp[n][k][k*a] print(ans)
s875611874
p04013
u097317219
1588877622
Python
PyPy3 (2.4.0)
py
Runtime Error
405
92636
497
n,a = map(int,input().split()) x = list(map(int,input().split())) max_x = max(x) dp = [[[0]*(n*max_x+1) for i in range(n+1)] for j in range(n+1)] dp[0][0][0] = 1 for i in range(n+1): for j in range(n+1): for k in range(n*max_x+1): if i>=1 and k < x[i-1]: dp[i][j][k] = dp[i-1][j][k] elif i>=1 and j>= 1 and k>= x[i-1]: dp[i][j][k] = dp[i-1][j][k]+dp[i-1][j-1][k-x[i-1]] else: continue ans = 0 for j in range(1,n+1): ans += dp[n][j][j*a] print(ans)
s195172899
p04013
u934868410
1588708527
Python
Python (3.4.3)
py
Runtime Error
73
4980
218
n,a = map(int,input().split()) x = list(map(int,input().split())) t = [[0]*5001 for _ in range(n+1)] ans = 0 for i in range(1, n+1): for y in x: for z in t[i-1]: t[i][z+y-a] += 1 ans += t[i][0] print(ans)
s760745230
p04013
u934868410
1588708503
Python
Python (3.4.3)
py
Runtime Error
21
4980
215
n,a = map(int,input().split()) x = list(map(int,input().split())) t = [[0]*5001 for _ in range(n+1)] ans = 0 for i in range(1, n+1): for y in x: for z in t[i-1]: t[z+y-a] += 1 ans += t[i][0] print(ans)
s289049759
p04013
u614875193
1588615992
Python
Python (3.4.3)
py
Runtime Error
17
2940
1109
#include <bits/stdc++.h> using namespace std; const long long INF = 1LL << 60; int MOD = 1000000007; double PI = 3.14159265358979323846; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } typedef long long ll; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rep1(i,n) for(int i=1;i<(int)(n);i++) #define For(i,s,n) for (int i=s;i<(int)(n);i++) #define vi vector<int> #define vii vector< vector<int> > #define All(c) (c).begin(), (c).end() #define Print(x) cout<<(x)<<"\n" int N, A; int X[51]; ll dp[51][51][2501]; int main() { cin >> N >> A; rep(i, N) cin >> X[i]; rep(i, 51) { rep(j, 51) { rep(k, 2501) { if (i == 0 && j == 0 && k == 0) { dp[i][j][k] = 1; } else if (i>=1 && k<X[i-1]) { dp[i][j][k] = dp[i - 1][j][k]; } else if (i>=1 && j>=1 && k>=X[i-1]){ dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - X[i-1]]; } } } } ll ans = 0; rep1(i, N+1) { ans += dp[N][i][i * A]; } cout << ans << endl; }
s734216641
p04013
u106797249
1588520069
Python
Python (3.4.3)
py
Runtime Error
17
2940
360
def resolve(): N, A = list(map(int, input().split())) X = sorted(list(map(int, input().split()))) cnt = 0 for bits in range(1, 1<<N): flags = list(bin(bits)[2:].zfill(N)) _X = [x for i, x in enumerate(X) if flags[i]=="1"] cnt += 1 if sum(_X)/len(_X) == A print(cnt) if '__main__' == __name__: resolve()
s917901271
p04013
u308918401
1588449635
Python
Python (3.4.3)
py
Runtime Error
21
3064
476
n,a=map(int,input().split()) x=list(map(int,input().split())) t=[[[0]*(n*a+1)]*(n+1)]*(n+1) ans=0 for j in range(n+1): for k in range(n+1): if k>j: break for s in range((n+1)*a+1): if s==0 and k==0 and j==0: t[j][k][s]=1 elif j>=1 and x[j-1]>s: t[j][k][s]=t[j-1][k][s] elif j>=1 and k>=1 and x[j-1]<=s: t[j][k][s]=t[j-1][k][s]+t[j-1][k-1][s-x[j-1]] if j==n and k>=1 and s==k*a: ans+=t[j][k][s] print(ans)
s458332743
p04013
u308918401
1588447031
Python
Python (3.4.3)
py
Runtime Error
72
12276
474
n,a=map(int,input().split()) x=list(map(int,input().split())) t=[[[0 for s in range(k*a+1)]for k in range(j+1)]for j in range(n+1)] for j in range(n+1): for k in range(j+1): for s in range(k*a+1): if s==0 and k==0 and j==0: t[j][k][s]=0 elif j>=1 and x[j+1]<s: t[j][k][s]=t[j-1][k][s] elif j>=1 and k>=1 and x[j+1]>=s: t[j][k][s]=t[j-1][k][s]+t[j-1][k-1][s-x[j+1]] ans=0 for i in range(n): ans+=t[n][i+1][(i+1)*a] print(ans)
s266379086
p04013
u915647268
1587812210
Python
Python (3.4.3)
py
Runtime Error
216
5108
378
n, a = [int(i) for i in input().split()] x = [int(i)-a for i in input().split()] max = max(x) dp = [[0 for _ in range(2*n*max+1)] for _ in range(n+1)] dp[0][n*max] = 1 for i in range(1, n+1): for j in range(2*n*max+1): if j - x[i-1] < 0 or j - x[i-1] > 2*n*max: dp[i][j] = dp[i-1][j] else: dp[i][j] = dp[i-1][j] + dp[i-1][j-x[i-1]] print(dp[n][n*max]-1)
s819337404
p04013
u915647268
1587811808
Python
Python (3.4.3)
py
Runtime Error
194
5108
566
n, a = [int(i) for i in input().split()] x = [int(i)-a for i in input().split()] max = max(x) dp = [[0 for _ in range(2*n*max+1)] for _ in range(n+1)] dp[0][n*max] = 1 for i in range(1, n+1): for j in range(2*n*max+1): if j - x[i-1] < 0 or j - x[i-1] > 2*n*max: dp[i][j] = dp[i-1][j] else: dp[i][j] = dp[i-1][j] + dp[i-1][j-x[i-1]] print(dp[n][n*max]-1) # # def function(i, j, x): # print(0) # if i == 0 and j == 0: # return 1 # elif i == 0 and j == x[0]: # return 1 # else: # return function(i-1, j, x) + function(i-1, j-x[i], x)
s640040742
p04013
u915647268
1587810763
Python
Python (3.4.3)
py
Runtime Error
195
5108
577
n, a = [int(i) for i in input().split()] x = [int(i)-a for i in input().split()] max = max(x) dp = [[0 for _ in range(2*n*max)] for _ in range(n)] dp[0][n*max+x[0]] = 1 dp[0][n*max] = 1 for i in range(1, n): for j in range(2*n*max): if j - x[i] < 0 or j - x[i] >= 2*n*max: dp[i][j] = dp[i-1][j] else: dp[i][j] = dp[i-1][j] + dp[i-1][j-x[i]] print(dp[n-1][n*max]-1) # # def function(i, j, x): # print(0) # if i == 0 and j == 0: # return 1 # elif i == 0 and j == x[0]: # return 1 # else: # return function(i-1, j, x) + function(i-1, j-x[i], x)
s445335537
p04013
u622045059
1587320520
Python
Python (3.4.3)
py
Runtime Error
2107
58920
2583
# python3.4.2用 import math import fractions import bisect import collections import itertools import heapq import string import sys import copy from decimal import * from collections import deque sys.setrecursionlimit(10**7) MOD = 10**9+7 INF = float('inf') #無限大 def gcd(a,b):return fractions.gcd(a,b) #最大公約数 def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数 def iin(): return int(sys.stdin.readline()) #整数読み込み def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み def isn(): return sys.stdin.readline().split() #文字列読み込み def imn(): return map(int, sys.stdin.readline().split()) #整数map取得 def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得 def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得 def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得 def iln_s(): return sorted(iln()) # 昇順の整数リスト取得 def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得 def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得 def join(l, s=''): return s.join(l) #リストを文字列に変換 def perm(l, n): return itertools.permutations(l, n) # 順列取得 def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数 def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得 def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数 def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離 def m_add(a,b): return (a+b) % MOD def lprint(l): print(*l, sep='\n') def sieves_of_e(n): is_prime = [True] * (n+1) is_prime[0] = False is_prime[1] = False for i in range(2, int(n**0.5)+1): if not is_prime[i]: continue for j in range(i * 2, n+1, i): is_prime[j] = False return is_prime N,A=imn() x = iln() X = max(x) dp = [[[0 for _ in range(N*X+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): for s in range(N*X+1): #dp[j+1][k][s] = max(dp[j+1][k][s], dp[j][k][s]) if s-x[j] < 0: dp[j+1][k][s] = dp[j][k][s] else: #if s-x[j] >= 0: dp[j+1][k+1][s] = dp[j][k+1][s] + dp[j][k][s-x[j]] ans = 0 for i in range(1, N+1): ans += dp[N][i][i*A] #print(dp[i][1]) #print(dp[N][i][i*A]) print(ans)
s597504873
p04013
u423665486
1587252362
Python
Python (3.4.3)
py
Runtime Error
18
3064
362
def resolve(): modu = 1000000007 n, m = map(int, input().split()) a = [False]*n for _ in range(m): a[int(input())] = True dp = [0]*(n+1) dp[0], dp[1] = 1, 1 for i in range(2, n+1): if a[i]: continue multi = [] if not a[i-1]: multi.append(dp[i-1]) if not a[i-2]: multi.append(dp[i-2]) dp[i] = sum(multi) % modu print(dp[-1]) resolve()
s433071657
p04013
u114233208
1586745315
Python
Python (3.4.3)
py
Runtime Error
2104
4188
967
import math def nCr(n,r): f = math.factorial return f(n) / f(r) / f(n-r) N, A = list(map(int, input().split())) X = sorted(list(map(int, input().split()))) numbers = [0 for i in range((N*A)+1)] for each in X: numbers[each] += 1 g = numbers.copy() def ways(a, k, arr, g): global numbers f = g.copy() if a == 0 and k == 0: # print(each) n = 1 # print(arr) for each in set(arr): n *= int(nCr(numbers[each],arr.count(each))) return n if a == 0 and k != 0: return 0 if k == 0 and a != 0: return 0 nways = 0 for i in range(a, 0, -1): # print('i', i, numbers[i]) if f[i] > 0: f[i] -= 1 nways += ways(a-i, k-1, arr+[i], f) f[i] = 0 # print(numbers) return nways w = 0 for a in range(A, (N*A)+A, A): numbers = g.copy() w += ways(a, int(a/A), [], numbers) # print('w', w) print(w)
s048703228
p04013
u254871849
1586715129
Python
Python (3.4.3)
py
Runtime Error
291
21484
431
import sys import numpy as np n, a, *x = map(int, sys.stdin.read().split()) def main(): m = max(n, a) * max(x) dp = np.zeros((n + 1, m + 1), dtype=np.int64) dp[0, 0] = 1 for i in range(n): ndp = np.copy(dp) for j in range(1, n + 1): ndp[j][x[i]:] += dp[j-1][:m-x[i]+1] dp = ndp i = np.arange(1, n + 1) print(np.sum(dp[i, i * a])) if __name__ == '__main__': main()
s332872127
p04013
u426572476
1586672212
Python
Python (3.4.3)
py
Runtime Error
17
3192
3409
import sys import heapq import re from itertools import permutations from bisect import bisect_left, bisect_right from collections import Counter, deque from fractions import gcd from math import factorial, sqrt from functools import lru_cache, reduce INF = 1 << 60 mod = 1000000007 sys.setrecursionlimit(10 ** 7) # UnionFind class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x def size(self, x): return -self.parents[self.find(x)] def same(self, x, y): return self.find(x) == self.find(y) def members(self, x): root = self.find(x) return [i for i in range(self.n) if self.find(i) == root] def roots(self): return [i for i, x in enumerate(self.parents) if x < 0] def group_count(self): return len(self.roots()) def all_group_members(self): return {r: self.members(r) for r in self.roots()} def __str__(self): return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots()) # ダイクストラ def dijkstra_heap(s, edge, n): #始点sから各頂点への最短距離 d = [10**20] * n used = [True] * n #True:未確定 d[s] = 0 used[s] = False edgelist = [] for a,b in edge[s]: heapq.heappush(edgelist,a*(10**6)+b) while len(edgelist): minedge = heapq.heappop(edgelist) #まだ使われてない頂点の中から最小の距離のものを探す if not used[minedge%(10**6)]: continue v = minedge%(10**6) d[v] = minedge//(10**6) used[v] = False for e in edge[v]: if used[e[1]]: heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1]) return d # 素因数分解 def factorization(n): arr = [] temp = n for i in range(2, int(-(-n**0.5//1))+1): if temp%i==0: cnt=0 while temp%i==0: cnt+=1 temp //= i arr.append([i, cnt]) if temp!=1: arr.append([temp, 1]) if arr==[]: arr.append([n, 1]) return arr # 2数の最小公倍数 def lcm(x, y): return (x * y) // gcd(x, y) # リストの要素の最小公倍数 def lcm_list(numbers): return reduce(lcm, numbers, 1) # リストの要素の最大公約数 def gcd_list(numbers): return reduce(gcd, numbers) # ここから書き始める n, a = map(int, input().split()) x = list(map(int, input().split())) if n == 1: if x[0] == a: print(1) else: print(0) else: for i in range(n): x[i] -= a # x.sort() dp = [[0 for j in range(99)] for i in range(n)] # print(dp) for i in range(n): if i == 0: dp[i][49] = 1 dp[i][x[i] + 49] += 1 continue for j in range(99): dp[i][j] = dp[i - 1][j] if 0 <= j - x[i] <= 98: dp[i][j] += dp[i - 1][j - x[i]] ans = dp[-1][49] # for i in range(n): # print(dp[i]) print(ans - 1)
s214543673
p04013
u411203878
1586630548
Python
PyPy3 (2.4.0)
py
Runtime Error
172
38896
671
import math import collections def comb(n, k): return math.factorial(n) // math.factorial(k) // math.factorial(n - k) n,a = map(int,input().split()) t = list(map(int,input().split())) memo = [0]*51 for i in t: memo[i] += 1 typecount = [] ans = 0 for i in t: if i != a: typecount.append(i) for i in range(1,len(typecount)): for j in itertools.combinations(typecount,i): if int((sum(j)/len(j))*100) == int(sum(j)/len(j))*100: if int(sum(j)/len(j))==a: #print(j) ans += 2**(memo[a]) if 0 < memo[a]: for i in range(1,memo[a]+1): ans += comb(memo[a], i) print(ans)
s361954215
p04013
u411203878
1586630307
Python
Python (3.4.3)
py
Runtime Error
21
3316
685
import math def combination(n, k): return math.factorial(n) // math.factorial(k) // math.factorial(n - k) import collections n,a = map(int,input().split()) t = list(map(int,input().split())) memo = [0]*51 for i in t: memo[i] += 1 typecount = [] ans = 0 for i in t: if i != a: typecount.append(i) for i in range(1,len(typecount)): for j in itertools.combinations(typecount,i): if int((sum(j)/len(j))*100) == int(sum(j)/len(j))*100: if int(sum(j)/len(j))==a: #print(j) ans += 2**(memo[a]) if 0 < memo[a]: for i in range(1,memo[a]+1): ans += combination(memo[a], i) print(ans)