제출 #1069463

#제출 시각아이디문제언어결과실행 시간메모리
1069463HD1비스킷 담기 (IOI20_biscuits)C++14
0 / 100
1066 ms348 KiB
#include "biscuits.h"
#include <iostream>
using namespace std;

long long count_tastiness(long long x, std::vector<long long> a) {
    int s = 0,k = a.size();
    for(int i = 0; i < k; i++) s += a[i] * (1<<i);
    int ans = 1;
    for(int i = 1; i <= s/x; i++){
        vector<long long> b = a;
        bool go = true;
        for(int j = 0; j < 20; j++){
            if(i&(1<<j)){
                for(int _ = 0; _ < x; _++){
                    int c = j, cant = 1;
                    if(c >= k){
                        go= false;
                        break;
                    }
                    while(c >= 0 && b[c] < cant){
                        cant -= b[c];
                        cant *= 2;
                        b[c] = 0;
                        c--;
                    } 
                    if(c==-1) {
                        go = false;
                        break;
                    }
                    b[c] -= cant;
                }
            }
        }
        if(go) {
            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...