hdu4011 Working in Beijing
来源:互联网 发布:网络安全法宣传ppt 编辑:程序博客网 时间:2024/05/16 15:46
http://acm.hdu.edu.cn/showproblem.php?pid=4011
MemoryLimit: 65768/65768 K (Java/Others)
Total Submission(s):483 AcceptedSubmission(s): 256
#include <iostream>
#include <stdio.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
const long N=100010;
__int64 a[N],aa,minx;
int main()
{
intn,t,b;
inti,j,k;
while (cin>>t)
{
minx=k=0;
while (t--)
{
scanf("%d%I64d%d",&n,&aa,&b);
minx=n*b+2*aa;//总共参加会议当天花费+往返费用(头尾)
// printf("%I64d\n",minx);
scanf("%I64d",&a[0]);
for (i=1;i<n;i++)
{
scanf("%I64d",&a[i]);
if(a[i]-1==a[i-1])continue;//连续两场会议,其实可以不用
minx+=min((a[i]-a[i-1]-1)*b,2*aa);//留下来费用,往返机票费用,取较小着~
}
printf("Case #%d: %I64d\n",++k,minx);
}
}
return 0;
}
Working in Beijing
TimeLimit: 4000/2000 MS(Java/Others)Total Submission(s):483
Problem Description
Mr. M is an undergraduate student ofFDU. He finds an intern position in Beijing, so that he cannotattend all the college activities. But in some conditions, he mustcome back to Shanghai on certain date. We can assume the importantactivities that Mr. M must attend are occupy a whole day. Mr. Mmust take flight to Shanghai before that day and leave after thatday. On the other hand, Mr. M is absent in Beijing and he will losehis salary for his absent.
Sometimes the cost of flight is much higher than the loss ofsalary, so to save the cost on the travel, Mr. M can stay inShanghai to wait for another important date before he back toBeijing.
Now, Mr. M knows all of the important date in the next year. Helphim schedule his travel to optimize the cost.
Sometimes the cost of flight is much higher than the loss ofsalary, so to save the cost on the travel, Mr. M can stay inShanghai to wait for another important date before he back toBeijing.
Now, Mr. M knows all of the important date in the next year. Helphim schedule his travel to optimize the cost.
Input
The input contains several test cases.The first line of single integer indicates the number of testcases.
For each test case, the firstline contains three integers: n, a and b, denoting the number ofimportant events, the cost of a single flight from Beijing toShanghai or Shanghai to Beijing and the salary for a single daystay in Beijing. (1 <= n <= 100000, 1<= a <= 1000000000, 1<= b <=100)
Next line contains n integersti, denoting the time of the important events. You can assume theti are in increasing order and they are different from each other.(0 <= ti <= 10000000)
Output
For each test case, output a singleinteger indicating the minimum cost for this year.
Sample Input
2 1 10 10 55 10 2 5 10 15 65 70
Sample Output
Case #1: 30Case #2: 74
Source
The 36th ACM/ICPC Asia Regional Shanghai Site —— Warmup
#include <iostream>
#include <stdio.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
const long
__int64 a[N],aa,minx;
int main()
{
return 0;
}
0 0
- hdu4011 Working in Beijing
- hdu 4011.Working in Beijing
- 杭电OJ第4011题 Working in Beijing
- Walk in Beijing
- the last day in Beijing
- Day3: Meeting friend in Beijing
- Working in shanghai
- Working in the Background
- Working in Ericsson
- working experience in MST
- Working in Unity
- hdu4011(水贪心)
- One Night in Beijing[by Ivan]
- To my students in Beijing Prof.Stearns
- Cortex-M3 Trainning In Beijing (培训)
- One night in Beijing
- Working with Hibernate in Eclipse
- Working with Files in C#
- Visual Studio 2012完美的拥抱GitHub
- poj 2000 Gold Coins
- CodeForces 110A Nearly Lucky N…
- 一日小记
- hdu 2034 人见人爱A-B
- hdu4011 Working in Beijing
- foj1001 使用了位图
- foj1050 Number lengths
- 用指针实现链表--插入排序
- 世界末日
- foj 2027
- 七种qsort排序方法--
- 从源码中浅析Android中如何利用attrs和styles定义控件
- Spark核心开发者:性能超Hadoop百倍,算法实现仅有其1/10或1/100