제출 #669853

#제출 시각아이디문제언어결과실행 시간메모리
669853evenvalue비스킷 담기 (IOI20_biscuits)C++17
21 / 100
1088 ms50548 KiB
//#include "biscuits.h" #include <bits/stdc++.h> using namespace std; template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T>>; template<typename T> using max_heap = priority_queue<T, vector<T>, less<T>>; using int64 = long long; using ld = long double; constexpr int kInf = 1e9 + 10; constexpr int64 kInf64 = 1e15 + 10; constexpr int kMod = 1e9 + 7; constexpr int kBits = 60; void merge_biscuits(const int64 x, vector<int64> &biscuits) { while (biscuits.size() <= kBits) biscuits.push_back(0); for (int i = 0; i < kBits; i++) { const int64 carry = max(0LL, biscuits[i] - x) / 2; biscuits[i] -= 2 * carry; biscuits[i + 1] += carry; } } int64 count_tastiness(int64 x, vector<int64> biscuits) { merge_biscuits(x, biscuits); map<pair<int64, int>, int64> memo; memo[{0, kBits}] = 1; function<int64(int64, int)> dp = [&](const int64 n, const int i) -> int64 { if (memo[{n, i}] != 0) return memo[{n, i}]; if (biscuits[i] + n < x) return memo[{n, i}] = dp((biscuits[i] + n) / 2, i + 1); return memo[{n, i}] = dp((biscuits[i] + n) / 2, i + 1) + dp((biscuits[i] + n - x) / 2, i + 1); }; return dp(0, 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...