Submission #780858

#TimeUsernameProblemLanguageResultExecution timeMemory
780858JosiaPacking Biscuits (IOI20_biscuits)C++17
0 / 100
1 ms340 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; #define int long long long long count_tastiness(long long x, std::vector<long long> a) { vector<int> b(100, 0); int carry = 0; for (int i = 0; i<b.size(); i++) { carry /= 2; int here = carry+(i<a.size()?a[i]:0); if (here == 0) continue; if (here%2==0) { b[i] = 2; carry = here - 2; } else { b[i] = 1; carry = here - 1; } } // for (int i: b) cerr << i << " "; // cerr << "\n"; int res = 1; bool cont = 1; int lastCont = 0; int addup = 0; for (int i=0; i<62; i++) { if (!b[i]) {cont = 0; lastCont = 0; continue;} if (!cont) { res += addup; addup = 0; } if (cont) { res *= 2; if (b[i] == 2) addup += 1<<lastCont; lastCont ++; } cont = 1; } res += addup; return res; }

Compilation message (stderr)

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