Submission #810531

#TimeUsernameProblemLanguageResultExecution timeMemory
810531TimDeePacking Biscuits (IOI20_biscuits)C++17
100 / 100
65 ms844 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; #define forn(i,n) for(int i=0;i<n;++i) #define pb push_back #define all(x) x.begin(), x.end() using ll = long long; #define pi pair<int,int> #define f first #define s second #define int int64_t map<int,int> mem; int s[61]; int x; int f(int n) { if (n<=0) return 0; if (n==1) return 1; if (mem.count(n)) return mem[n]; int p=1; int i=0; while (2*p<n) p<<=1, ++i; int a = f(p); int b = f(min(n, s[i]/x+1)-p); mem[n]=a+b; return mem[n]; } ll count_tastiness(ll _x, vector<ll> a) { x=_x; mem.clear(); forn(i,60) s[i]=0; s[0]=a[0]; while (a.size()<60) a.pb(0); forn(i,60) if (i) s[i]=s[i-1]+(a[i]<<i); for (int i=0; i<=60; ++i) f(1ll<<i); return mem[1ll<<60]; } #undef int
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...