# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
44949 | bogdan10bos | Ice Hockey World Championship (CEOI15_bobek) | C++14 | 240 ms | 21596 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 FILE_IO
typedef long long LL;
int N;
int lg2[1100005];
LL V, v[45];
LL sum[2][1100005];
int main()
{
#ifdef FILE_IO
freopen("1.in", "r", stdin);
freopen("1.out", "w", stdout);
#endif
scanf("%d", &N);
scanf("%lld", &V);
for(int i = 0; i < N; i++) scanf("%lld", &v[i]);
for(int i = N; i <= 39; i++) v[i] = LL(1e18 + 1);
int mxmsk = (1 << 20) - 1;
for(int i = 2; i <= mxmsk; i++)
{
lg2[i] = lg2[i - 1];
if( (2 << lg2[i]) == i ) lg2[i]++;
}
for(int i = 0; i <= 1; i++)
{
int pos = i * 20;
for(int msk = 1; msk <= mxmsk; msk++)
{
int b = lg2[msk];
sum[i][msk] = min(LL(1e18 + 1), sum[i][msk ^ (1 << b)] + v[b + pos] );
}
sort(sum[i], sum[i] + mxmsk + 1);
}
int pos = mxmsk;
LL ans = 0LL;
for(int i = 0; i <= mxmsk; i++)
{
if(sum[0][i] > V) break;
while(V - sum[1][pos] < sum[0][i])
pos--;
ans += (pos + 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... |