Submission #601830

#TimeUsernameProblemLanguageResultExecution timeMemory
601830FatihSolakPacking Biscuits (IOI20_biscuits)C++17
0 / 100
1125 ms788448 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; long long count_tastiness(long long x, vector<long long> a){ int k = a.size(); vector<long long> pre = a; for(int i = 1;i<k;i++){ pre[i] = pre[i-1] + a[i] * (1<<i); } for(int i = 0;i<k;i++){ pre[i] /= x; //cout << i << " " << pre[i] << endl; } for(int i = k-2;i>=0;i--){ pre[i] = min(pre[i],pre[i+1]); } vector<long long> vals; vals.push_back(0); for(int i = 0;i<k;i++){ vector<long long> nwvals; for(auto u:vals){ if(u + (1<<i) <= pre[i]){ nwvals.push_back(u + (1<<i)); } else break; } for(auto u:nwvals){ vals.push_back(u); } } long long ans = vals.size(); /* long long ans = 0; for(int i = 0;i<=pre[k-1];i++){ bool ok = 1; for(int j = 0;j<k;j++){ if(pre[j] < (i & ((1<<(j+1))-1)) ){ ok = 0; } } ans += ok; }*/ return ans; }
#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...