Submission #336220

# Submission time Handle Problem Language Result Execution time Memory
336220 2020-12-15T02:58:34 Z LifeHappen__ Bali Sculptures (APIO15_sculpture) C++14
0 / 100
38 ms 68224 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

const int N = 2005;
int n, A, B, a[N];
int dp[205][205][205], ma[205][205];
int s[N];

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);

  #define task "arrange"
  //freopen(task".inp", "r", stdin);
  //freopen(task".out", "w", stdout);

  cin >> n >> A >> B;
  for (int i = 1; i <= n; ++i)
    cin >> a[i];
  for (int i = 1; i <= n; ++i)
    s[i] = s[i - 1] + a[i];

  memset(dp, 0x3f, sizeof dp);
  memset(ma, 0x3f, sizeof ma);
  dp[0][0][0] = 0;
  ma[0][0] = 0;

  auto sum = [&](int l, int r) {return s[r] - s[l - 1];};

  //dp[i][j][k] to i have j group j + 1 group start at j

  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= B; ++j) {
      for (int k = 1; k <= i; ++k) {
        dp[i][j][k] = ma[k - 1][j - 1] | (sum(k, i));
        ma[i][j] = min(ma[i][j], dp[i][j][k]);
      }
    }
  }

  int ans = 1e18;
  for (int i = A; i <= B; ++i) {
    ans = min(ans, ma[n][i]);
  }

  cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 33 ms 68076 KB Output is correct
2 Incorrect 32 ms 68076 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 32 ms 68076 KB Output is correct
2 Incorrect 32 ms 68076 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 32 ms 68076 KB Output is correct
2 Incorrect 32 ms 68076 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 33 ms 68224 KB Output is correct
2 Incorrect 34 ms 68120 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 32 ms 68076 KB Output is correct
2 Incorrect 38 ms 68080 KB Output isn't correct
3 Halted 0 ms 0 KB -