제출 #1203832

#제출 시각아이디문제언어결과실행 시간메모리
1203832LucaLucaM비스킷 담기 (IOI20_biscuits)C++20
9 / 100
1095 ms328 KiB
#include "biscuits.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>

#define debug(x) #x << " = " << x << '\n'
using ll = long long;

ll count_tastiness(ll X, std::vector<ll> a) {
  while ((int) a.size() < 60) {
    a.push_back(0);
  }

  ll S = 0;
  for (int i = 0; i < 60; i++) {
    S += (ll) (1LL << i) * a[i];
  }

  int ret = 0;
  for (ll y = 0; y <= S; y++) {
    ll sum = 0;
    bool ok = true;
    for (int bit = 0; bit < 60 && ok; bit++) {
      sum /= 2;
      sum += a[bit];
      if (y >> bit & 1LL) {
        if (sum >= X) {
          sum -= X;
        } else {
          ok = false;
        }
      }
    }
    if (ok) {
      ret++;
    }
  }
  return ret;
}

#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...