# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1085767 | juicy | Ice Hockey World Championship (CEOI15_bobek) | C++17 | 303 ms | 20916 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;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int n; long long k; cin >> n >> k;
vector<long long> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
vector<long long> lt, rt;
for (int m = 0; m < (1 << n / 2); ++m) {
long long sum = 0;
for (int i = 0; i < n / 2; ++i) {
if (m >> i & 1) {
sum += a[i];
}
}
lt.push_back(sum);
}
for (int m = 0; m < (1 << n - n / 2); ++m) {
long long sum = 0;
for (int i = 0; i < n - n / 2; ++i) {
if (m >> i & 1) {
sum += a[n / 2 + i];
}
}
rt.push_back(sum);
}
sort(lt.rbegin(), lt.rend());
sort(rt.begin(), rt.end());
int j = 0;
long long res = 0;
for (auto x : lt) {
while (j < rt.size() && rt[j] + x <= k) {
++j;
}
res += j;
}
cout << res;
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... |