#include<bits/stdc++.h>
using namespace std;
#ifdef ONPC
#include"debug.h"
#else
#define debug(...) 42
#endif
#define endl '\n'
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
const int mod = 1e9 + 7;
const int MAXN = 1e6 + 15;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
ll a[MAXN], n, m;
ll ans = 0;
vector<ll> b;
void solve(int idx, ll sum, bool typ){
if (typ == 0 && idx == n / 2){
b.pb(sum);
return;
}
if (typ == 1 && idx == n){
ans += upper_bound(all(b), m - sum) - b.begin();
return;
}
solve(idx + 1, sum, typ);
solve(idx + 1, sum + a[idx], typ);
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for (int i = 0; i < n; i++){
cin >> a[i];
}
solve(0, 0, 0);
sort(all(b));
solve(n / 2, 0, 1);
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
420 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
992 KB |
Output is correct |
2 |
Correct |
55 ms |
2520 KB |
Output is correct |
3 |
Correct |
287 ms |
8912 KB |
Output is correct |
4 |
Correct |
49 ms |
2520 KB |
Output is correct |
5 |
Correct |
4 ms |
992 KB |
Output is correct |
6 |
Correct |
3 ms |
736 KB |
Output is correct |
7 |
Correct |
5 ms |
992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
1496 KB |
Output is correct |
2 |
Correct |
15 ms |
988 KB |
Output is correct |
3 |
Correct |
105 ms |
6608 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
736 KB |
Output is correct |
6 |
Correct |
5 ms |
992 KB |
Output is correct |
7 |
Correct |
5 ms |
992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
1496 KB |
Output is correct |
2 |
Correct |
86 ms |
2520 KB |
Output is correct |
3 |
Correct |
90 ms |
2520 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
17 ms |
2520 KB |
Output is correct |
6 |
Correct |
80 ms |
8908 KB |
Output is correct |
7 |
Correct |
27 ms |
2516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
202 ms |
5328 KB |
Output is correct |
2 |
Correct |
13 ms |
988 KB |
Output is correct |
3 |
Correct |
5 ms |
736 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
736 KB |
Output is correct |
6 |
Correct |
58 ms |
5332 KB |
Output is correct |
7 |
Correct |
5 ms |
988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
988 KB |
Output is correct |
2 |
Correct |
54 ms |
2564 KB |
Output is correct |
3 |
Correct |
4 ms |
736 KB |
Output is correct |
4 |
Correct |
4 ms |
860 KB |
Output is correct |
5 |
Correct |
24 ms |
2520 KB |
Output is correct |
6 |
Correct |
7 ms |
992 KB |
Output is correct |
7 |
Correct |
105 ms |
9660 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
212 ms |
9424 KB |
Output is correct |
2 |
Correct |
18 ms |
988 KB |
Output is correct |
3 |
Correct |
5 ms |
736 KB |
Output is correct |
4 |
Correct |
289 ms |
10704 KB |
Output is correct |
5 |
Correct |
34 ms |
5588 KB |
Output is correct |
6 |
Correct |
5 ms |
992 KB |
Output is correct |
7 |
Correct |
11 ms |
1588 KB |
Output is correct |