(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 #412393

#TimeUsernameProblemLanguageResultExecution timeMemory
412393achibasadzishviliPacking Biscuits (IOI20_biscuits)C++14
100 / 100
90 ms1332 KiB
#include "biscuits.h" #include<bits/stdc++.h> #define ll long long #define f first #define s second #define pb push_back using namespace std; ll pre[505],n; map<ll,ll>got; ll solve(ll k){ if(k == 1)return 1; if(k <= 0)return 0; if(got.count(k))return got[k]; ll ret = 0; ll pw = 1,t = 0; while(2 * pw < k){ t++; pw *= 2; } got[k] = solve(pw) + solve(min(k ,1 + pre[t] / n) - pw); return got[k]; } ll count_tastiness(ll x, vector<ll> a){ got.clear(); for(int i=0; i<=200; i++) pre[i] = 0; for(int i=0; i<a.size(); i++){ if(!i)pre[i] = a[i] * (1LL << i); else pre[i] = pre[i - 1] + a[i] * (1LL << i); } for(int i=a.size(); i<=200; i++) pre[i] = pre[i - 1]; n = x; return solve(pre[(int)a.size() - 1] + 1); }

Compilation message (stderr)

biscuits.cpp: In function 'long long int solve(long long int)':
biscuits.cpp:14:5: warning: unused variable 'ret' [-Wunused-variable]
   14 |  ll ret = 0;
      |     ^~~
biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:27:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |  for(int i=0; i<a.size(); 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...