// __builtin_popcount(x)
// __builtin_popcountll(x)
#define here cerr<<"===========================================\n"
#include <bits/stdc++.h>
#define ld double
#define ll long long
#define ull unsigned long long
#define llinf 100000000000000000LL // 10^17
#define iinf 2000000000 // 2*10^9
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
using namespace std;
#define maxn 45
ll n,m;
ll a[maxn];
vector<ll> get(ll l,ll r){
vector<ll> v;
ll siz = r-l+1;
for(ll mask = 0;mask<(1<<siz);mask++){
ll sum = 0;
for(ll i = 0;i<siz;i++) if((1<<i)&mask) sum+=a[i+l];
v.pb(sum);
}
sort(all(v));
return v;
}
int main(){
ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);
cin >> n >> m;
for(ll i = 1;i<=n;i++) cin >> a[i];
ll mid = (n+1)/2;
vector<ll> ls = get(1,mid);
vector<ll> rs = get(mid+1,n);
ll ans = 0;
for(ll x : ls){
ll i = upper_bound(all(rs),m-x) - rs.begin();
ans+=i;
}
cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
224 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
320 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
2360 KB |
Output is correct |
2 |
Correct |
86 ms |
5420 KB |
Output is correct |
3 |
Correct |
362 ms |
20716 KB |
Output is correct |
4 |
Correct |
89 ms |
5440 KB |
Output is correct |
5 |
Correct |
15 ms |
1548 KB |
Output is correct |
6 |
Correct |
10 ms |
960 KB |
Output is correct |
7 |
Correct |
19 ms |
1600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
2884 KB |
Output is correct |
2 |
Correct |
30 ms |
2256 KB |
Output is correct |
3 |
Correct |
137 ms |
10480 KB |
Output is correct |
4 |
Correct |
1 ms |
320 KB |
Output is correct |
5 |
Correct |
7 ms |
856 KB |
Output is correct |
6 |
Correct |
19 ms |
1620 KB |
Output is correct |
7 |
Correct |
19 ms |
1620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
74 ms |
4544 KB |
Output is correct |
2 |
Correct |
135 ms |
8524 KB |
Output is correct |
3 |
Correct |
130 ms |
8516 KB |
Output is correct |
4 |
Correct |
1 ms |
320 KB |
Output is correct |
5 |
Correct |
83 ms |
8524 KB |
Output is correct |
6 |
Correct |
289 ms |
20880 KB |
Output is correct |
7 |
Correct |
128 ms |
8520 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
262 ms |
16612 KB |
Output is correct |
2 |
Correct |
29 ms |
2244 KB |
Output is correct |
3 |
Correct |
10 ms |
980 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
8 ms |
960 KB |
Output is correct |
6 |
Correct |
280 ms |
16692 KB |
Output is correct |
7 |
Correct |
18 ms |
1492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
2260 KB |
Output is correct |
2 |
Correct |
84 ms |
5452 KB |
Output is correct |
3 |
Correct |
10 ms |
984 KB |
Output is correct |
4 |
Correct |
10 ms |
980 KB |
Output is correct |
5 |
Correct |
98 ms |
8444 KB |
Output is correct |
6 |
Correct |
28 ms |
2260 KB |
Output is correct |
7 |
Correct |
322 ms |
20820 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
332 ms |
20812 KB |
Output is correct |
2 |
Correct |
32 ms |
2316 KB |
Output is correct |
3 |
Correct |
11 ms |
984 KB |
Output is correct |
4 |
Correct |
385 ms |
20772 KB |
Output is correct |
5 |
Correct |
117 ms |
10508 KB |
Output is correct |
6 |
Correct |
19 ms |
1616 KB |
Output is correct |
7 |
Correct |
36 ms |
2912 KB |
Output is correct |