제출 #923903

#제출 시각아이디문제언어결과실행 시간메모리
923903winter0101비스킷 담기 (IOI20_biscuits)C++14
100 / 100
762 ms1640 KiB
#include<bits/stdc++.h> #include "biscuits.h" using namespace std; #define all(fl) fl.begin(),fl.end() #define pb push_back #define fi first #define se second #define for1(i,j,k) for(int i=j;i<=k;i++) #define for2(i,j,k) for(int i=j;i>=k;i--) #define for3(i,j,k,l) for(int i=j;i<=k;i+=l) #define lb lower_bound #define ub upper_bound #define sz(a) (int)a.size() #define pii pair<int,int> #define pli pair<long long,int> #define gcd __gcd #define lcm(x,y) x*y/__gcd(x,y) long long mx[61]; map<long long,long long>f[61]; //k hieu sao ac ??? long long cal(long long val,int bit){ if (bit==0){ return f[bit][val]=min(val,mx[bit])+1; } if (f[bit].find(val)!=f[bit].end())return f[bit][val]; long long ans=cal(val,bit-1); if (val>=(1ll<<bit)&&mx[bit]>=(1ll<<bit)){ ans+=cal(min(val-(1ll<<bit),mx[bit]-(1ll<<bit)),bit-1); } return f[bit][val]=ans; } long long count_tastiness(long long x, std::vector<long long> a) { while (sz(a)<60)a.pb(0); int n=sz(a); long long sum=0; for1(i,0,n-1){ sum+=(1ll<<i)*a[i]; mx[i]=min(sum/x,(1ll<<(i+1))-1); f[i].clear(); } return cal(mx[59],59); }
#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...