#include <bits/stdc++.h>
#include "biscuits.h"
using namespace std;
#define int long long
#define SZ(x) ((int)(x).size())
#define all(x) begin(x), end(x)
bool chk(int v, int x, vector<int> cnt) {
for(int i = 0; i < x; i++) {
int val = v;
for(int j = SZ(cnt) - 1; j >= 0; j--) {
int need = min(cnt[j], val / (1LL << j));
cnt[j] -= need; val -= (1ll << j) * need;
}
if(val) return false;
}
return true;
}
int count_tastiness(int x, vector<int> a) {
int k = a.size();
int sum = 0;
for(int i = 0; i < k; i++) {
sum = sum + (1LL << i) * a[i];
}
int ret = 1;
if(x == 1) {
for(int i = k - 1; i > 0; i--) {
if(a[i - 1] >= 2) {
a[i - 1] = a[i - 1] + a[i] * 2LL;
a[i] = 0;
}
}
for(int i = 0; i < k; i++) {
ret = ret * (a[i] + 1LL);
}
}
else {
for(int i = 1; i * x <= sum; i++) {
if(chk(i, x, a)) ret++;
}
}
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
12 ms |
256 KB |
Output is correct |
5 |
Correct |
3 ms |
256 KB |
Output is correct |
6 |
Correct |
46 ms |
376 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
45 ms |
256 KB |
Output is correct |
9 |
Correct |
3 ms |
256 KB |
Output is correct |
10 |
Correct |
9 ms |
256 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
240 ms |
256 KB |
Output is correct |
13 |
Correct |
210 ms |
256 KB |
Output is correct |
14 |
Correct |
201 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
1 ms |
256 KB |
Output is correct |
9 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1093 ms |
256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1092 ms |
384 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
12 ms |
256 KB |
Output is correct |
5 |
Correct |
3 ms |
256 KB |
Output is correct |
6 |
Correct |
46 ms |
376 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
45 ms |
256 KB |
Output is correct |
9 |
Correct |
3 ms |
256 KB |
Output is correct |
10 |
Correct |
9 ms |
256 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
240 ms |
256 KB |
Output is correct |
13 |
Correct |
210 ms |
256 KB |
Output is correct |
14 |
Correct |
201 ms |
376 KB |
Output is correct |
15 |
Correct |
1 ms |
256 KB |
Output is correct |
16 |
Correct |
0 ms |
256 KB |
Output is correct |
17 |
Correct |
1 ms |
256 KB |
Output is correct |
18 |
Correct |
1 ms |
256 KB |
Output is correct |
19 |
Correct |
1 ms |
256 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
256 KB |
Output is correct |
22 |
Correct |
1 ms |
256 KB |
Output is correct |
23 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |