# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
135017 | wilwxk | Split the sequence (APIO14_sequence) | C++14 | 0 ms | 0 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;
typedef long long ll;
const int MAXN=1e5+5;
const ll INF=1e18;
ll dp[MAXN][205];
int opt[MAXN][205];
ll soma[MAXN];
ll v[MAXN];
int n, x;
struct reta {
ll a, b, id;
};
vector<reta> st[300];
void init() {
dp[0][0]=0; for(int i=1; i<=x; i++) dp[0][i]=-INF;
for(int i=1; i<=n; i++) dp[i][0]=-INF;
}
int cmp(reta a, reta b, reta c) {
double aa=(a.b-b.b); aa/=(b.a-a.a);
double bb=(c.b-b.b); aa/=(b.a-c.a);
if(aa==bb) return 0;
if(aa<bb) return 1;
return -1;
}
void update(int ind, int k) {
}
ll query(ll val) {
}
int main() {
scanf("%d %d", &n, &x); x++;
for(int i=1; i<=n; i++) scanf("%lld", &v[i]);
for(int i=1; i<=n; i++) soma[i]=soma[i-1], soma[i]+=v[i];
init();
for(int i=1; i<=n; i++) {
for(int j=1; j<=x; j++) {
auto cur=query(soma[i], j-1);
dp[i][j]=;
opt[i][j]=;
update(i, j);
// printf("%d %d >> %lld // %d\n", i, j, dp[i][j], opt[i][j]);
}
}
printf("%lld\n", dp[n][x]);
vector<int> respf;
int ind=n; int k=x;
while(respf.size()<x-1) {
respf.push_back(opt[ind][k]);
ind=opt[ind][k--];
}
reverse(respf.begin(), respf.end());
for(auto cur : respf) printf("%d ", cur);
}