UVA 607 二十二 Scheduling Lectures
Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu
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 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
Miguel A. Revilla
1999-04-06
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std; const int inf=0x3f3f3f3f; int n,l,c;
int i,j,k;
int cas=,ans;
int a[],sum[],dp[][]; int dissatisfaction(int x)
{
if(x==)
return ;
else if(<=x && x<=)
return (-c);
else
return (x-)*(x-); } int main()
{ while(scanf("%d",&n)!=EOF && n!=)
{
sum[]=;
scanf("%d %d",&l,&c);
for(i=;i<=n;i++)
{
scanf("%d",&a[i]);
sum[i]=sum[i-]+a[i];
}
for(i=;i<=n;i++)
{
dp[i][]=;
for(j=;j<=n;j++)
dp[i][j]=inf;
} for(i=;dp[i-][n]==inf;i++)
{
for(j=i;j<=n && sum[j]<=i*l;j++)
{
for(k=j;k>=i-;k--)
{
if(dp[i-][k]!=inf && (sum[j]-sum[k])<=l)
dp[i][j]=min(dp[i][j],dp[i-][k]+dissatisfaction(l-sum[j]+sum[k]));
else if(sum[j]-sum[k]>l)
break;
}
}
} for(i=;i<=n;i++)
{
if(dp[i][n]!=inf)
{
ans=i;
break;
}
}
if(cas>)
printf("\n");
printf("Case %d:\nMinimum number of lectures: %d\nTotal dissatisfaction index: %d\n",cas++,ans,dp[ans][n]);
}
return ;
}
UVA 607 二十二 Scheduling Lectures的更多相关文章
- [分享] IT天空的二十二条军规
Una 发表于 2014-9-19 20:25:06 https://www.itsk.com/thread-335975-1-1.html IT天空的二十二条军规 第一条.你不是什么都会,也不是什么 ...
- Bootstrap <基础二十二>超大屏幕(Jumbotron)
Bootstrap 支持的另一个特性,超大屏幕(Jumbotron).顾名思义该组件可以增加标题的大小,并为登陆页面内容添加更多的外边距(margin).使用超大屏幕(Jumbotron)的步骤如下: ...
- Web 前端开发精华文章推荐(HTML5、CSS3、jQuery)【系列二十二】
<Web 前端开发精华文章推荐>2014年第一期(总第二十二期)和大家见面了.梦想天空博客关注 前端开发 技术,分享各类能够提升网站用户体验的优秀 jQuery 插件,展示前沿的 HTML ...
- 二十二、OGNL的一些其他操作
二十二.OGNL的一些其他操作 投影 ?判断满足条件 动作类代码: ^ $ public class Demo2Action extends ActionSupport { public ...
- WCF技术剖析之二十二: 深入剖析WCF底层异常处理框架实现原理[中篇]
原文:WCF技术剖析之二十二: 深入剖析WCF底层异常处理框架实现原理[中篇] 在[上篇]中,我们分别站在消息交换和编程的角度介绍了SOAP Fault和FaultException异常.在服务执行过 ...
- VMware vSphere 服务器虚拟化之二十二桌面虚拟化之创建View Composer链接克隆的虚拟桌面池
VMware vSphere 服务器虚拟化之二十二桌面虚拟化之创建View Composer链接克隆的虚拟桌面池 在上一节我们创建了完整克隆的自动专有桌面池,在创建过程比较缓慢,这次我们将学习创建Vi ...
- Bootstrap入门(二十二)组件16:列表组
Bootstrap入门(二十二)组件16:列表组 列表组是灵活又强大的组件,不仅能用于显示一组简单的元素,还能用于复杂的定制的内容. 1.默认样式列表组 2.加入徽章 3.链接 4.禁用的列表组 5. ...
- JAVA之旅(二十二)——Map概述,子类对象特点,共性方法,keySet,entrySet,Map小练习
JAVA之旅(二十二)--Map概述,子类对象特点,共性方法,keySet,entrySet,Map小练习 继续坚持下去吧,各位骚年们! 事实上,我们的数据结构,只剩下这个Map的知识点了,平时开发中 ...
- 备忘录模式 Memento 快照模式 标记Token模式 行为型 设计模式(二十二)
备忘录模式 Memento 沿着脚印,走过你来时的路,回到原点. 苦海翻起爱恨 在世间难逃避命运 相亲竟不可接近 或我应该相信是缘份 一首<一生所爱>触动了多少 ...
- 二十二. Python基础(22)--继承
二十二. Python基础(22)--继承 ● 知识框架 ● 继承关系中self的指向 当一个对象调用一个方法时,这个方法的self形参会指向这个对象 class A: def get(s ...
随机推荐
- Mysql触发器总结
触发器(trigger):监视某种情况,并触发某种操作. 触发器创建语法四要素:1.监视地点(table) 2.监视事件(insert/update/delete) 3.触发时间(after/befo ...
- PAT乙级 1026. 程序运行时间(15)
1026. 程序运行时间(15) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 要获得一个C语言程序的运行时间, ...
- emulator-arm.exe 已停止工作、 emulator-x86 已停止工作
问题描述: emulator-arm.exe 已停止工作. emulator-x86 已停止工作.AVD模拟器启动一直黑屏.AVD模拟器启动一直显示andorid界面 解决方法: 1. sdk的安 ...
- ASP.NET MVC 返回JsonResult序列化内容超出最大限制报错的解决办法
在使用MVC的时候我们经常会在Controller的Action方法中返回JsonResult对象,但是有时候你如果序列化的对象太大会导致JsonResult从Controller的Action返回后 ...
- android 项目学习随笔一(闪屏 )
1.取标题栏且全屏 <activity android:name="com.ecollab.zhsh66.SplashActivity" android:label=&quo ...
- Java相关内容解析
java中的反射机制是什么,有什么作用啊?要点:JAVA反射机制是在运行状态中,对于任意一个类,都能够知道这个类的所有属性和方法:对于任意一个对象,都能够调用它的任意一个方法:这种动态获取的以及动态调 ...
- ERR: Call to undefined function openssl_random_pseudo_bytes()
最近使用TP5/PHP7,总是出现ERR: Call to undefined function index\index\openssl_random_pseudo_bytes(),才发现是php没有 ...
- android 常用命令
1.查看当前手机界面的 Activity dumpsys | grep "mFocusedActivity" 查看任务栈 dumpsys | grep "Hist&q ...
- Linux系统调用---同步IO: sync、fsync与fdatasync【转】
转自:http://blog.csdn.net/cywosp/article/details/8767327 [-] 1 write不够需要fsync 2 fsync的性能问题与fdatasync ...
- HDU 3966:Aragorn's Story(树链剖分)
http://acm.hdu.edu.cn/showproblem.php?pid=3966 题意:有n个点n-1条边,每个点有一个权值,有两种操作:询问一个点上权值是多少和修改u到v这条链上的权值. ...