XTUOJ 1206 Dormitory's Elevator
Dormitory's Elevator
Time Limit : 1000 MS | Memory Limit : 65536 KB |
Problem Description
The new dormitory has N(1≤N≤100000) floors and M(1≤M≤100000)students. In the new dormitory, in order to save student's time as well as encourage student exercise, the elevator in dormitory will not stop in adjacent floor. So if there are people want to get off the elevator in adjacent floor, one of them must walk one stair instead. Suppose a people go down 1 floor costs A energy, go up 1 floor costs B energy(1≤A,B≤100). Please arrange where the elevator stop to minimize the total cost of student's walking cost.All students and elevator are at floor 1 initially, and the elevator can not godown and can stop at floor 2.
Input
First line contain an integer T, there are T(1≤T≤10) cases. For each case T, there are two lines. First line: The number of floors N(1≤N≤100000), and the number of students M(1≤M≤100000),A,B(1≤A,B≤100) Second line: M integers (2≤A[i]≤N), the student's desire floor.
Output
Output case number first, then the answer, the minimum of the total cost of student's walking cost.
Sample Input
1
3 2 1 1
2 3
Sample Output
Case 1: 1
Source
daizhenyang
解题:动态规划,同NYIST的诡异的电梯
#include <bits/stdc++.h>
using namespace std;
const int maxn = ;
int dp[maxn],des[maxn];
int main(){
int T,n,m,A,B;
scanf("%d",&T);
for(int t = ; t <= T; ++t){
memset(dp,0x3f,sizeof dp);
memset(des,,sizeof des);
scanf("%d %d %d %d",&n,&m,&A,&B);
for(int i = ,tmp; i < m; ++i){
scanf("%d",&tmp);
des[tmp]++;
}
dp[] = dp[] = dp[] = ;
for(int i = ; i <= n; ++i){
dp[i] = dp[i-] + min(A,B)*des[i-];
int x = min(B,A*)*des[i-];
int y = min(B*,A)*des[i-];
dp[i] = min(dp[i],dp[i-] + x + y);
}
printf("Case %d: %d\n",t,dp[n]);
}
return ;
}
XTUOJ 1206 Dormitory's Elevator的更多相关文章
- 湘潭大学oj 1206 Dormitory's Elevator dp
27153 njczy2010 1206 Accepted 1976 KB 234 MS G++ 1415 B 2014-09-28 10:01:23 真是吐血ac,,,,这么easy的题..... ...
- 2014嘉杰信息杯ACM/ICPC湖南程序设计邀请赛暨第六届湘潭市程序设计竞赛
比赛链接: http://202.197.224.59/OnlineJudge2/index.php/Contest/problems/contest_id/36 题目来源: 2014嘉杰信息杯ACM ...
- HDOJ 1008. Elevator 简单模拟水题
Elevator Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Su ...
- poj[2392]space elevator
Description The cows are going to space! They plan to achieve orbit by building a sort of space elev ...
- Design Elevator
From: https://discuss.leetcode.com/topic/89/write-elevator-program-using-event-driven-programming/9 ...
- PAT (Advanced Level) Practise:1008. Elevator
[题目链接] The highest building in our city has only one elevator. A request list is made up with N posi ...
- Pair Project: Elevator Scheduler [电梯调度算法的实现和测试]
作业提交时间:10月9日上课前. Design and implement an Elevator Scheduler to aim for both correctness and performa ...
- POJ2392Space Elevator(贪心+背包)
Space Elevator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9970 Accepted: 4738 De ...
- hdu 1008 Elevator
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Description The hig ...
随机推荐
- thinkphp5的Illegal string offset 'id'错误
thinkphp5的Illegal string offset 'id'错误 问题 解答 数组同名了,一个html页面传进来两个cateres的数组,所以在找id的时候不知道找这两个里面的哪一个 第一 ...
- IE(8~11+) 可用右键加速器
必应词典工具 立即安装: 网络安装:http://dict.bing.com.cn/tools_dl.aspx?dl=ie8acc&mkt=ZH-CN 开发示例: <?xml versi ...
- Android开发日志统一管理
在开发中,我们通常要对日志的输出做统一管理,下面就为大家推荐一个日志输出类,在开发阶段只需将DEBUG常量设为true,生产环境将DEBUG设为false即可控制日志的输出.啥都不说了,需要的朋友直接 ...
- Java hashCode(), equals()
转自:http://blog.csdn.net/fenglibing/article/details/8905007冯立彬的博客 以下是关于HashCode的官方文档定义: hashcode方法返回该 ...
- jqueryEasyui重新渲染
转载: jQuery EasyUI parser 的使用场景 | WebUI框架使用参考+http://www.easyui.info/archives/216.html parser,故名意思,就是 ...
- 51Nod 3的幂的和(扩展欧几里德求逆元)
求:3^0 + 3^1 +...+ 3^(N) mod 1000000007 Input 输入一个数N(0 <= N <= 10^9) Output 输出:计算结果 Input示例 3 O ...
- 将double数据保留两位小数
private double formatDouble(double number) { DecimalFormat df = new DecimalFormat("#.00"); ...
- 运维派 企业面试题3 为上题中的 "十个随机字母_test.html" 文件 更名
Linux运维必会的实战编程笔试题(19题) 企业面试题3 #将试题2中创建的文件名uopiyhgawe_test.html# test-->修改为omg,html-->HTML 方法一: ...
- 移动和PC的适配
<script> //mode 移动端的适配方式 按需 传参 目前只有两种 px和rem (function(win, doc, mode) { var std = 750; if(/(i ...
- notepad++调用python3中文乱码
使用notepad++,配置好快捷键调用python3,一切就绪,仿佛就差代码了,结果一使用, 中文乱码,一直没有好的解决办法. 最后只能在代码中增加一行重写向输出解决,示例如下: #!/usr/bi ...