Submission #595070

#TimeUsernameProblemLanguageResultExecution timeMemory
595070MadokaMagicaFanPacking Biscuits (IOI20_biscuits)C++14
0 / 100
717 ms372 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using pi = pair<int,int>; #define all(v) v.begin(),v.end() #define sort(v) sort(all(v)) #define endl '\n' #define forn(i,n) for(int i = 0; i < n; ++i) #define forbe(i,b,e) for(int i = b; i < e; ++i) #define forr(i,n) for(int i = n-1; i >= 0; --i) #define sz(v) ((int)v.size()) #define pb push_back #define f first #define s second ll count_tastiness(ll x, vector<ll> a){ int k = sz(a); ll ans = 0; while (sz(a) < 64) a.pb(0); forn(j,sz(a)-1) { if (a[j] < x) continue; ll delta = a[j]-x; a[j] -= delta; if (delta&1) ++a[j]; a[j+1] += (delta)/2l; } // forn(j, k) // cout << a[j] << ' '; // cout << endl; if (x == 1) { vector<ll> dp(65, 0); int lz = -1; int l2 = -2; dp[0] = 1; ans = 1; forn(j, sz(a)) { if (a[j]) { ans += dp[j]; dp[j+1] = ans; if (a[j] > 1) l2=j; continue; } if (l2 < lz) { dp[j+1] = ans; lz = j; continue; } ans += dp[l2]; dp[j+1] = ans; lz = j; } return ans; } int mval = 100000; ll rem; int t; forbe(i,0, mval+4) { ++ans; rem = 0; t = 1; forn(j, 25) { rem = (rem/2l); if (j < k) rem += a[j]; // cout << i << ' ' << j << ' ' << rem << endl; if ((i&(1<<j)) == 0) continue; // cout << i << endl; if (rem < x) { t = 0; --ans; // cout << i << endl; break; } rem -= x; } // if (t) // cout << i << endl; } return ans; } #ifdef ONPC void solve() { int k, x; cin >> k >> x; vector<ll> a(k); forn(i,k) cin >> a[i]; cout << count_tastiness(x,a) << endl; } int main() { freopen("in", "r", stdin); // ios_base::sync_with_stdio(0);cin.tie(0); solve(); } #endif

Compilation message (stderr)

biscuits.cpp: In function 'll count_tastiness(ll, std::vector<long long int>)':
biscuits.cpp:75:9: warning: variable 't' set but not used [-Wunused-but-set-variable]
   75 |     int t;
      |         ^
#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...