#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define pb push_back
#define fr first
#define sc second
#define ARRS ((ll)(2e6+500))
#define MAX ((ll)(1e6+100))
#define MOD ((ll)1e6+7)
#define mi(a,b) a=min((a),(b))
ll n,m,k,p,l,r,q;
ll a[ARRS];
ll b[ARRS];
ll s[ARRS];
ll es[ARRS];
int main(){
#ifdef KHOKHO
freopen("in.in","r",stdin);
freopen("out.out","w",stdout);
#endif
ios::sync_with_stdio(0);
ll S;
cin>>n>>S;
ll m=n/2;
n=n-m;
for(int i=0; i<n; i++)cin>>a[i];
for(int i=0; i<m; i++)cin>>b[i];
for(int i=0; i<(1<<n); i++)
for(int t=0; t<n; t++)
if((i>>t)&1)s[i]+=a[t];
for(int i=0; i<(1<<m); i++)
for(int t=0; t<m; t++)
if((i>>t)&1)es[i]+=b[t];
sort(s,s+(1<<n));
sort(es,es+(1<<m));
ll pas=0;
for(int i=0; i<(1<<n); i++){
pas+=upper_bound(es,es+(1<<m),S-s[i])-es;
}
cout<<pas;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
488 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
3 |
Correct |
3 ms |
640 KB |
Output is correct |
4 |
Correct |
3 ms |
752 KB |
Output is correct |
5 |
Correct |
2 ms |
836 KB |
Output is correct |
6 |
Correct |
2 ms |
836 KB |
Output is correct |
7 |
Correct |
3 ms |
836 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
836 KB |
Output is correct |
2 |
Correct |
3 ms |
836 KB |
Output is correct |
3 |
Correct |
3 ms |
880 KB |
Output is correct |
4 |
Correct |
3 ms |
880 KB |
Output is correct |
5 |
Correct |
3 ms |
880 KB |
Output is correct |
6 |
Correct |
3 ms |
880 KB |
Output is correct |
7 |
Correct |
2 ms |
880 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
880 KB |
Output is correct |
2 |
Correct |
4 ms |
880 KB |
Output is correct |
3 |
Correct |
3 ms |
880 KB |
Output is correct |
4 |
Correct |
3 ms |
880 KB |
Output is correct |
5 |
Correct |
3 ms |
880 KB |
Output is correct |
6 |
Correct |
3 ms |
880 KB |
Output is correct |
7 |
Correct |
3 ms |
880 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
40 ms |
2468 KB |
Output is correct |
2 |
Correct |
106 ms |
4904 KB |
Output is correct |
3 |
Correct |
469 ms |
17204 KB |
Output is correct |
4 |
Correct |
118 ms |
17204 KB |
Output is correct |
5 |
Correct |
21 ms |
17204 KB |
Output is correct |
6 |
Correct |
15 ms |
17204 KB |
Output is correct |
7 |
Correct |
27 ms |
17204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
52 ms |
17204 KB |
Output is correct |
2 |
Correct |
45 ms |
17204 KB |
Output is correct |
3 |
Correct |
188 ms |
17204 KB |
Output is correct |
4 |
Correct |
2 ms |
17204 KB |
Output is correct |
5 |
Correct |
10 ms |
17204 KB |
Output is correct |
6 |
Correct |
33 ms |
17204 KB |
Output is correct |
7 |
Correct |
27 ms |
17204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
84 ms |
17204 KB |
Output is correct |
2 |
Correct |
179 ms |
17204 KB |
Output is correct |
3 |
Correct |
168 ms |
17204 KB |
Output is correct |
4 |
Correct |
3 ms |
17204 KB |
Output is correct |
5 |
Correct |
111 ms |
17204 KB |
Output is correct |
6 |
Correct |
433 ms |
17392 KB |
Output is correct |
7 |
Correct |
145 ms |
17392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
353 ms |
17392 KB |
Output is correct |
2 |
Correct |
45 ms |
17392 KB |
Output is correct |
3 |
Correct |
14 ms |
17392 KB |
Output is correct |
4 |
Correct |
3 ms |
17392 KB |
Output is correct |
5 |
Correct |
12 ms |
17392 KB |
Output is correct |
6 |
Correct |
392 ms |
17392 KB |
Output is correct |
7 |
Correct |
23 ms |
17392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
17392 KB |
Output is correct |
2 |
Correct |
112 ms |
17392 KB |
Output is correct |
3 |
Correct |
17 ms |
17392 KB |
Output is correct |
4 |
Correct |
16 ms |
17392 KB |
Output is correct |
5 |
Correct |
124 ms |
17392 KB |
Output is correct |
6 |
Correct |
38 ms |
17392 KB |
Output is correct |
7 |
Correct |
425 ms |
17392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
434 ms |
17392 KB |
Output is correct |
2 |
Correct |
40 ms |
17392 KB |
Output is correct |
3 |
Correct |
15 ms |
17392 KB |
Output is correct |
4 |
Correct |
464 ms |
17492 KB |
Output is correct |
5 |
Correct |
148 ms |
17492 KB |
Output is correct |
6 |
Correct |
26 ms |
17492 KB |
Output is correct |
7 |
Correct |
52 ms |
17492 KB |
Output is correct |