Codeforces round #267 (Div. 2) C. George and job (DP) Supplement

Source: Internet
Author: User

Codeforces round #267 (Div. 2) C. George and job question link please click ~

The new itone 6 has been released recently and George got really keen to buy it. unfortunately, he didn't have enough money, so George was going to work as a programmer. now he faced the following problem at the work.

Given a sequenceNIntegersP1, bytes,P2, middle..., middle ,...,PN. You are to chooseKPairs of integers:

 

[ L 1, bytes,R1], region [L2, bytes,R2], numbers..., numbers [LK, Bytes,RK] (1 limit ≤ limitL1 bytes ≤ bytesR1 worker <workerL2 bytes ≤ bytesR2 rows <values... rows <valuesLKLimit ≤ limitRKLimit ≤ limitN;RIAccept-Encoding-LIBytes + bytes 1 records = bytesM), Then ),

In such a way that the value of sum is maximal possible. Help George to interact with the task.

Input

The first line contains three IntegersN,MAndK(1 limit ≤ limit (MLimit × limitK) Bytes ≤ bytesNLimit ≤00005000). The second line containsNIntegersP1, bytes,P2, middle..., middle ,...,PN(0 bytes ≤ bytesPILimit ≤ limit 109 ).

Output

Print an integer in a single line-the maximum possible value of sum.

Sample test (s) Input
5 2 11 2 3 4 5
Output
9
Input
7 1 32 10 7 18 5 33 0
Output
61
 1 #include <iostream> 2 #include <cstdio> 3 #define LL long long 4 using namespace std; 5 const int maxn = 5000 + 100; 6 LL p[maxn],s[maxn],dp[maxn][maxn]; 7 int main(){ 8     int n,m,k; 9     cin>>n>>m>>k;10     for(int i = 1;i <= n;i++){11         cin>>p[i];s[i] = s[i - 1] + p[i];12     }13     for(int i = m;i <= n;i++)14         for(int j = 1;j <= k;j++)15                 dp[i][j] = max(dp[i-m][j-1]+s[i]-s[i-m],dp[i-1][j]);16     cout<<dp[n][k]<<endl;17     return 0;18 }
View code

 

Codeforces round #267 (Div. 2) C. George and job (DP) Supplement

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.