3162 transcription problem (divide DP)

Source: Internet
Author: User

3162 transcription Problems

Time limit: 1 s

Space limit: 128000 KB

Title Level: Diamonds Diamond

Exercises

View Run Results

Title Description Description

Now to the M-Order of the book to the K-person copy (transcription), each person's transcription speed is the same, a book is not allowed to two (or more) people to copy, to each person's book, must be continuous, such as can not be the first, third, the fourth number of the same person to copy. Now, please design a scheme that will make replication time shortest. The time to copy is the number of people who have copied the most pages.

Enter a description Input Description

First line two integers M, K; (k<=m<=100)

The second line is a M integer, and the first integer represents the number of pages of the book I.

Output Description Output Description

A total of k lines, two positive integers per line, and line I indicates the starting and ending numbers of the book to be copied by the first person. The starting number of the K line should be small to large arrangement, if there are many solutions, then as far as possible to let the previous people copy less.

Sample Input Sample Input

9 3

1 2 3 4 5 6 7 8 9

Sample Output Sample Output

1 5

6 7

8 9

data range and tips Data Size & Hint

See questions

Category tags tags click here to expand

#include <bits/stdc++.h>using namespacestd;#defineN 510inta[n],d[n],f[n][n],n,m,k;void  out(intIintj) {    intt,x; if(j==0)return ; if(j==1) {cout<<1<<' '<<i<<endl;return ; } t=i;x=A[i];  while(x+a[t-1]<=f[k][m]) x+=a[--T];  out(t1, J-1); cout<<t<<' '<<i<<Endl;}intMain () {scanf ("%d%d",&m,&k); Memset (F,127/3,sizeoff);  for(intI=1; i<=m;i++) scanf ("%d", a+i), d[i]=d[i-1]+a[i],f[1][i]=D[i];  for(intI=2; i<=k;i++)         for(intj=1; j<=m;j++)             for(intL=1; l<j;l++) F[i][j]=min (F[i][j],max (f[i-1][l],d[j]-d[l]));  out(M,K); return 0;} 

3162 transcription problem (divide DP)

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.