Submission #1192264

#TimeUsernameProblemLanguageResultExecution timeMemory
1192264lucaskojimaBali Sculptures (APIO15_sculpture)C++17
16 / 100
1096 ms1604 KiB
#include "bits/stdc++.h"
#define sz(x) (int)size(x)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const char nl = '\n';
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;

int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0);

  int n, a, b; cin >> n >> a >> b;
  vector<int> y(n); for (auto &x : y) cin >> x;

  vector<ll> p(n); p[0] = y[0];
  for (int i = 1; i < n; i++)
    p[i] = p[i - 1] + y[i];

  int c = *max_element(all(y)) * n;
  vector dp(n, vector(b + 1, vector<bool>(c + 1)));

  for (int i = 0; i < n; i++)
    dp[i][1][p[i]] = true;

  for (int i = 0; i < n; i++)
    for (int k = 1; k < b; k++)
      for (int val = 0; val <= c; val++)
        for (int j = i + 1; j < n; j++)
          dp[j][k + 1][val | (p[j] - p[i])] = dp[j][k + 1][val | (p[j] - p[i])] | dp[i][k][val];

  int ans = INF;
  for (int k = a; k <= b; k++)
    for (int val = 0; val <= c; val++)
      if (dp[n - 1][k][val] == true)
        ans = min(ans, val);

  cout << ans << nl;
  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...