This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//#pragma GCC target("avx2")
//#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define per(i, a, b) for(int i = (a); i >= (b); i--)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int N;
ll x;
vector<ll> a;
map<ll, ll> memo[100];
ll f(ll y, int i){
if(memo[i].count(y)){
return memo[i][y];
}
ll& ans = memo[i][y];
ans = 1;
rep(j, i + 1, N){
y += (1ll << j);
if(a[j] / x >= y){
ans += f(y, j);
}
y -= (1ll << j);
}
return ans;
}
long long count_tastiness(long long X, vector<long long> A){
while(SZ(A) < 62) A.pb(0);
a = A, x = X, N = SZ(A);
rep(i, 0, N){
a[i] = a[i] * (1ll << i);
if(i) a[i] += a[i - 1];
}
rep(i, 0, N) memo[i].clear();
ll ans = 1;
rep(i, 0, N){
ll y = (1ll << i);
if(a[i] / x >= y){
ans += f(y, i);
}
}
return ans;
}
# | 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... |