# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
24702 | kdh9949 | Ice Hockey World Championship (CEOI15_bobek) | C++14 | 366 ms | 18404 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;
typedef long long ll;
int n, p, q;
ll m, x[20], y[20], a[1048576], b[1048576], ans;
int main(){
scanf("%d%lld", &n, &m);
p = n / 2; q = n - p;
if(n == 1){
ll x; scanf("%lld", &x);
printf("%lld\n", x <= m ? x : 0);
return 0;
}
for(int i = 0; i < p; i++){
scanf("%lld", x + i);
}
for(int i = 0; i < q; i++){
scanf("%lld", y + i);
}
for(int i = 0; i < (1 << p); i++){
for(int j = 0; j < p; j++) if((1 << j) & i) a[i] += x[j];
}
for(int i = 0; i < (1 << q); i++){
for(int j = 0; j < q; j++) if((1 << j) & i) b[i] += y[j];
}
sort(a, a + (1 << p));
sort(b, b + (1 << q));
for(int i = 0, j = (1 << q) - 1; i < (1 << p); i++){
for(; j >= 0; j--){
if(a[i] + b[j] <= m) break;
}
ans += (j + 1);
}
printf("%lld\n", 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... |