算法题:UVA 607 (dp记忆化搜索)

Scheduling Lectures

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 are two scheduling restrictions:

1.Each topic must be covered in a single lecture. It cannot be divided into two lectures. This reduces discontinuity between lectures.

2.Topic i must be covered before topic i + 1 for all . Otherwise, students may not have the prerequisites to understand topic i + 1.

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

where C is a positive integer, and t is the amount of free time at the end of a lecture. The total dissatisfaction index is the sum of the DI for each lecture.

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

Input

The input consists of a number of cases. The first line of each case contains the integer n, or 0 if there are no more cases. The next line contains the integers L and C. These are followed by n integers.

Output

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

Sample Input

6
30 15
10
10
10
10
10
10
10
120 10
80
80
10
50
30
20
40
30
120
100
0

Sample Output

Case 1:
Minimum number of lectures: 2
Total dissatisfaction index: 0

Case 2:
Minimum number of lectures: 6
Total dissatisfaction index: 2700

时间: 2024-07-29 20:01:02

算法题:UVA 607 (dp记忆化搜索)的相关文章

算法题:UVA 10558 A Brief Gerrymander (dp记忆化搜索)

Problem E: A Brief Gerrymander The evil ruling party, the Liberatives, are redistributing the electoral regions (ridings) in your city, and are nefariously attempting to pack certain opposition-friendly neighborhoods into as few ridings as possible.

算法题:UVA 10626 Buying Coke(dp + 记忆化搜索)

I often buy Coca-Cola from the vending machine at work. Usually I buy several cokes at once, since my working mates also likes coke. A coke in the vending machine costs 8 Swedish crowns, and the machine accept crowns with the values 1, 5 and 10. As s

算法题:UVA 709 Formatting Text(记忆化搜索)

Formatting Text Writings e-mails is fun, but, unfortunately, they do not look very nice, mainly because not all lines have the same lengths. In this problem, your task is to write an e-mail formatting program which reformats a paragraph of an e-mail

hdu 1078 FatMouse and Cheese 记忆化搜索

  一开始打算正向用状态dp,结果果断超时,换成反向记忆话搜索就过了 /* author:jxy lang:C/C++ university:China,Xidian University **If you need to reprint,please indicate the source** */ #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #in

poj3249Test for Job(记忆化搜索)

/* 题意:给一个DAG图,n个节点,每个节点都对应一个值,入度为零的点走到出度为零的点,计算所有可能路径 经过节点值的和最大! 思路:记忆话搜索:也就是如果我们搜索到某一个节点的时候发现该节点已经存在了值,那么直接返回该节点的值! 和回溯的思想差不多吧! 注意:我们是正向建图,并且记忆话搜索是先将子节点的最优值计算出来,然后在计算父节点的最优值 所以最终的最优值的结果在 入度为0的节点上! */ #include<iostream> #include<cstdio> #inclu

算法题:UVA 825 Walking on the Safe Side(记忆化搜索)

Walking on the Safe Side Square City is a very easy place for people to walk around. The two-way streets run North-South or East-West dividing the city into regular blocks. Most street intersections are safe for pedestrians to cross. In some of them,

算法题:UVA 11008 Antimatter Ray Clearcutting(记忆化搜索+位运算)

Problem E Antimatter Ray Clearcutting Input: Standard Input Output: Standard Output It's year 2465, and you are the Chief Engineer for Glorified Lumberjacks Inc. on planet Trie. There is a number of trees that you need to cut down, and the only weapo

算法题:UVA 10651 Pebble Solitaire(bfs + 哈希判重(记忆化搜索?))

Pebble solitaire is an interesting game. This is a game where you are given a board with an arrangement of small cavities, initially all but one occupied by a pebble each. The aim of the game is to remove as many pebbles as possible from the board. P

算法题:UVA 10604 (记忆化搜索 + hash)

In a chemist's lab, there are several types of chemicals in tubes. The chemist wants to mix all these chemicals together, two chemicals at a time. Whenever two chemicals are mixed, some heat is generated and released into the air and the mixed chemic