Submission #306243

#TimeUsernameProblemLanguageResultExecution timeMemory
306243qpwoeirutPacking 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) { //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; if (i+1 == a.size() && add >= x) { a.push_back(0); } } //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; else { if (cur > 0) { ans += ans >> cur; } cur = 0; } } return ans; } /* 2 3 3 5 2 1 3 2 2 1 2 */

Compilation message (stderr)

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