Submission #566797

#TimeUsernameProblemLanguageResultExecution timeMemory
5667972fat2codePacking Biscuits (IOI20_biscuits)C++17
12 / 100
2 ms340 KiB
#include "biscuits.h"
#include <bits/stdc++.h>
#define fr first
#define sc second
#define all(s) s.begin(), s.end()
#define int long long
using namespace std;

int ans, k;

int count_tastiness(int x, vector<int> a) {
    ans = 1LL;
    k = (int)a.size();
    for(int i=0;i<(int)a.size();i++){
        if(a[i] >= 3){
            if(i == a.size() - 1){
                a.push_back(0);
            }
            a[i + 1] += ( (a[i] - 1LL) / 2LL);
            if(a[i] % 2 == 1LL) a[i] = 1;
            else a[i]= 2;
        }
    }
    int j = 0;
    while(j < (int)a.size()){
        int curr = 0;
        int pos = j;
        while(j < (int)a.size() && a[j] != 0){
            curr = (curr + a[j] * (1LL << (j - pos)));
            ++j;
        }
        curr++;
        ans *= curr;
        j++;
    }
	return ans;
}

Compilation message (stderr)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:16:18: 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]
   16 |             if(i == a.size() - 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...