| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 545892 | rainboy | Ice Hockey World Championship (CEOI15_bobek) | C11 | 49 ms | 16696 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 <stdio.h>
#define N 40
#define N_ (N / 2)
void solve(long long *aa, long long *ss, int n) {
int m, h, h1, h2, i;
for (i = 0; i < n; i++) {
m = 1 << i, h = m * 2 - 1, h1 = m - 1, h2 = m - 1;
while (h1 >= 0 && h2 >= 0)
ss[h--] = ss[h1] > ss[h2] + aa[i] ? ss[h1--] : ss[h2--] + aa[i];
}
}
int main() {
static long long aa[N], ss[1 << N_], tt[1 << N_];
int n, i, m1, m2, h1, h2;
long long s, ans;
scanf("%d%lld", &n, &s);
for (i = 0; i < n; i++)
scanf("%lld", &aa[i]);
solve(aa, ss, n / 2), solve(aa + n / 2, tt, n - n / 2);
m1 = 1 << n / 2, m2 = 1 << n - n / 2;
ans = 0;
for (h1 = 0, h2 = m2 - 1; h1 < m1; h1++) {
while (h2 >= 0 && ss[h1] + tt[h2] > s)
h2--;
ans += h2 + 1;
}
printf("%lld\n", ans);
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... | ||||
