| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1089852 | KALARRY | Tricks of the Trade (CEOI23_trade) | C++14 | 42 ms | 11348 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.
//chockolateman
#include<bits/stdc++.h>
using namespace std;
long long N,K,a[250005],b[250005],dp[250005][2];
int main()
{
    scanf("%lld%lld",&N,&K);
    for(long long i = 1 ; i <= N ; i++)
        scanf("%lld",&a[i]);
    for(long long i = 1 ; i <= N ; i++)
        scanf("%lld",&b[i]);
    for(long long j = 1 ; j <= K ; j++)
        dp[0][j%2] = -1e9;
    for(long long j = 1 ; j <= K ; j++)
    {
        for(long long i = 1 ; i <= N ; i++)
            dp[i][j%2] = max(dp[i-1][j%2] - a[i],dp[i-1][(j-1)%2] + b[i] - a[i]);
    }
    long long ans = -1e9;
    for(long long i = 1 ; i <= N ; i++)
        ans = max(ans,dp[i][K%2]);
    printf("%lld\n",ans);
    return 0;
}
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... | ||||
