#include "biscuits.h"
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<limits.h>
#include <cassert>
#include <cstdint>
#include<cmath>
#include<set>
#include<algorithm>
#include <iomanip>
#include<numeric> //gcd(a,b)
#include<bitset>
using namespace std;
#define ll long long
#define f first
#define endl "\n"
#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define vi vector<int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-loops")
using namespace std;
#define int long long
#define double long double
int lg=60;
long long count_tastiness(long long x, vector<ll>v) {
int sum;
if(x==1&&0){
int k=v.size();
for(int i=0;i<k;i++){
if(v[i]==0)continue;
if(v[i]%2)v[i+1]+=(v[i]/2),v[i]=1;
else v[i+1]+=((v[i]-2)/2),v[i]=2;//spread
}
int idk=60+k;
vector<vector<int>>dp(k+65,vector<int>(idk+5,0));
dp[0][0]=1;
for(int i=0;i<=k+60;i++){
if(i<v.size()){
for(int j=idk;j>=v[i];j--)dp[i][j]=dp[i][j-v[i]];//shifting
for(int j=v[i]-1;j>=0;j--)dp[i][j]=0;
}
for(int j=idk;j>=0;j--){
if(j-x>=0)dp[i+1][(j-1)/2]+=dp[i][j];
dp[i+1][(j/2)]+=dp[i][j];
}
}
sum=0;//not using anything
for(int i=0;i<idk;i++)sum+=dp[k+61][i];
return sum;
}
else{
int k=v.size();
sum=0;
for(auto i:v)sum+=i;
if(sum>100000)return 0;
vector<vector<int>>dp(k+65,vector<int>(sum+5,0));
dp[0][0]=1;
for(int i=0;i<=k+60;i++){
if(i<v.size()){
for(int j=sum;j>=v[i];j--)dp[i][j]=dp[i][j-v[i]];//shifting
for(int j=v[i]-1;j>=0;j--)dp[i][j]=0;
}
for(int j=sum;j>=0;j--){
if(j-x>=0)dp[i+1][(j-x)/2]+=dp[i][j];//use x
dp[i+1][(j/2)]+=dp[i][j];//
}
}
int sum=0;//not using anything
for(int i=0;i<=sum;i++)sum+=dp[k+61][i];
return sum;
}
}
/*
int32_t main(){
int x,k;cin>>x>>k;
vector<int>in(k);
for(int i=0;i<k;i++)cin>>in[i];
cout<<count_tastiness(x,in)<<'\n';
}*/
Compilation message
biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:52:8: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | if(i<v.size()){
| ~^~~~~~~~~
biscuits.cpp:73:8: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
73 | if(i<v.size()){
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
52072 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
59 ms |
35192 KB |
Output is correct |
4 |
Runtime error |
12 ms |
18268 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
52068 KB |
Output is correct |
2 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
34 ms |
59984 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
352 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
52072 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
59 ms |
35192 KB |
Output is correct |
4 |
Runtime error |
12 ms |
18268 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |