Codevs 4310 Copying manuscripts

Source: Internet
Author: User

4310 Copying Manuscripts

time limit: 1 sspace limit: 4000 KBtitle level: Golden Gold SolvingView Run ResultsTitle 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 not to the first, third and fourth book to the same person 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

The first line of two integers m,k; (k≤m≤500),

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 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

k≤m≤500

#include <cstdio> #include <iostream>using namespace Std;int m,k;int a[600],b[600],f[600][600];void xx (int X,int y)//output, greedy {if (y==0) return;if (y==1)///Only one person transcription   {            cout<<1<< ' <<x<<endl;          return;  } int t=x,l=a[x]; while (L+a[t-1]<=f[k][m])//As long as the J person can copy, let him copy, so that the former J Personal transcription burden minimum   {  l+=a[t-1];  t--;  } XX (t-1,y-1);//At this time only t-1 book can be copied, there is y-1 personal cout<<t<< "<<x<<endl;//recursive output}int main () {scanf ("%d%d ", &m,&k); for (int i=1;i<=k;i++) for  (int j=1;j<=m;j++)    f[i][j]=1000000;for (int i=1;i<=m;i++)  {   scanf ("%d", &a[i]);   B[i]=b[i-1]+a[i];   F[1][i]=b[i];  } for (int i=2;i<=k;i++)//F[I][J] The minimum time required for a person to copy a J book for  (int. j=i;j<=m;j++) for    (int p=1;p<=j-1;p++)      

  

Codevs 4310 Copying manuscripts

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.