A Sweet Journey

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 25    Accepted Submission(s): 12

Problem Description
Master Di plans to take his girlfriend for a travel by bike. Their journey, which can be seen as a line segment of length L, is a road of swamps and flats. In the swamp, it takes A point strengths per meter for Master Di to ride; In the flats, Master Di will
regain B point strengths per meter when riding. Master Di wonders:In the beginning, he needs to prepare how much minimum strengths. (Except riding all the time,Master Di has no other choice) 



 
Input
In the first line there is an integer t (1≤t≤50),
indicating the number of test cases.

For each test case:

The first line contains four integers, n, A, B, L.

Next n lines, each line contains two integers: Li,Ri,
which represents the interval [Li,Ri] is
swamp.

1≤n≤100,1≤L≤105,1≤A≤10,1≤B≤10,1≤Li<Ri≤L.

Make sure intervals are not overlapped which means Ri<Li+1 for
each i (1≤i<n).

Others are all flats except the swamps.
 
Output
For each text case:

Please output “Case #k: answer”(without quotes) one line, where k means the case number counting from 1, and the answer is his minimum strengths in the beginning.
 
Sample Input
1
2 2 2 5
1 2
3 4
 
Sample Output
Case #1: 0

最近状态一直不怎么好,想了很多问题都没有想出答案。当然了,我这种状态好了也不会好到哪里去。。。

只能切一切这种菜题了。。。

题意就是一个人去旅行,有沼泽地有平坦地,平坦地可以涨力气,沼泽地耗力气。问如果能顺利到达目的地的话,一开始要准备多少力气。

代码:

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#pragma warning(disable:4996)
using namespace std; int dis[100005]; int main()
{
int test,i,j,n,A,B,L,temp1,temp2,ans;
scanf("%d",&test);
for(i=1;i<=test;i++)
{
memset(dis,0,sizeof(dis));
scanf("%d%d%d%d",&n,&A,&B,&L);
for(j=1;j<=n;j++)
{
scanf("%d%d",&temp1,&temp2);
dis[temp2]=(-1)*(temp2-temp1)*(A+B);
}
ans=0;
for(j=1;j<=L;j++)
{
dis[j]=dis[j-1]+dis[j]+B;
ans=min(ans,dis[j]);
}
printf("Case #%d: %d\n",i,-1*ans);
}
return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

HDU 5477: A Sweet Journey的更多相关文章

  1. HDU 5477 A Sweet Journey 水题

    A Sweet Journey Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pi ...

  2. CodeForces 567B Berland National Library hdu-5477 A Sweet Journey

    这类题一个操作增加多少,一个操作减少多少,求最少刚开始为多少,在中途不会出现负值,模拟一遍,用一个数记下最大的即可 #include<cstdio> #include<cstring ...

  3. 2015 ACM/ICPC Asia Regional Shanghai Online

    1001 Puzzled Elena 1002 Antonidas 1003 Typewriter 1004 Count the Grid 1005 Code Formatting 1006 Ther ...

  4. HDU5477(模拟)

    A Sweet Journey Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  5. HDU 6042 - Journey with Knapsack | 2017 Multi-University Training Contest 1

    /* HDU 6042 - Journey with Knapsack [ 生成函数,五边形定理 ] | 2017 Multi-University Training Contest 1 题意: n种 ...

  6. HDU 5025:Saving Tang Monk(BFS + 状压)

    http://acm.hdu.edu.cn/showproblem.php?pid=5025 Saving Tang Monk Problem Description   <Journey to ...

  7. hdu 5326 Work

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5326 Work Description It’s an interesting experience ...

  8. hdu 2822 Dogs

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2822 Dogs Description Prairie dog comes again! Someda ...

  9. HDU 5584 LCM Walk 数学

    LCM Walk Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5584 ...

随机推荐

  1. [经验] Cocos Creator使用笔记 --- 俄罗斯方块 (1)

    一:  实现 物体匀速掉落 这是我在做俄罗斯方块的时候遇到的一个问题,  因为原来的方块的掉落是每秒掉落一个像素点, 但是这样看起来的话会是一卡一卡的, 为了让方块在掉落的过程中看起来更加的流畅, 于 ...

  2. PAT (Advanced Level) 1124~1127:1124模拟 1125优先队列 1126欧拉通路 1127中序后序求Z字形层序遍历

    1124 Raffle for Weibo Followers(20 分) 题意:微博抽奖,有M个人,标号为1~M.从第S个人开始,每N个人可以获奖,但是已获奖的人不能重复获奖,需要跳过该人把机会留给 ...

  3. Helm 架构【转】

    在实践之前,我们先来看看 Helm 的架构. Helm 有两个重要的概念:chart 和 release. chart 是创建一个应用的信息集合,包括各种 Kubernetes 对象的配置模板.参数定 ...

  4. idea中跑mapreduce报错, PATH设置错误

    问题如题,报错: [root@node01 servers]# hadoop jar loginVisit.jar cn.itcast.loginVisit.step1.Step1Main19/07/ ...

  5. 恒大与FF终达成和解!谁赢了,谁输了?

    去年11月结束的中超,广州恒大以63分的积分落后上海上港5分,排在第二名的位置.恒大恒可惜地没有创造史无前例的联赛八连冠,与新的亚洲纪录失之交臂.但相比球场上的"失意",许家印在商 ...

  6. Linux系统测试工具

    一.文件系统测试工具简介 1.LTP 参考网站:http://oss.sgi.com/projects/ltp/ LTP(Linux Test Project)是由SGI和IBM联合发起的项目,提供一 ...

  7. bzoj 4754: [Jsoi2016]独特的树叶

    不得不说这是神题. %%%   http://blog.csdn.net/samjia2000/article/details/51762811 #include <cstdio> #in ...

  8. linux网络编程之shutdown() 与 close()函数详解

    linux网络编程之shutdown() 与 close()函数详解 参考TCPIP网络编程和UNP: shutdown函数不能关闭套接字,只能关闭输入和输出流,然后发送EOF,假设套接字为A,那么这 ...

  9. 010、MySQL日期时间戳转化为文本日期时间

    #时间戳转化文本时间 SELECT from_unixtime( unix_timestamp( curdate( ) ) ); #时间戳转化文本时间格式化 SELECT from_unixtime( ...

  10. Netty 中队列的使用

    任务队列中的Task有3种典型使用场景 用户程序自定义的普通任务 此前代码: 参考https://www.cnblogs.com/ronnieyuan/p/12016712.html NettySer ...