Submission #63529

# Submission time Handle Problem Language Result Execution time Memory
63529 2018-08-02T05:52:04 Z Just_Solve_The_Problem Homecoming (BOI18_homecoming) C++11
0 / 100
1000 ms 12564 KB
#include "homecoming.h"
#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int N = (int)2e6 + 7;

ll pref[N], dp[N];

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

ll solve(int n, int k, int a[], int b[]) {
  for (int i = 0; i < n + n - 1; i++) {
    pref[i] = ((i != 0) ? pref[i - 1] : 0) + b[i % n];
  }
  ll cost;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      cost = -get(max(j + k - 1, i), i + k - 1) + a[i];
      dp[i] = max(dp[i], dp[j] + cost);
    }
    dp[i] = max(dp[i], -get(i, i + k - 1) + a[i]);
  }

  for (int i = 1; i < n; i++) {
    dp[i] = max(dp[i], dp[i - 1]);
  }
  return dp[n - 1];
}
# 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 Execution timed out 1093 ms 12564 KB Time limit exceeded
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 -