# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
335530 | aanastasov | 비스킷 담기 (IOI20_biscuits) | C++17 | 97 ms | 1028 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "biscuits.h"
#include <cassert>
typedef long long int64_t;
int64_t count_tastiness(int64_t x, std::vector<int64_t> a) {
while (a.size() < 62) a.push_back(0);
int64_t extra = 0;
auto ways = std::vector<int64_t>{1};
for (int64_t i = 0; i < a.size(); ++i) {
if (a[i] + (extra >> i) >= x) {
extra += (1LL << i) * a[i];
extra -= (1LL << i) * x;
assert(extra >= 0);
ways.push_back(ways.back() * 2);
} else {
auto counts = std::vector<int64_t>(a.begin(), a.end());
int64_t upper_bound = 0;
for (int64_t j = i; j >= 0; --j) {
int64_t available = 0;
for (int64_t jj = 0; jj < j + 1; ++jj)
available += counts[jj] * (1LL << jj);
if ((available >> j) < x)
continue;
int64_t needed = x;
for (int64_t jj = j; jj >= 0; --jj) {
int64_t am = std::min(needed, counts[jj]);
counts[jj] -= am;
needed = (needed - am) * 2;
}
upper_bound |= 1LL << j;
}
int64_t res = 0;
upper_bound++;
for (int64_t j = 0; j < i + 1; ++j)
if ((upper_bound & (1LL << j)) > 0)
res += ways[j];
ways.push_back(res);
extra = 0;
}
}
return ways.back();
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |