Submission #394856

#TimeUsernameProblemLanguageResultExecution timeMemory
394856rocks03Packing 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 = 1;
    rep(y, 1, 100000+1){
        ll x = X;
        vector<ll> a = A;
        bool ok = true;
        per(bit, 30, 0){
            if(!(y >> bit & 1)) continue;
            x = X;
            per(i, SZ(a) - 1, 0){
                if(i > bit) continue;
                int debug = a[i];
                ll sub = min(x, a[i] / (1ll << (bit - i)));
                x -= sub;
                a[i] -= sub * (1ll << (bit - i));
                if(x == 0) break;
            }
            if(x != 0){
                ok = false;
                break;
            }
        }
        ans += (ok == true);
    }
    return ans;
}

Compilation message (stderr)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:29:21: warning: unused variable 'debug' [-Wunused-variable]
   29 |                 int debug = a[i];
      |                     ^~~~~
#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...