#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define mp make_pair
#define pb push_back
using namespace std;
int n, k;
vi arr;
ll dp[100000][2500][2];
ll f(int at, int segments, int taken){
if(at >= n)
return 0;
if(dp[at][segments][taken] != -1)
return dp[at][segments][taken];
ll best = 0;
best = max(best, arr[at] + f(at + 1, segments, 1));
if(taken == 0)
best = max(best, f(at + 1, segments, 0));
if(segments + 1 < k && taken == 1)
best = max(best, f(at + 1, segments + 1, 0));
return dp[at][segments][taken] = best;
}
int main(){
cin>>n>>k;
for(int i = 0; i < n; i++){
int a;
cin>>a;
arr.pb(a);
}
memset(dp, -1, sizeof(dp));
cout<<f(0, 0,0)<<endl;
}
Compilation message
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status