# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
170881 | socho | Ice Hockey World Championship (CEOI15_bobek) | C++14 | 418 ms | 21000 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() {
long long n, m;
cin >> n >> m;
vector<long long> vc(n);
for (long long i=0; i<n; i++) cin >> vc[i];
vector<long long> le, ri;
for (long long i=0; i<n/2; i++) {
le.push_back(vc[i]);
// cout << "L " << i << endl;
}
for (long long i=n/2; i<n; i++) {
ri.push_back(vc[i]);
// cout << "R " << i << endl;
}
long long ls = le.size(), rs = ri.size();
vector<long long> les, ris;
for (long long i=0; i<(1<<ls); i++) {
long long sm = 0;
for (long long j=0; j<ls; j++) {
if (i & (1 << j)) sm += le[j];
}
les.push_back(sm);
}
for (long long i=0; i<(1<<rs); i++) {
long long sm = 0;
for (long long j=0; j<rs; j++) {
if (i & (1 << j)) sm += ri[j];
}
ris.push_back(sm);
}
sort(les.begin(), les.end());
sort(ris.begin(), ris.end());
reverse(ris.begin(), ris.end());
long long valid = 0;
long long pt = 0;
for (int i=0; i<les.size(); i++) {
long long mx = m - les[i];
while (pt < ris.size() && ris[pt] > mx) pt++;
valid += (ris.size() - pt);
}
cout << valid << endl;
}
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... |