#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD=1000000007;
map<LL,LL> byk;
LL a[25],b[25];
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
LL n,m,ans=0;
cin >> n >> m;
LL first=n/2,second=n-first;
for(LL i=0;i<first;i++)cin >> a[i];
for(LL i=0;i<second;i++)cin >> b[i];
for(LL i=0;i<(1<<first);i++){
LL brp=0;
for(LL j=0;j<first;j++){
if(i & (1<<j))brp+=a[j];
}
byk[brp]++;
}
for(auto it=byk.begin();it!=byk.end();++it){
if(it==byk.begin())continue;
auto prev=it;
--prev;
byk[it->first]+=byk[prev->first];
}
for(LL i=0;i<(1<<second);i++){
LL brp=0;
for(LL j=0;j<second;j++){
if(i & (1<<j))brp+=b[j];
}
//butuh maksimal m-brp
auto butuh=byk.upper_bound(m-brp);
if(butuh==byk.begin())continue;
--butuh;
ans+=(butuh->second);
}
cout << ans << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
416 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
1292 KB |
Output is correct |
2 |
Correct |
364 ms |
11140 KB |
Output is correct |
3 |
Execution timed out |
1067 ms |
29180 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
71 ms |
1528 KB |
Output is correct |
2 |
Correct |
85 ms |
3532 KB |
Output is correct |
3 |
Correct |
211 ms |
1024 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
8 ms |
376 KB |
Output is correct |
6 |
Correct |
36 ms |
2040 KB |
Output is correct |
7 |
Correct |
57 ms |
4472 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
225 ms |
7084 KB |
Output is correct |
2 |
Correct |
441 ms |
8056 KB |
Output is correct |
3 |
Correct |
459 ms |
8316 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
80 ms |
376 KB |
Output is correct |
6 |
Correct |
367 ms |
1528 KB |
Output is correct |
7 |
Correct |
359 ms |
16788 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1090 ms |
33228 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
97 ms |
4480 KB |
Output is correct |
2 |
Correct |
437 ms |
16792 KB |
Output is correct |
3 |
Correct |
31 ms |
2424 KB |
Output is correct |
4 |
Correct |
31 ms |
2424 KB |
Output is correct |
5 |
Correct |
89 ms |
376 KB |
Output is correct |
6 |
Correct |
64 ms |
4464 KB |
Output is correct |
7 |
Execution timed out |
1088 ms |
66040 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1073 ms |
65948 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |