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

#TimeUsernameProblemLanguageResultExecution timeMemory
816819kevinsogoPacking Biscuits (IOI20_biscuits)C++17
100 / 100
52 ms860 KiB
#include <bits/stdc++.h> using namespace std; #include "biscuits.h" using ll = long long; ll count_tastiness(ll x, vector<ll> a) { a.resize(62); vector<ll> t = {0LL}; for (int i = 0; i < a.size(); i++) t.push_back(t.back() + (a[i] << i)); for (int i = 0; i < t.size(); i++) t[i] = min(t[i] / x, (1LL << i) - 1); vector<unordered_map<ll,ll>> posm(t.size()); function<ll(ll,int)> poss = [&](ll s, int k) { if ((s = min(s, t[k])) < 0) return 0LL; if (k == 0) return 1LL; if (auto f = posm[k].find(s); f != posm[k].end()) return f->second; return posm[k][s] = poss(s, k - 1) + poss(s - (1LL << k - 1), k - 1); }; return poss(t.back(), t.size() - 1); }

Compilation message (stderr)

biscuits.cpp: In function 'll count_tastiness(ll, std::vector<long long int>)':
biscuits.cpp:9:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |  for (int i = 0; i < a.size(); i++) t.push_back(t.back() + (a[i] << i));
      |                  ~~^~~~~~~~~~
biscuits.cpp:10:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |  for (int i = 0; i < t.size(); i++) t[i] = min(t[i] / x, (1LL << i) - 1);
      |                  ~~^~~~~~~~~~
biscuits.cpp: In lambda function:
biscuits.cpp:16:59: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   16 |   return posm[k][s] = poss(s, k - 1) + poss(s - (1LL << k - 1), k - 1);
      |                                                         ~~^~~
#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...