Submission #394925

#TimeUsernameProblemLanguageResultExecution timeMemory
394925rocks03Packing Biscuits (IOI20_biscuits)C++14
21 / 100
1089 ms22444 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()); ll x; vector<ll> a; unordered_map<ll, ll> memo2; ll f2(ll n){ if(memo2.count(n)) return memo2[n]; ll& ans = memo2[n]; if(n < x) ans = 1; else ans = f2((n - x) / 2) + f2(n / 2); return ans; } map<pll, ll> memo; ll f(int ind, ll add){ if(memo.count({ind, add})){ return memo[{ind,add}]; } ll& ans = memo[{ind,add}]; if(ind >= SZ(a)){ ans = f2(add); return ans; } ll cur = a[ind] + add; ans = f(ind + 1, cur / 2); if(cur >= x){ cur -= x; ans += f(ind + 1, cur / 2); } return ans; } long long count_tastiness(long long X, vector<long long> A){ a = A, x = X; memo.clear(); memo2.clear(); return f(0, 0); }
#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...