Submission #805628

#TimeUsernameProblemLanguageResultExecution timeMemory
805628WLZ비스킷 담기 (IOI20_biscuits)C++17
33 / 100
1151 ms1608040 KiB
#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUG
#include "../../templates/debug.h"
#else
#define debug(...) 0
#endif

const int X = 130;

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 * 2;
    }
  }
  while ((int) a.size() < X) a.push_back(0);
  long long ans = 0;
  vector< vector< vector<long long> > > dp(X, vector< vector<long long> >(2, vector<long long>(2 * x + 5, 0)));
  dp[0][1][0] = 1;
  for (int i = 0; i < X - 1; i++) {
    for (int j = x; j < 2 * x + 5; j++) dp[i][1][j - x] += dp[i][0][j];
    for (int e = 0; e < 2; e++) {
      for (int j = 0; j < 2 * x + 5; j++) {
        //if (i < 5) debug(ans);
        if (e == 1) ans += dp[i][e][j];
        dp[i + 1][0][j / 2 + a[i]] += dp[i][e][j];
      }
    }
  }
  debug(dp);
  return ans;
}

Compilation message (stderr)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:8:20: warning: statement has no effect [-Wunused-value]
    8 | #define debug(...) 0
      |                    ^
biscuits.cpp:35:3: note: in expansion of macro 'debug'
   35 |   debug(dp);
      |   ^~~~~
#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...