이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// author - alimammadzade
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
cin.tie(nullptr)->sync_with_stdio(false);
// system("cls"), freopen("in.txt", "r", stdin);
int n, m, res = 0;
cin >> n >> m;
vector<int> fi, se;
vector<int> fii, see;
for (int i = 0; i < n / 2; i++) {
int x;
cin >> x;
fi.push_back(x);
}
for (int i = n / 2; i < n; i++) {
int x;
cin >> x;
se.push_back(x);
}
int n1 = fi.size(), n2 = se.size();
for (int i = 0; i < (1 << n1); i++) {
int sum = 0;
for (int j = 0; j < n1; j++)
if (i & (1 << j)) sum += fi[j];
fii.push_back(sum);
}
for (int i = 0; i < (1 << n2); i++) {
int sum = 0;
for (int j = 0; j < n2; j++)
if (i & (1 << j)) sum += se[j];
see.push_back(sum);
}
sort(fii.begin(), fii.end());
sort(see.begin(), see.end());
for (int& i : fii) {
if (i > m) break;
res += upper_bound(see.begin(), see.end(), m - i) - see.begin();
}
cout << res;
}
# | 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... |