#include<bits/stdc++.h>
#include "biscuits.h"
using namespace std;
using ll = long long;
ll INF = 1e18;
ll count_tastiness(ll x, vector<ll> a) {
ll ans = 0, sum = 0;
for(int i=0;i<a.size();i++) sum += (1ll << i) * a[i];
ll mx = sum / x;
while((1ll << a.size()) < mx) a.push_back(0);
queue<ll> qu, qc, ql;
qu.push(0), qc.push(0), ql.push(0), ans++;
set<pair<ll, ll>> s;
while(!qu.empty()){
ll u = qu.front(), c = qc.front(), l = ql.front() / 2 + a[c]; qu.pop(), qc.pop(), ql.pop();
if(u + (1ll << c) > mx || s.count({u, c})) continue;
s.insert({u, c});
qu.push(u), qc.push(c + 1), ql.push(l);
if(l >= x) qu.push(u + (1ll << c)), qc.push(c + 1), ql.push(l - x), ans++;
}
return ans;
}
Compilation message
biscuits.cpp: In function 'll count_tastiness(ll, std::vector<long long int>)':
biscuits.cpp:10:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
10 | for(int i=0;i<a.size();i++) sum += (1ll << i) * a[i];
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
63 ms |
8184 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
65 ms |
4216 KB |
Output is correct |
5 |
Correct |
13 ms |
1408 KB |
Output is correct |
6 |
Correct |
228 ms |
8340 KB |
Output is correct |
7 |
Correct |
8 ms |
896 KB |
Output is correct |
8 |
Correct |
239 ms |
8436 KB |
Output is correct |
9 |
Correct |
22 ms |
1664 KB |
Output is correct |
10 |
Correct |
1 ms |
256 KB |
Output is correct |
11 |
Correct |
1 ms |
256 KB |
Output is correct |
12 |
Correct |
57 ms |
1792 KB |
Output is correct |
13 |
Correct |
24 ms |
948 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
8056 KB |
Output is correct |
2 |
Execution timed out |
1093 ms |
92380 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1098 ms |
121988 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1083 ms |
15900 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
63 ms |
8184 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
65 ms |
4216 KB |
Output is correct |
5 |
Correct |
13 ms |
1408 KB |
Output is correct |
6 |
Correct |
228 ms |
8340 KB |
Output is correct |
7 |
Correct |
8 ms |
896 KB |
Output is correct |
8 |
Correct |
239 ms |
8436 KB |
Output is correct |
9 |
Correct |
22 ms |
1664 KB |
Output is correct |
10 |
Correct |
1 ms |
256 KB |
Output is correct |
11 |
Correct |
1 ms |
256 KB |
Output is correct |
12 |
Correct |
57 ms |
1792 KB |
Output is correct |
13 |
Correct |
24 ms |
948 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
58 ms |
8056 KB |
Output is correct |
16 |
Execution timed out |
1093 ms |
92380 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |