(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #305016

#TimeUsernameProblemLanguageResultExecution timeMemory
305016arnold518Packing Biscuits (IOI20_biscuits)C++14
100 / 100
35 ms1024 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; ll X, A[100], P[100]; ll dp[100][100]; ll solve(int bit, int con) { if(bit==-1) return 1; ll &ret=dp[bit][con]; if(ret!=-1) return ret; ll t=P[con]&((1ll<<(bit+1))-1); if(t>P[bit]) t=P[bit], con=bit; ret=0; if((1ll<<bit)>t) { ret+=solve(bit-1, con); } else { ret+=solve(bit-1, bit-1)+solve(bit-1, con); } //printf("%d %d : %lld\n", bit, con, ret); return ret; } ll count_tastiness(ll _X, vector<ll> _A) { X=_X; memset(A, 0, sizeof(A)); for(int i=0; i<_A.size(); i++) A[i]=_A[i]; for(int i=0; i<60; i++) P[i]=(1ll<<i)*A[i]; for(int i=1; i<60; i++) P[i]+=P[i-1]; for(int i=0; i<60; i++) P[i]/=X; for(int i=0; i<60; i++) P[i]=min(P[i], (1ll<<(i+1))-1); //for(int i=0; i<60; i++) printf("%d ", P[i]); printf("\n"); memset(dp, -1, sizeof(dp)); return solve(59, 59); }

Compilation message (stderr)

biscuits.cpp: In function 'll count_tastiness(ll, std::vector<long long int>)':
biscuits.cpp:42:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |  for(int i=0; i<_A.size(); i++) A[i]=_A[i];
      |               ~^~~~~~~~~~
#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...