Submission #394847

#TimeUsernameProblemLanguageResultExecution timeMemory
394847rocks03Packing Biscuits (IOI20_biscuits)C++14
0 / 100
1093 ms332 KiB
//#pragma GCC target("avx2") //#pragma GCC optimization("O3") //#pragma GCC optimization("unroll-loops") #include<bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> #define ff first #define ss second #define pb push_back #define SZ(x) ((int)(x).size()) #define all(x) x.begin(), x.end() #define rep(i, a, b) for(int i = (a); i < (b); i++) #define per(i, a, b) for(int i = (a); i >= (b); i--) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); long long count_tastiness(long long X, vector<long long> a){ ll ans = 0; rep(y, 0, 100000+1){ ll x = X; int bt = 20; while(bt >= 0 && !(y >> bt & 1)) bt--; per(i, SZ(a) - 1, 0){ if(bt < i){ continue; } ll cur = a[i]; while(true){ ll sub = min(x, cur / (1ll << (bt - i))); x -= sub; cur -= sub * (1ll << (bt - i)); if(x == 0){ x = X; --bt; while(bt >= 0 && !(y >> bt & 1)) bt--; if(bt < i){ break; } } else break; } } if(bt < 0){ ans++; } } 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...