This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(), v.end()
#define pb push_back
#define f first
#define s second
#define pii pair<int, int>
#define pll pair<ll, ll>
using namespace std;
int main()
{
ll n, m, i, j, ans = 0, sum = 0;
cin >> n >> m;
vl v(n), v1, v2, x, y;
for(i = 0; i < n; i++)
{
cin >> v[i];
if(i < (n + 1) / 2)
v1.pb(v[i]);
else
v2.pb(v[i]);
}
ll a = v1.size(), b = v2.size();
for(i = 0; i < 1 << a; i++)
{
sum = 0;
for(j = 0; j < a; j++)
{
if((i >> j) & 1)
sum += v1[j];
}
x.pb(sum);
}
for(i = 0; i < 1 << b; i++)
{
sum = 0;
for(j = 0; j < b; j++)
{
if((i >> j) & 1)
sum += v2[j];
}
y.pb(sum);
}
sort(all(x));
sort(all(y));
for(i = 0; i < x.size(); i++)
{
ll u = upper_bound(all(y), m - x[i]) - y.begin();
ans += u;
}
cout << ans << "\n";
}
Compilation message (stderr)
bobek.cpp: In function 'int main()':
bobek.cpp:49:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | for(i = 0; i < x.size(); i++)
| ~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |