#include<bits/stdc++.h>
#include<fstream>
using namespace std;
ifstream fin("HCN.INP");
ofstream fout("HCN.OUT");
#define sz(a) (int)a.size()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const ld PI = 3.14159265359;
//using u128 = __uint128_t;
//const int x[4] = {1, -1, 0, 0};
//const int y[4] = {0, 0, 1, -1};
const ll mod = 1e9 + 9;
const int mxn = 1e5 + 5, mxq = 2e5 + 5, sq = 200, mxv = 2e6 + 5;
const ll inf = 1e17 + 5;
//const int base= (1 << 18);
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int n; ll m;
ll a[45];
vt<ll>two, one;
void solve(int l, int r, ll sm){
if(l > r){
if(r == n)two.pb(sm);
else one.pb(sm);
return;
}
solve(l + 1, r, sm + a[l]); solve(l + 1, r, sm);
}
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> m;
for(int i = 1; i <= n; i++)cin >> a[i];
int nn = n / 2;
solve(1, nn, 0); solve(nn + 1, n, 0);
sort(one.begin(), one.end()); sort(two.begin(), two.end());
ll ans = 0, r = 0;
for(int i = sz(one) - 1; i >= 0; i--){
while(r < sz(two) && two[r] + one[i] <= m)r++;
ans += r;
}
cout << ans;
return(0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
464 KB |
Output is correct |
2 |
Correct |
0 ms |
464 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 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 |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 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 |
1 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 |
13 ms |
2144 KB |
Output is correct |
2 |
Correct |
41 ms |
5584 KB |
Output is correct |
3 |
Correct |
167 ms |
21196 KB |
Output is correct |
4 |
Correct |
40 ms |
5588 KB |
Output is correct |
5 |
Correct |
6 ms |
1756 KB |
Output is correct |
6 |
Correct |
4 ms |
1044 KB |
Output is correct |
7 |
Correct |
9 ms |
1756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
3032 KB |
Output is correct |
2 |
Correct |
15 ms |
2144 KB |
Output is correct |
3 |
Correct |
65 ms |
12724 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
3 ms |
1116 KB |
Output is correct |
6 |
Correct |
10 ms |
1612 KB |
Output is correct |
7 |
Correct |
9 ms |
1756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
3676 KB |
Output is correct |
2 |
Correct |
61 ms |
8024 KB |
Output is correct |
3 |
Correct |
60 ms |
7252 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
28 ms |
8536 KB |
Output is correct |
6 |
Correct |
138 ms |
21452 KB |
Output is correct |
7 |
Correct |
60 ms |
6744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
124 ms |
13652 KB |
Output is correct |
2 |
Correct |
14 ms |
2144 KB |
Output is correct |
3 |
Correct |
5 ms |
1112 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
3 ms |
1116 KB |
Output is correct |
6 |
Correct |
121 ms |
13768 KB |
Output is correct |
7 |
Correct |
9 ms |
1756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
2140 KB |
Output is correct |
2 |
Correct |
40 ms |
5588 KB |
Output is correct |
3 |
Correct |
5 ms |
1112 KB |
Output is correct |
4 |
Correct |
5 ms |
1116 KB |
Output is correct |
5 |
Correct |
32 ms |
8276 KB |
Output is correct |
6 |
Correct |
14 ms |
2104 KB |
Output is correct |
7 |
Correct |
165 ms |
22212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
165 ms |
21960 KB |
Output is correct |
2 |
Correct |
16 ms |
2144 KB |
Output is correct |
3 |
Correct |
5 ms |
1116 KB |
Output is correct |
4 |
Correct |
176 ms |
21704 KB |
Output is correct |
5 |
Correct |
40 ms |
11984 KB |
Output is correct |
6 |
Correct |
9 ms |
1752 KB |
Output is correct |
7 |
Correct |
19 ms |
3032 KB |
Output is correct |