Submission #1028645

#TimeUsernameProblemLanguageResultExecution timeMemory
1028645NeroZeinPacking Biscuits (IOI20_biscuits)C++17
21 / 100
1095 ms63352 KiB
#include "biscuits.h"
#include <bits/stdc++.h>

using namespace std; 

long long x;
vector<long long> a;
map<pair<int, long long>, long long> dp;

long long bt(int b, long long c) {
  if (b == 60) {
    return 1; 
  }
  //if (c > 2 * x) {
    //c = 2 * x;
  //}
  if (dp.count({b, c})) {
    return dp[{b, c}];
  }
  long long& ret = dp[{b, c}];
  ret = bt(b + 1, c / 2 + (b + 1 < (int) a.size() ? a[b + 1] : 0));
  if (c >= x) {
    ret += bt(b + 1, (c - x) / 2 + (b + 1 < (int) a.size() ? a[b + 1] : 0));
  }
  return ret; 
}

long long count_tastiness(long long x_, vector<long long> a_) {
  x = x_;
  a = a_; 
  long long ans = bt(0, a[0]);
  dp.clear();
  return ans;
}
#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...