Submission #586623

#TimeUsernameProblemLanguageResultExecution timeMemory
586623Valaki2Packing Biscuits (IOI20_biscuits)C++14
0 / 100
1083 ms340 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back const int maxbits = 60; int po[maxbits]; void init() { po[0] = 1; for(int i = 1; i < maxbits; i++) { po[i] = 2 * po[i - 1]; } } bool good(int y, int x, vector<int> a) { int n = (int) a.size(); for(int z = 0; z < x; z++) { int cnt = y; for(int i = n - 1; i >= 0; i--) { while(cnt - po[i] >= 0 && a[i]) { a[i]--; cnt -= po[i]; } } if(cnt > 0) { return false; } } return true; } int count_tastiness(int x, vector<int> a) { init(); int ans = 0; int max_i = 0; for(int i = 0; i < (int) a.size(); i++) { max_i += a[i] * po[i]; } max_i /= x; for(int i = 0; i <= max_i; i++) { if(good(i, x, a)) { //cout << i << "+\n"; ans++; } else { //cout << i << "-\n"; } } 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...