Submission #586626

# Submission time Handle Problem Language Result Execution time Memory
586626 2022-06-30T13:08:09 Z Valaki2 Packing Biscuits (IOI20_biscuits) C++14
0 / 100
1000 ms 340 KB
#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back

const int maxbits = 60;

int po[maxbits];

void init() {
    po[0] = 1;
    for(int i = 1; i < maxbits; i++) {
        po[i] = 2 * po[i - 1];
    }
}

bool good(int y, int x, vector<int> a) {
    int n = (int) a.size();
    for(int z = 0; z < x; z++) {
        int cnt = y;
        for(int i = n - 1; i >= 0; i--) {
            while(cnt - po[i] >= 0 && a[i]) {
                a[i]--;
                cnt -= po[i];
            }
        }
        if(cnt > 0) {
            return false;
        }
    }
    return true;
}

int count_tastiness(int x, vector<int> a) {
    init();
    int ans = 0;
    int max_i = 0;
    for(int i = 0; i < (int) a.size(); i++) {
        max_i += a[i] * po[i];
    }
    max_i /= x;
    if(max_i == 0) {
        return 1;
    }
    for(int i = 0; i <= max_i; i++) {
        if(good(i, x, a)) {
            //cout << i << "+\n";
            ans++;
        } else {
            //cout << i << "-\n";
        }
    }
	return ans;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1078 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -