Submission #308376

# Submission time Handle Problem Language Result Execution time Memory
308376 2020-10-01T01:47:17 Z crackersamdjam Packing Biscuits (IOI20_biscuits) C++17
0 / 100
2 ms 384 KB
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define gc getchar()
#define pc(x) putchar(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=char(n%10+48);n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

#ifndef ONLINE_JUDGE
template<typename T>
void pr(T a){std::cerr<<a<<std::endl;}
template<typename T,typename... Args>
void pr(T a, Args... args) {std::cerr<<a<<' ',pr(args...);}
#else
template<typename... Args>
void pr(Args... args){}
#endif

using namespace std;
using ll = long long;

#include <ext/pb_ds/assoc_container.hpp>
__gnu_pbds::gp_hash_table<ll, ll> dp;

ll x;
vector<ll> a, sum;

ll go(ll v){
	if(v < 0)
		return 0;
	if(v == 0)
		return 1;
	if(dp.find(v) != dp.end())
		return dp[v];
	int i = __lg(v);
	dp[v] = go(v-(1LL<<i)) + go(min(v, sum[i]/x)-(1LL<<i));
	// pr(v, dp[v]);
	return dp[v];
}

ll count_tastiness(ll _x, vector<ll> _a){
	a = _a, x = _x;
	while(size(a) < 60)
		a.emplace_back(0);
	int n = size(a);
	sum.resize(n);
	for(int i = 0; i < n; i++){
		sum[i] = (1LL<<i)*a[i];
		if(i) sum[i] += sum[i-1];
	}
	return go((1LL<<60)-1);
}

#ifdef LOCAL
int main(){
	print(count_tastiness(3, {5, 2, 1}));
}
#endif
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -