from bisect import *
n,m = map(int, input().split())
lis = list(map(int, input().split()))
a = n//2
b = (n-1)//2 + 1
aa = dict()
bb = dict()
#meet in middle prep
for i in range(2**a):
cur = 0
temp = 0
tempi = i
while tempi:
if tempi&1:
temp += lis[cur]
cur +=1
tempi//=2
if temp in aa:
aa[temp] += 1
else:
aa[temp] = 1
for i in range(2**b):
cur = a
temp = 0
tempi = i
while tempi:
if tempi&1:
temp += lis[cur]
cur +=1
tempi//=2
if temp in bb:
bb[temp] += 1
else:
bb[temp] = 1
aa = [[i,aa[i]] for i in aa]
bb = [[i,bb[i]] for i in bb]
aa.sort()
bb.sort()
for i in range(1,len(aa)):
aa[i][1] += aa[i-1][1]
for i in range(1,len(bb)):
bb[i][1] += bb[i-1][1]
ans = 0
for i in aa:
if m-i[0]<0: continue
ans += bb[bisect(bb, [m-i[0], 1000000000])-1][1]
print(ans)
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
18356 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
37 ms |
18372 KB |
Output is correct |
2 |
Correct |
34 ms |
18208 KB |
Output is correct |
3 |
Correct |
36 ms |
18132 KB |
Output is correct |
4 |
Correct |
36 ms |
18164 KB |
Output is correct |
5 |
Incorrect |
34 ms |
18228 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
50 ms |
19724 KB |
Output is correct |
2 |
Correct |
46 ms |
19144 KB |
Output is correct |
3 |
Correct |
49 ms |
18948 KB |
Output is correct |
4 |
Correct |
35 ms |
18232 KB |
Output is correct |
5 |
Incorrect |
45 ms |
18820 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
61 ms |
20124 KB |
Output is correct |
2 |
Correct |
55 ms |
19648 KB |
Output is correct |
3 |
Correct |
46 ms |
18956 KB |
Output is correct |
4 |
Correct |
46 ms |
19152 KB |
Output is correct |
5 |
Incorrect |
56 ms |
19620 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
180 ms |
26040 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
259 ms |
28324 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1093 ms |
58656 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1060 ms |
196792 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
906 ms |
47220 KB |
Output is correct |
2 |
Execution timed out |
1082 ms |
83352 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1089 ms |
170884 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |