이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <algorithm>
#define int int64_t
using namespace std;
struct solver
{
int n, m;
vector<int> vals;
vector<int> possh1;
vector<int> possh2;
vector<int> gethalf(int l, int r)
{
vector<int> res = {0};
for (int i = l; i < r; i++)
{
int cs = res.size();
for (int j = 0; j < cs; j++)
{
res.push_back(res[j] + vals[i]);
}
}
return res;
}
int solve()
{
possh1 = gethalf(0, n / 2);
possh2 = gethalf(n / 2, n);
sort(possh1.begin(), possh1.end());
sort(possh2.begin(), possh2.end());
int res = 0;
int rp = possh2.size();
for (int lp = 0; lp < (int)possh1.size(); lp++)
{
while (rp > 0 && possh2[rp - 1] + possh1[lp] > m) rp--;
res += rp;
}
return res;
}
};
signed main()
{
int n, m;
solver s;
cin >> n >> m;
s.n = n; s.m = m;
s.vals.resize(n);
for (int i = 0; i < n; i++) cin >> s.vals[i];
cout << s.solve() << "\n";
}
# | 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... |