#include <bits/stdc++.h>
using namespace std;
#define ll long long
void go(int n, vector<ll> &vals){
ll A[n];
for (ll &i : A) cin >> i;
for (int i = 0; i < (1 << n); i++){
ll sm = 0;
for (int j = 0; j < n; j++) if ((i >> j) & 1) sm += A[j];
vals.push_back(sm);
}
sort(vals.begin(), vals.end());
}
int main(){
int N; ll M; cin >> N >> M;
vector<ll> X, Y;
go(N / 2, X); go(N - N / 2, Y);
ll ans = 0;
for (ll i : X) ans += upper_bound(Y.begin(), Y.end(), M - i) - Y.begin();
cout<<ans<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
264 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
288 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
292 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
25 ms |
1968 KB |
Output is correct |
2 |
Correct |
79 ms |
5324 KB |
Output is correct |
3 |
Correct |
340 ms |
20784 KB |
Output is correct |
4 |
Correct |
84 ms |
5388 KB |
Output is correct |
5 |
Correct |
13 ms |
1480 KB |
Output is correct |
6 |
Correct |
8 ms |
848 KB |
Output is correct |
7 |
Correct |
16 ms |
1568 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
37 ms |
2748 KB |
Output is correct |
2 |
Correct |
29 ms |
1916 KB |
Output is correct |
3 |
Correct |
145 ms |
10544 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
6 ms |
848 KB |
Output is correct |
6 |
Correct |
18 ms |
1476 KB |
Output is correct |
7 |
Correct |
17 ms |
1560 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
65 ms |
3504 KB |
Output is correct |
2 |
Correct |
121 ms |
6572 KB |
Output is correct |
3 |
Correct |
137 ms |
6584 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
72 ms |
6568 KB |
Output is correct |
6 |
Correct |
276 ms |
20728 KB |
Output is correct |
7 |
Correct |
118 ms |
6692 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
236 ms |
12724 KB |
Output is correct |
2 |
Correct |
30 ms |
1976 KB |
Output is correct |
3 |
Correct |
10 ms |
848 KB |
Output is correct |
4 |
Correct |
1 ms |
296 KB |
Output is correct |
5 |
Correct |
9 ms |
848 KB |
Output is correct |
6 |
Correct |
263 ms |
12832 KB |
Output is correct |
7 |
Correct |
19 ms |
1596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
1976 KB |
Output is correct |
2 |
Correct |
85 ms |
5416 KB |
Output is correct |
3 |
Correct |
12 ms |
848 KB |
Output is correct |
4 |
Correct |
12 ms |
960 KB |
Output is correct |
5 |
Correct |
85 ms |
6704 KB |
Output is correct |
6 |
Correct |
26 ms |
1868 KB |
Output is correct |
7 |
Correct |
314 ms |
20696 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
326 ms |
20712 KB |
Output is correct |
2 |
Correct |
27 ms |
1968 KB |
Output is correct |
3 |
Correct |
11 ms |
848 KB |
Output is correct |
4 |
Correct |
362 ms |
20712 KB |
Output is correct |
5 |
Correct |
110 ms |
10544 KB |
Output is correct |
6 |
Correct |
17 ms |
1576 KB |
Output is correct |
7 |
Correct |
38 ms |
2860 KB |
Output is correct |