Submission #306034

# Submission time Handle Problem Language Result Execution time Memory
306034 2020-09-24T10:05:48 Z eriksuenderhauf Packing Biscuits (IOI20_biscuits) C++17
21 / 100
1000 ms 15896 KB
#pragma GCC optimize("O3")
#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz(x) (int)(x).size()

unordered_map<ll,ll> dp[65];

void dfs(int d, ll p, ll& ret, ll x, vector<ll>& a) {
  if (d > 60 || (d >= sz(a) && p < x))
    return;
  p = p / 2 + (d < sz(a) ? a[d] : 0);
  if (dp[d].count(p)) {
    ret += dp[d][p];
    return;
  }
  ll t = ret;
  dfs(d + 1, p, ret, x, a);
  if (p >= x) {
    ret++;
    dfs(d + 1, p - x, ret, x, a);
  }
  dp[d][p] = ret - t;
}

ll count_tastiness(ll x, vector<ll> a) {
  int k = sz(a);
  for (int i = 0; i <= 60; i++)
    dp[i].clear();
  ll ret = 1;
  dfs(0, 0, ret, x, a);
  return ret;
}

Compilation message

biscuits.cpp: In function 'll count_tastiness(ll, std::vector<long long int>)':
biscuits.cpp:28:7: warning: unused variable 'k' [-Wunused-variable]
   28 |   int k = sz(a);
      |       ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 92 ms 14588 KB Output is correct
2 Correct 150 ms 7940 KB Output is correct
3 Correct 267 ms 13000 KB Output is correct
4 Correct 1 ms 360 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 911 ms 15736 KB Output is correct
9 Correct 507 ms 10744 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 7 ms 640 KB Output is correct
12 Correct 83 ms 2728 KB Output is correct
13 Execution timed out 1006 ms 15808 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 15896 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 92 ms 14588 KB Output is correct
25 Correct 150 ms 7940 KB Output is correct
26 Correct 267 ms 13000 KB Output is correct
27 Correct 1 ms 360 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 911 ms 15736 KB Output is correct
32 Correct 507 ms 10744 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Correct 7 ms 640 KB Output is correct
35 Correct 83 ms 2728 KB Output is correct
36 Execution timed out 1006 ms 15808 KB Time limit exceeded