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>
using namespace std;
typedef long long ll;
ll n, m;
vector<ll> a, b, c;
void brute(int i, int e, ll cost){
if(i == e+1){
b.push_back(cost);
return;
}
brute(i+1, e, cost + a[i]);
brute(i+1, e, cost);
}
int main(){
cin>>n>>m;
a.resize(n);
for(int i = 0; i < n; i++){
cin>>a[i];
}
b.reserve(1000000); c.reserve(1000000);
brute(0, n/2, 0);
c = b;
b.clear();
brute(n/2+1, n-1, 0);
ll ans =0 ;
sort(b.begin(), b.end());
sort(c.begin(), c.end());
int pntr = c.size() - 1;
for(int i = 0; i < b.size(); i++){
while(pntr >= 0 && c[pntr] + b[i] > m){
pntr--;
}
ans += pntr + 1;
}
cout<<ans<<endl;
}
Compilation message (stderr)
bobek.cpp: In function 'int main()':
bobek.cpp:31:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < b.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... |