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. github默认端口22被占用,ssh: connect to host github.com port 22: Connection timed out

    出现github 连接错误: ssh:connect to host github.com port 22:Connection timed out 刚开始以为是网络问题,github不能连接上,但是 ...

  2. oracle练习-day03

    .创建表空间.创建用户赋权限.创建表语法:.常见的数据类型字符             myname ) varchar2:推荐使用这个 可变长度最大字符    myname varchar2() 字 ...

  3. priority_queue优先级队列总结

    http://www.cppblog.com/Darren/archive/2009/06/09/87224.html priority_queue用法 priority_queue 调用 STL里面 ...

  4. 【STM32H7教程】第53章 STM32H7的LTDC应用之汉字小字库和全字库制作

    完整教程下载地址:http://www.armbbs.cn/forum.php?mod=viewthread&tid=86980 第53章       STM32H7的LTDC应用之汉字小字库 ...

  5. 《N诺机试指南》(一)数组妙用

    题目A: 大家思路有可能是这样: 将输入数据全部存储到一个数组里,然后可以冒泡排序一波,从小到大排序 那么怎么找到重复次数呢:我是这样想的,新定义数组b,原数组a,首先b[0] = a[0],定义指针 ...

  6. SpringBoot初试牛刀

    新建 Spring Boot 项目常用的两种方式 你可以通过 https://start.spring.io/ 这个网站来生成一个 Spring Boot 的项目. 你可以选择自己喜欢的依赖进行加载到 ...

  7. Spring框架中的JDK与CGLib动态代理

    JDK和CGLib动态代理区别 JDK动态代理:利用拦截器(拦截器必须实现InvocationHanlder)加上反射机制生成一个实现代理接口的匿名类, 在调用具体方法前调用InvokeHandler ...

  8. 配置uboot指定nfs挂载根文件系统

    背景: 文件系统的调试也建议在 网络中进行. 概念: NFS是Network File System的缩写及网络文件系统. 要功能是通过局域网络让不同的主机系统之间可以共享文件或目录. NFS系统和W ...

  9. when_did_you_born-瞟来的wp

    继上文,这次开始嫖when_did_you_born这题.前面的步骤大致是一样的就不赘述了,直接到代码分析. 字符串 这次呢在main函数处 按下F5进入调试 查看反汇编代码 可以清楚的看到它的逻辑一 ...

  10. HihoCoder 1245:王胖浩与三角形 三角形边长与面积

    #1245 : 王胖浩与三角形 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 王胖浩有一个三角形,三边长为a,b,c.他有特殊的能力,能增加三条边的边长,增加的总长度不能 ...