이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define db long double
#define vll vector<pll>
#define endl '\n'
#define all(x) x.begin(), x.end()
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
int n, m, res, a[45];
void fmain(){
cin >> n >> m;
for(int i = 1; i <= n; i++){
cin >> a[i];
}
vi v;
for(int mask = 0; mask < (1 << (n / 2)); mask++){
int s = 0;
for(int i = 0; i < n / 2; i++){
if((1 << i) & mask){
s += a[i + 1];
}
}
v.push_back(s);
}
sort(all(v));
for(int mask = 0; mask < (1 << (n - n / 2)); mask++){
int s = 0;
for(int i = 0; i < n - n / 2; i++){
if((1 << i) & mask){
s += a[n / 2 + i + 1];
}
}
int ind = upper_bound(all(v), m - s) - v.begin();
res += ind;
}
cout << res;
}
signed main(){
fastio;
int tmr = 1;
// cin >> tmr;
while(tmr--){
fmain();
}
}
# | 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... |