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 <cassert>
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
#define ll long long
template <typename T> void print(T elem) {cout << elem << " ";}
template <typename T> void print(vector<T> &v) {for(auto elem: v) print(elem); cout << endl;}
void arrange(ll x, vector<ll> &a) {
int k=a.size();
for(int i=0; i<k-1; i++)
if (a[i] > x+1) {
ll excess = (a[i]-x)/2;
a[i] -= 2*excess;
a[i+1] += excess;
}
return;
}
int possible(ll n, ll x, vector<ll> &a) {
// cout << "n:" << n << endl;
int k = a.size();
ll m = n;
for(int i=0; i<k && m>0; i++) {
bool one = m%2; m >>= 1;
if (one) {if (a[i]<x) return 0;}
else if (i<k-1) {a[i+1] += a[i]/2; a[i]=0;}
// cout <<"a: "; print(a);
}
if (m>0) return 0;
else {return 1;}
}
ll count_tastiness(ll x, std::vector<ll> a) {
arrange(x,a);
// print(a);
ll cnt = 0;
for(int i=0; i<=100'000; i++) {
vector<ll> b = a;
cnt += possible(i,x,b);
}
return cnt;
}
# | 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... |