Submission #805379

#TimeUsernameProblemLanguageResultExecution timeMemory
805379WLZ비스킷 담기 (IOI20_biscuits)C++17
0 / 100
1072 ms28724 KiB
#include "biscuits.h"
//#include "../../templates/debug.h"
#include <bits/stdc++.h>
using namespace std;

long long count_tastiness(long long x, std::vector<long long> a) {
  for (int i = 0; i < (int) a.size(); i++) {
    if (a[i] > x) {
      if (i == (int) a.size() - 1) a.push_back(0);
      a[i + 1] += (a[i] - x) / 2;
      a[i] -= (a[i] - x) / 2;
    }
  }
  int k = (int) a.size();
  long long ans = 0;
  vector< map<long long, long long> > dp(k + 1, map<long long, long long>());
  dp[0][0] = 1;
  for (int i = 0; i <= k; i++) {
    for (auto &[j, d] : dp[i]) {
      if (j >= 0) ans += d;
      long long extra = j;
      for (int t = i + 1; t <= k; t++) {
        extra = (extra / 2) - (extra < 0);
        extra += a[t - 1];
        dp[t][extra - x] += dp[i][j];
      }
    }
  }
  //debug(dp);
	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...