This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include "biscuits.h"
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define rrep(i,a,b) for(int i=int(a);i>int(b);i--)
#define trav(a,v) for(auto& a: v)
#define sz(v) v.size()
#define all(v) v.begin(),v.end()
#define vi vector<int>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const long long inf = 2e9;
using namespace std;
long long count_tastiness(long long x, std::vector<long long> a) {
ll ans = 1;
vector<ll> cur;
rep(i, 1, 1e5 + 1) {
cur = a;
bool done = true;
rep(j, 0, 18) {
if (!((1 << j) & i))continue;
if (j >= a.size()) {
done = false;
break;
}
rrep(o, j - 1, -1) {
if (cur[j] >= x)break;
if((1<<o)&i)cur[j] += (cur[o] - x) / (1 << (j - o));
else cur[j] += (cur[o]) / (1 << (j - o));
}
if (cur[j] < x) {
done = false;
break;
}
}
ans += done;
}
return ans;
}
//int main() {
// ll q;
// cin >> q;
// rep(i, 0, q) {
// ll n, x;
// cin >> n >> x;
// vector<ll> v(n);
// rep(i, 0, n)cin >> v[i];
// cout << count_tastiness(x, v) << endl;
// }
//}
Compilation message (stderr)
biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:27:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
27 | if (j >= a.size()) {
| ~~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |