Submission #479996

#TimeUsernameProblemLanguageResultExecution timeMemory
479996stefantagaPacking Biscuits (IOI20_biscuits)C++14
0 / 100
1 ms332 KiB
#include "biscuits.h" #include <cassert> #include <cstdio> using namespace std; long long sum=0,cop[65],din[65]; long long brut(long long x,std::vector <long long> a ) { int k=a.size(); long long p=1,suma=0,lim,t,ok1; for (int i=0;i<k;i++) { suma=suma+p*a[i]; p=p*2; } long long lim2=suma/x,sum1=0; for (lim=0;lim<=lim2;lim++) { for (t=0;t<k;t++) { cop[t]=a[t]; } p=1; ok1=1; for (t=0;t<k;t++) { if ((lim&p)!=0) { cop[t]=cop[t]-x; if (cop[t]<0) { ok1=0; break; } } cop[t+1]+=(cop[t]/2); p=p*2; } sum1=sum1+ok1; } return sum1; } long long count_tastiness(long long x, std::vector<long long> a) { int k=a.size(); long long p=1,suma=0,lim,t,ok1,nr=0,i,j; for (i=0;i<k;i++) { cop[i]=a[i]; } for (i=k;i<=60;i++) { cop[i]=0; } suma=1; for (i=0;i<=60;i++) { if (cop[i]>=3) { nr=cop[i]-1; long long ceau=nr/2; cop[i+1]+=ceau; cop[i]=cop[i]-ceau*2; } } p=1; long long acum=0; for (i=0;i<=60;i++) { if (cop[i]!=0) { acum+=p*cop[i]; } else { suma=suma*(acum+1); acum=0; } p=p*2; } return suma; } #ifdef HOME int main() { int q; assert(scanf("%d", &q) == 1); vector<int> k(q); vector<long long> x(q); vector<vector<long long>> a(q); vector<long long> results(q),results2(q); for (int t = 0; t < q; t++) { assert(scanf("%d%lld", &k[t], &x[t]) == 2); a[t] = vector<long long>(k[t]); for (int i = 0; i < k[t]; i++) { assert(scanf("%lld", &a[t][i]) == 1); } } fclose(stdin); for (int t = 0; t < q; t++) { results2[t]= brut(x[t],a[t]); results[t] = count_tastiness(x[t], a[t]); } for (int t = 0; t < q; t++) { printf("%lld\n", results[t]); } for (int t = 0; t < q; t++) { printf("%lld\n", results2[t]); } fclose(stdout); return 0; } #endif // HOME

Compilation message (stderr)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:45:26: warning: unused variable 'lim' [-Wunused-variable]
   45 |     long long p=1,suma=0,lim,t,ok1,nr=0,i,j;
      |                          ^~~
biscuits.cpp:45:30: warning: unused variable 't' [-Wunused-variable]
   45 |     long long p=1,suma=0,lim,t,ok1,nr=0,i,j;
      |                              ^
biscuits.cpp:45:32: warning: unused variable 'ok1' [-Wunused-variable]
   45 |     long long p=1,suma=0,lim,t,ok1,nr=0,i,j;
      |                                ^~~
biscuits.cpp:45:43: warning: unused variable 'j' [-Wunused-variable]
   45 |     long long p=1,suma=0,lim,t,ok1,nr=0,i,j;
      |                                           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...