Submission #83174

# Submission time Handle Problem Language Result Execution time Memory
83174 2018-11-05T20:10:03 Z MrTEK Bali Sculptures (APIO15_sculpture) C++14
0 / 100
2 ms 468 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<int,int> ii;

const int N = 2e3 + 5;
const int M = 205;
const ll INF = 1e18;

ll a[N],ans,n,x,y,pre[N],dp[N][2];

ll get(int l,int r) {
  return pre[r] - pre[l - 1];
}

void f(int l,int r,int optl,int optr) {
  if (l > r || optl > optr)
    return;
  int mid = (l + r) / 2;
  int new_opt = mid;
  for (int i = max(mid,optl) ; i <= optr ; i++) {
    if (dp[mid][0] > (dp[i + 1][1] | get(mid, i))) {
      dp[mid][0] = (dp[i + 1][1] | get(mid,i));
      new_opt = i;
    }
  }
  f(l,mid - 1,new_opt,optr);
  f(mid + 1,r,optl,new_opt);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> n >> x >> y;
  for (int i = 1 ; i <= n ; i++) {
    cin >> a[i];
    pre[i] = pre[i - 1] + a[i];
  }
  for (int i = 1 ; i <= y ; i++) {
    for (int j = 1 ; j <= n ; j++) {
      dp[j][1] = dp[j][0];
      dp[j][0] = INF;
    }
    f(1,n,1,n);
    if (i >= x)
      ans = max(ans,dp[1][0]);
  }
  cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 448 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 448 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -