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 ...
随机推荐
- Node.js能够做什么?
正如 JavaScript 为client而生.Node.js 为网络而生.Node.js 能做的远不止开发一个网 站那么简单,使用 Node.js,你能够轻松地开发: 具有复杂逻辑的站点: ...
- MYSQL学习笔记三:日期和时间函数
MYSQL学习笔记三:日期和时间函数 1. 获取当前日期的函数和获取当前时间的函数 /*获取当前日期的函数和获取当前时间的函数.将日期以'YYYY-MM-DD'或者'YYYYMMDD'格式返回 */ ...
- Session、Cookie总结
什么是sessnion,session存在哪,能存多久.怎么设置他的存储时间 一.什么是session 1.session 被翻译为会话.当client(一般都是浏览器作为client)訪问serve ...
- Spring 4 CustomEditorConfigurer Example--转
原文地址:http://howtodoinjava.com/spring/spring-core/registering-built-in-property-editors-in-spring-4-c ...
- MySQL格式化日期参数
MySQL格式化日期参数 %a 缩写星期名 %b 缩写月名 %c 月,数值 %D 带有英文前缀的月中的天 %d 月的天,数值(00-31) %e 月的天,数值(0-31) %f 微秒 %H 小时 (0 ...
- #p-complete原来比np更难
转载一下豆瓣的一个不知名的朋友的介绍: NP是指多项式时间内验证其解是否正确.比如: 我们给一个0-1背包的解,就可以在多项式时间内验证是否满足条件.至于是否能找到 满足条件的解,这在NP复杂度里没有 ...
- Ionic CLI升级到3版本后2版本工程运行出错.md
1. 问题描述: 最近将Ionic的CLI升级到了最新的版本3.2,升级后在原来Ionic2版本的CLI中创建的工程,通过ionic serve运行报错,错误类似如下: C:\Users\Admin\ ...
- 用fcntl锁一个文件来保护操作
int testfd; /* fd for test*/ if((testfd = open("/usr/local/pgsql/bin/test_fd",O_RDWR|O_CRE ...
- html5开发页游(前话)
导师要求模仿某个页游网站开发益智小游戏.老板的要求是要跨平台,IOS,Android.PC.Mac等系统主要通过浏览器打开都能用.那个网站的页游是通过flash实现的,使用这种方法肯定不能满足老板的要 ...
- Map<String,String>转换json字符串
import java.util.HashMap; import java.util.Map; import net.sf.json.JSONObject; public class testJson ...