This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//Be Name KHODA
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define pp pop_back
#define lb lower_bound
#define ub upper_bound
#define cl clear
#define bg begin
#define arr(x) array<int , x>
#define endl '\n'
int n;
ll m;
vector<ll> a , b;
vector<ll> ls , rs;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for(int i = 0 ; i < min(n , 20) ; i++){
ll d;
cin >> d;
a.pb(d);
}
for(int i = 20 ; i < n ; i++){
ll d;
cin >> d;
b.pb(d);
}
for(int msk = 0 ; msk < (1 << min(n , 20)) ; msk++){
ll d = 0;
for(int i = 0 ; i < min(n , 20) ; i++) if(((msk >> i) & 1)) d += a[i];
ls.pb(d);
}
for(int msk = 0 ; msk < (1 << (n - min(n , 20))) ; msk++){
ll d = 0;
for(int i = 0 ; i < (n - min(n , 20)) ; i++) if(((msk >> i) & 1)) d += b[i];
rs.pb(d);
}
sort(rs.bg() , rs.end());
ll o = 0;
for(ll l : ls){
if(l > m) continue;
o += int(ub(rs.bg() , rs.end() , m - l) - rs.bg());
}
cout << o;
}
# | 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... |