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 ...
随机推荐
- leetCode(38):Lowest Common Ancestor of a Binary Search Tree
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BS ...
- 关于Android制作.9.png图片
第一个问题,.9格式的图片与我们之前的一般图片有什么问题呢? 这是安卓开发里面的一种特殊的图片. 这样的格式的图片在android 环境下具有自适应调节大小的能力. (1)同意开发者定义可扩展区域,当 ...
- Android BlueDroid(二):BlueDroid蓝牙开启过程init
关键词:bluedroid initNative enableNative BTIF_TASK BTU_TASKbt_hc_work_thread set_power preload GKI作 ...
- android:为TextView加入样式——下划线,颜色,设置链接样式及前背景色
实现下划线及颜色设置: public class AtActivity extends Activity { LinearLayout ll; /** Called when the acti ...
- bzoj1831: [AHOI2008]逆序对(DP+双精bzoj1786)
1831: [AHOI2008]逆序对 Description 小可可和小卡卡想到Y岛上旅游,但是他们不知道Y岛有多远.好在,他们找到一本古老的书,上面是这样说的: 下面是N个正整数,每个都在1~K之 ...
- dom4j组装xml 以及解析xml
dom4j组装xml 以及解析xml: 1.下载dom4j的jar包,地址:https://dom4j.github.io/ 2.java代码: package test; import java.i ...
- svn回到某个历史版本的做法
作者:朱金灿 来源:http://blog.csdn.net/clever101 一.在选中的文件上弹出svn的右键菜单,单击"Updateto revision"菜单项,如下图: ...
- PostgreSQL Replication之第九章 与pgpool一起工作(3)
9.3 理解pgpool的架构 一旦我们安装了pgpool,是时候来讨论软件架构了.从一个用户的角度看,pgpool就像一个 正常的数据库服务器,您可以想连接任何其他服务器一样连接到它: pgpool ...
- Generic type test java
package test; public class GenericTest { public class Room<T> { private T t; public void add(T ...
- [洛谷P3927]SAC E#1 - 一道中档题 Factorial
题目大意:求$n!$在$k(k>1)$进制下末尾0的个数. 解题思路:一个数在十进制转k进制时,我们用短除法来做.容易发现,如果连续整除p个k,则末尾有p个0. 于是问题转化为$n!$能连续整除 ...