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 ...
随机推荐
- MOPSO 多目标例子群优化算法
近年来,基于启发式的多目标优化技术得到了很大的发展,研究表明该技术比经典方法更实用和高效.有代表性的多目标优化算法主要有NSGA.NSGA-II.SPEA.SPEA2.PAES和PESA等.粒子群优化 ...
- Delphi中SQL批量插入记录
http://www.cnblogs.com/azhqiang/p/4050331.html 在进行数据库操作时, 我们经常会遇到批量向数据库中写入记录的情况. 在这里我提供3种操作方式: 1. ...
- pic计数
#include <pic.h> //用的是PICC编译器 __CONFIG (HS & PROTECT & PWRTEN & BOREN & WDTDIS ...
- InnoDB Status Output – Buffer Pool and Spin Rounds
InnoDB has a good source of information about its status which can be requested every time you need ...
- Creater中选择一行的方法
1. 在表布局中增加一单选钮列,给单选钮的属性name任意设定一个值.2. 选择单选钮对应列,将其selectID设为单选钮的ID;将onclick设为setTimeout('initAllRow ...
- rsync 只同步指定类型的文件
需求: 同步某个目录下所有的图片(*.jpg),该目录下有很多其他的文件,但只想同步*.jpg的文件. rsync 有一个--exclude 可以排除指定文件,还有个--include选项的作用正好和 ...
- Docker 端口映射问题解决
在操作Docker容器时发现了其一个端口映射的BUG,具体表现为:开启容器时做了端口映射80:8080,即宿主机的80端口映射到容器内部的8080Jboss端口.一开始测试也没有什么问题,都可以联通, ...
- JavaEE基础(五)
1.Java语言基础(数组概述和定义格式说明) A:为什么要有数组(容器) 为了存储同种数据类型的多个值 B:数组概念 数组是存储同一种数据类型多个元素的集合.也可以看成是一个容器. 数组既可以存储基 ...
- Nginx使用手册目录
Nginx学习总结[第一篇]: Nginx简介 Nginx第二篇:Nginx部署及使用 Nginx第三篇:Nginx日志处理 Nginx第四篇:Nginx优化 Nginx第五篇:Nginx日常管理
- Educational Codeforces Round 13 D:Iterated Linear Function(数论)
http://codeforces.com/contest/678/problem/D D. Iterated Linear Function Consider a linear function f ...