# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
894619 | IWKR | Ice Hockey World Championship (CEOI15_bobek) | C++17 | 425 ms | 22716 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;
#define int long long
int32_t main() {
int n, m;
cin >> n >> m;
int arr[n];
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
int a = n / 2;
vector<int> v;
vector<int> v2;
int ans = 0;
for (int i = 0; i < (1 << a); i++) {
int res = 0;
for (int j = 0; j < a; j++) {
if (i & (1 << j)) {
res += arr[j];
}
}
if (res <= m) {
v.push_back(res);
}
}
int b = n - a;
for (int i = 0; i < (1 << b); i++) {
int res = 0;
for (int j = 0; j < b; j++) {
if (i & (1 << j)) {
res += arr[a + j];
}
}
if (res <= m) {
v2.push_back(res);
}
}
sort(v.begin(), v.end());
for (int i = 0; i < v2.size(); i++) {
int low = 0;
int high = v.size();
while (high - low > 1) {
int mid = (high + low) / 2;
if (v[mid] + v2[i] <= m) {
low = mid;
} else {
high = mid;
}
}
ans += low + 1;
}
cout << ans;
}
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... |