이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define lc (rt<<1)
#define rc (rt<<1|1)
#define pb push_back
#define cl(a, b) memset(a, b, sizeof(a))
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vii;
typedef vector<pii> viii;
const int inf = 0x3F3F3F3F;
const ll infl = 0x3F3F3F3F3F3F3F3FLL;
const int mod = 1e9 + 7, LOG=60;
ll cnt, psa[LOG]; map<ll, ll> mp;
ll fun(ll x){
if(x < 0) return 0;
if(x == 0) return 1LL;
if(mp.count(x)) return mp[x];
int p = 63 - __builtin_clzll(x);
ll tmp = fun((1<<p)-1) + fun(min(x, psa[p]/cnt) - (1<<p));
return mp[x]=tmp;
}
ll count_tastiness(ll x, vl a){
a.resize(LOG); cnt = x; mp.clear();
psa[0] = a[0];
for(int i=1; i<LOG; i++) psa[i] = psa[i-1] + a[i]*(1LL<<i);
return fun((1LL<<LOG) - 1);
}
//int main(){
// ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
// vl a = {5, 2, 1};
// cout << count_tastiness(3, a) << endl;
//}
# | 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... |