# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
303778 | alex_velea | 비스킷 담기 (IOI20_biscuits) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <unordered_map>
using namespace std;
const int kMaxK = 127;
typedef long long int64;
#define DEBUG if(0)
long long count_tastiness(int64 x, std::vector<int64> a) {
a.resize(kMaxK, 0);
for (int i = 0; i + 1 < kMaxK; i += 1) {
if (a[i] > x) {
int64 carry = (a[i] - x) / 2;
a[i + 1] += carry;
a[i] -= carry * 2;
}
}
DEBUG {
for (int i = 0; i < 10; i += 1) {
cerr << a[i] << '\t';
}
cerr << '\n';
}
unordered_map<int64, int64> old = { {0, 1} };
int64 ans = 1;
for (int i = 0; i < kMaxK; i += 1) {
unordered_map<int64, int64> new_dp;
for (auto& itr : old) {
int64 carry = itr.first;
int64 num = itr.second;
if (carry + a[i] >= x) {
DEBUG cerr << "Add + for " << i << '\n';
ans += num;
new_dp[(carry + a[i] - x) / 2] += num;
}
new_dp[(carry + a[i]) / 2] += num;
}
old = new_dp;
}
return ans;
}