제출 #310680

#제출 시각아이디문제언어결과실행 시간메모리
310680apostoldaniel854비스킷 담기 (IOI20_biscuits)C++14
21 / 100
38 ms888 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back using ll = long long; const int K = 60; const ll INF = 1e18; bool check (ll x, ll p) { for (int i = 1; i <= p; i++) { x *= 2; if (x >= INF) return false; } return true; } ll count_tastiness (ll x, vector <ll> a) { a.resize (K); vector <ll> sum (1 + K); vector <ll> dp (1 + K); for (int i = 0; i < K; i++) sum[i + 1] = sum[i] + (a[i] << i); dp[K] = 1; for (int i = K; i > 0; i--) { ll lb = sum[i], rb = sum[i]; for (int j = i - 1; j >= 0; j--) { if (check (x, j)) { if (lb >= (x << j)) lb -= (x << j); if (rb >= sum[j]) { if (lb <= rb) dp[j] += dp[i] * (1 + (rb - max (lb, sum[j])) / (x << j)); rb -= (1 + (rb - sum[j]) / (x << j)) * (x << j); } } } } return dp[0]; } /** int main () { int n; ll x; cin >> n >> x; vector <ll> v; for (int i = 1; i <= n; i++) { ll val; cin >> val; v.pb (val); } cout << count_tastiness (x, v) << "\n"; return 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...