Submission #63533

# Submission time Handle Problem Language Result Execution time Memory
63533 2018-08-02T05:54:50 Z Just_Solve_The_Problem Homecoming (BOI18_homecoming) C++11
0 / 100
1000 ms 12552 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 - 2; 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, 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 1073 ms 12552 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 -