이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "biscuits.h"
// #include "grader.cpp" наистина какъв ви е проблема с това :(
#include <bits/stdc++.h>
using namespace std;
const int maxn = 64;
const long long inf = (1LL << 60) - 1;
int n;
long long x;
long long a[maxn];
struct key
{
int pos;
long long mx;
inline friend bool operator < (const key& x, const key& y)
{
return x.pos < y.pos || (x.pos == y.pos && x.mx < y.mx);
}
};
map<key, long long> dp;
long long s[maxn];
long long f(int pos, long long mx)
{
if (mx < 0)
{
return 0;
}
if (pos == -1)
{
return 1;
}
if (mx > (1LL << pos + 1))
{
return 1;
}
if (dp.find({pos, mx}) != dp.end())
{
return dp[{pos, mx}];
}
long long result = f(pos - 1, min(mx, (1LL << pos) - 1));
result += f(pos - 1, min(mx, s[pos] / x) - (1LL << pos));
return dp[{pos, mx}] = result;
}
long long count_tastiness(long long X, vector<long long> arr)
{
dp.clear();
n = arr.size();
x = X;
for (int i = 0; i < n; ++i)
{
a[i] = arr[i];
}
for (int i = 0; i < maxn; ++i)
{
if (i < n)
{
s[i] = a[i] * (1LL << i);
}
else
{
s[i] = 0;
}
if (i >= 1)
{
s[i] += s[i - 1];
}
}
return f(60, inf);
}
/*
1
3 3
5 2 1
1
3 2
2 1 2
2
3 3
5 2 1
3 2
2 1 2
5 9 13 ... 13
*/
컴파일 시 표준 에러 (stderr) 메시지
biscuits.cpp: In function 'long long int f(int, long long int)':
biscuits.cpp:42:26: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
42 | if (mx > (1LL << pos + 1))
| ~~~~^~~
# | 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... |