#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define popcount __builtin_popcount using namespace std; typedef long long int ll; typedef pair P; ll dp[3030][3030]; ll a[3030]; ll s[3030]; const ll INF=1e18; int main() { int n, k, m; cin>>n>>k>>m; for(int i=0; i>a[i]; s[i+1]=s[i]+a[i]; } for(int i=0; i<=n; i++) for(int j=0; j<=k; j++) dp[i][0]=-INF; dp[0][0]=0; for(int j=0; j v1(n+1), v2(n+1); for(int i=0; i<=n; i++){ v1[i]=dp[i][j]-s[i]; v2[i]=dp[i][j]+s[i]; } deque deq; deq.push_back(0); for(int i=1; i<=n; i++){ while(!deq.empty() && deq.front()