# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
281998 | ChrisT | Ice Hockey World Championship (CEOI15_bobek) | C++17 | 253 ms | 20944 KiB |
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;
int main () {
int n; long long m;
scanf ("%d %lld",&n,&m);
vector<long long> a(n), sums1, sums2; int ed;
for (auto &au : a) scanf ("%lld",&au);
function<void(int,long long,vector<long long>&)> gen = [&] (int ind, long long sum, vector<long long> &sums) {
if (ind == ed) return (void)sums.push_back(sum);
gen(ind+1,sum,sums); gen(ind+1,sum+a[ind],sums);
};
ed = n/2;
gen(0,0,sums1);
ed = n;
gen(n/2,0,sums2);
sort(sums1.begin(),sums1.end()); sort(sums2.begin(),sums2.end());
long long ret = 0; int pp = (int)sums2.size() - 1;
for (int i = 0; i < (int)sums1.size(); i++) {
while (~pp && sums1[i] + sums2[pp] > m) --pp;
ret += pp + 1;
}
printf ("%lld\n",ret);
return 0;
}
Compilation message (stderr)
# | 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... |