Submission #658776

#TimeUsernameProblemLanguageResultExecution timeMemory
658776beaconmcIce Hockey World Championship (CEOI15_bobek)Pypy 3
10 / 100
1093 ms196792 KiB
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)
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...