Submission #306249

#TimeUsernameProblemLanguageResultExecution timeMemory
306249qpwoeirutPacking Biscuits (IOI20_biscuits)C++17
0 / 100
2 ms384 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; long long count_tastiness(long long x, std::vector<long long> a) { a.resize(128, 0); //cerr << "a: "; for (int i=0; i<a.size(); ++i) cerr << a[i] << ' '; cerr << endl; int add = 0; for (int i=0; i<a.size(); ++i) { a[i] += add; add = max(0LL, (a[i] - x) >> 1); a[i] -= add << 1; } //cerr << "a: "; for (int i=0; i<a.size(); ++i) cerr << a[i] << ' '; cerr << endl; ll ans = 1; for (int i=0; i<a.size(); ++i) { if (a[i] >= x) ans <<= 1; } //cerr << "base: " << ans << endl; int cur = 0; for (int i=0; i<a.size(); ++i) { if (a[i] > x) { ++cur; a[i+1] += a[i] >> 1; a[i] = 0; } else { if (cur > 0) { ans += ans >> cur; } cur = 0; } } return ans; } /* 2 3 3 5 2 1 3 2 2 1 2 1 5 1 0 1 1 1 2 1 4 1 1 5 2 9 1 5 1 0 0 0 1 0 1 1 1 128 */

Compilation message (stderr)

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