UVA 60,722 Scheduling Lectures

Source: Internet
Author: User

Scheduling lecturesTime limit:3000MS Memory Limit:0KB 64bit IO Format:%lld &%llu SubmitStatusPracticeUVA 607Appoint Description:System Crawler (2015-08-26)

Description

You are teaching a course and must cover n () topics. The length of each lecture is L () minutes. The topics require () minutes each. For each topic, you must decide in which lecture it should be covered. There is scheduling restrictions:

1.
Each topic must is covered in a single lecture. It cannot is divided into and lectures. This reduces discontinuity between lectures.
2.
Topic I must be covered before Topic I + 1 for all. Otherwise, students may is not having the prerequisites to understand topic I + 1.

With the above restrictions, it's sometimes necessary to has free time at the end of a lecture. If The amount of free time are at most minutes, the students would be happy to leave early. However, if the amount of free time was more, they would feel that their tuition fees was wasted. Therefore, we'll model the dissatisfaction index (DI) of a lecture by the formula:


where Cis a positive integer, and Tis the amount of free time at the end of a lecture. The total dissatisfaction index was the sum of the DI for each lecture.


For this problem, you must find the minimum number of lectures that's needed to satisfy the above constraints. If There is multiple lecture schedules with the minimum number of lectures, also minimize the total dissatisfaction index .

InputThe input consists of a number of cases. The first line of all case contains the integer N, or 0 if there is no more cases. The next line contains the integers Land C. These is followed by NIntegers.

OutputFor each case, print the case number, the minimum number of lectures used, and the total dissatisfaction index for the Cor Responding lecture schedule on three separate lines. Output a blank line between cases.

Sample Input

630 1510101010101010120 1080801050302040301201000

Sample Output
Case 1:minimum Number of lectures:2total dissatisfaction index:0case 2:minimum number of Lectures:6total Dissatisfactio N index:2700

Miguel A. Revilla
1999-04-06
1#include <stdio.h>2#include <string.h>3#include <algorithm>4 using namespacestd;5 6 Const intinf=0x3f3f3f3f;7 8 intn,l,c;9     inti,j,k;Ten     intcas=1, ans; One     inta[1005],sum[1005],dp[1005][1005]; A  - intDissatisfaction (intx) - { the     if(x==0) -         return 0; -     Else if(1<=x && x<=Ten) -         return(-c); +     Else -         return(X-Ten) * (X-Ten); +  A } at  - intMain () - { -      -      while(SCANF ("%d", &n)!=eof && n!=0) -     { insum[0]=0; -scanf"%d%d",&l,&c); to          for(i=1; i<=n;i++) +         { -scanf"%d",&a[i]); thesum[i]=sum[i-1]+A[i]; *         } $          for(i=0; i<=n;i++)Panax Notoginseng         { -dp[i][0]=0; the              for(j=1; j<=n;j++) +dp[i][j]=inf; A         } the  +          for(i=1;DP [i1][n]==inf;i++) -         { $              for(J=i;j<=n && sum[j]<=i*l;j++) $             { -                  for(k=j;k>=i-1; k--) -                 { the                     if(dp[i-1][k]!=inf && (sum[j]-sum[k]) <=l) -Dp[i][j]=min (dp[i][j],dp[i-1][k]+dissatisfaction (l-sum[j]+sum[k]));Wuyi                     Else if(sum[j]-sum[k]>l) the                          Break; -                 } Wu             } -         } About  $          for(i=1; i<=n;i++) -         { -             if(dp[i][n]!=inf) -             { Aans=i; +                  Break; the             } -         } $         if(cas>1)  theprintf"\ n"); theprintf"Case%d:\nminimum Number of lectures:%d\ntotal dissatisfaction index:%d\n", cas++, Ans,dp[ans][n]); the     } the     return 0; -}
View Code

UVA 60,722 Scheduling Lectures

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.