#include "biscuits.h"
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define trav(a,v) for(auto a:v)
typedef long long int lld;
lld arr[100];
int k;
vector<lld> V;
vector<lld> NXT;
lld ans;
lld DP[100][30000];
lld X;
lld calc(int pos, int carry){
//cout<<pos<<" "<<carry<<endl;
if(pos==60){
return 1;
}
if(DP[pos][carry]!=-1)return DP[pos][carry];
DP[pos][carry]=calc(pos+1,(carry+arr[pos])/2);
if(carry+arr[pos]>=X){
DP[pos][carry]+=calc(pos+1,(carry+arr[pos]-X)/2);
}
return DP[pos][carry];
}
long long count_tastiness(long long x, std::vector<long long> a) {
rep(i,0,100)arr[i]=0;
V.clear();
NXT.clear();
k=a.size();
rep(i,0,k)arr[i]=a[i];
rep(i,0,60){
if(arr[i]>=2*x+1){
lld val=(arr[i]-2*x-1)/2;
arr[i+1]+=val;
arr[i]-=2*val;
}
while(arr[i]>=2*x+1){
arr[i]-=2;
arr[i+1]++;
}
}
rep(i,0,60){
rep(j,0,2*x+1){
DP[i][j]=-1;
}
}
V.push_back(0);
ans=0;
X=x;
return calc(0,0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
568 KB |
Output is correct |
3 |
Correct |
1 ms |
564 KB |
Output is correct |
4 |
Correct |
1 ms |
568 KB |
Output is correct |
5 |
Correct |
1 ms |
568 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
572 KB |
Output is correct |
9 |
Correct |
1 ms |
564 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
9956 KB |
Output is correct |
2 |
Correct |
14 ms |
8788 KB |
Output is correct |
3 |
Correct |
20 ms |
9464 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
568 KB |
Output is correct |
6 |
Correct |
1 ms |
572 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
46 ms |
9940 KB |
Output is correct |
9 |
Correct |
36 ms |
9940 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
2 ms |
692 KB |
Output is correct |
12 |
Correct |
8 ms |
1748 KB |
Output is correct |
13 |
Correct |
57 ms |
9820 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
22 ms |
30468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |