# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
759763 | jay_jayjay | Feast (NOI19_feast) | C++14 | 132 ms | 262144 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.
// {{{1
extern "C" int __lsan_is_turned_off() { return 1; }
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <iostream>
#include <deque>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define infl 0x3f3f3f3f3f3f3f3f
#define ninf 0xbebebebe
#define ninfl 0xbebebebebebebebe
#ifdef DEBUG
#define dprintf(args...) fprintf(stderr,args)
#include <assert.h>
#endif
#ifndef DEBUG
#define dprintf(args...) 69
#define assert(args...) 42
#endif
// 1}}}
int main()
{
int n,nk;scanf("%d %d",&n,&nk);
printf("n=%d nk=%d\n",n,nk);
vector<int> a(n);for(auto&x:a)scanf("%d",&x);
vector<vector<ll>> dp(nk+1, vector<ll>(n,0));
for(int i=0;i<n;i++)dp[0][i] = 0;
for(int k=1;k<=nk;k++) {
ll x=0;
for(int i=0;i<n;i++) {
if(i)x = max(x,dp[k-1][i-1]);
//printf("x=%lld a[i]=%d\n",x,a[i]);
dp[k][i] = (x += a[i]);
if(i) dp[k][i] = max(dp[k][i],dp[k][i-1]);
else dp[k][i] = max(0ll,dp[k][i]);
//printf("dp[%d][%d]=%lld\n",k,i,dp[k][i]);
}
}
printf("%lld\n",dp[nk][n-1]);
}
Compilation message (stderr)
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |