# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
233985 | rupav | Split the sequence (APIO14_sequence) | C++14 | 2087 ms | 8960 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;
/// given an array of n integers, you have to maximize reward by doing k splits. Each split gives a reward of product of sums of left and right bounded subarray
vector<vector<ll>> dp;
vector<ll> a;
vector<ll> pref;
ll recurse(int st, int n, int k, ll psum){
ll &z = dp[st][k];
if(~z) return z;
if(!k) return z = 0ll;
ll p1, p2;
z = 0ll;
for(int i=st+1; i <= n - k; ++i){
p1 = pref[i - 1] - psum;
ll temp = recurse(i, n, k - 1, p1 + psum);
p2 = pref[n - 1] - pref[i - 1];
z = max(z, temp + p1*p2);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |