제출 #831364

#제출 시각아이디문제언어결과실행 시간메모리
831364ALeonidou비스킷 담기 (IOI20_biscuits)C++17
9 / 100
1076 ms340 KiB
#include "biscuits.h"
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define F first
#define S second
#define sz(x) (ll)x.size()
#define MID ((l+r)/2)
#define pb push_back
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl;
#define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl;
#define dbg4(x,y,z,w) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<" "<<#w<<": "<<w<<endl;

typedef vector <ll> vi;
typedef pair<ll,ll> ii;
typedef vector <ii> vii;

#define M 100001

ll count_tastiness(ll x, vi a) {
    ll n = sz(a);
    vi tmp;
    ll ans = 1;
    for (ll y =1; y<=M; y++){   //y
        tmp = a;
        ll sum;
        ll f = -1;
        //dbg(y);
        do{
            f++;
            sum = 0;
            for (ll i = n-1; i>=0; i--){
                if (tmp[i] == 0) continue;
                ll val = (1<<i);
                ll d = (y - sum) / val;
                ll g = min(d, tmp[i]);
                //dbg4(sum, val,d,g);
                tmp[i] -= g;
                sum += g * val;
                if (sum == y) break;
            }
            //dbg(sum);
        }while (sum == y);
        
        if (f >= x) ans++;

        //dbg2(f,ans);
        //cout<<endl;
    }

	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...