제출 #534322

#제출 시각아이디문제언어결과실행 시간메모리
534322benson1029비스킷 담기 (IOI20_biscuits)C++14
0 / 100
19 ms1168 KiB
#include "biscuits.h" #include<bits/stdc++.h> using namespace std; int k; long long X; vector<long long> pref; long long ans[65]; int logb2(long long x) { int cnt = 0; while(x>1) { cnt++; x/=2; } return cnt; } long long findans(long long x) { if(x<0) { return 0; } if(x==1) { return 1; } int LOG = logb2(x-1); int LOG1 = logb2(x); if(LOG != LOG1 && ans[LOG1]!=-1) { return ans[LOG1]; } long long v = findans(1LL<<LOG) + findans(min(x, 1+pref[LOG]/X) - (1LL<<LOG)); if(LOG != LOG1) { ans[LOG1] = v; } return v; } long long count_tastiness(long long x, std::vector<long long> a) { k = a.size(); X = x; pref.resize(61); a.resize(61); for(int i=0; i<=61; i++) ans[i] = -1; for(int i=k; i<61; i++) { a[i] = 0; } for(int i=0; i<61; i++) { pref[i] = (1LL<<i) * a[i]; if(i) pref[i] += pref[i-1]; } return findans(1LL<<61); }
#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...