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. GeoDa绘制疫情地图

    刚学习GeoDa,菜鸟,目前还不能在地图上显示省市名称,求教. 看到丁香医生发布的疫情地图,我也尝试做一下,不过我的shp文件上只有中国大陆的31个省市. 数据来源于丁香医生,截至时间为 2020.1 ...

  2. 28 最小的K个数

    题目描述 输入n个整数,找出其中最小的K个数.例如输入4,5,1,6,2,7,3,8这8个数字,则最小的4个数字是1,2,3,4,.   思路: 解法1:对于小规模数据,可以采用类似前题的快速排序思路 ...

  3. jquery源码部分分析

    1.整体架构和如何辨别浏览器端和node端 自执行函数,判断在什么端,如果在浏览器端就执行factory函数 //(function(){a,b})(a,b) //jq大架构,闭包,自执行函数,传入函 ...

  4. ABC154 E - Almost Everywhere Zero

    数位DP模板,记忆化+限制即可 #include<bits/stdc++.h> using namespace std; #define lowbit(x) ((x)&(-x)) ...

  5. 什么叫github

    git remote add origin https://github.com/huiwangui/git-demo.git:表示在本地仓库关联远程仓库(https://github.com/hui ...

  6. mysql 三表索引优化

    建表语句 CREATE TABLE IF NOT EXISTS `phone`( `phoneid` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `card` ...

  7. Django创建完全独立的APP

    我们之前已经完成了项目的结构搭建,但是,在Django当中,我们强调的一个重要概念是app,比如Django自带的admin就是一个成功的app典范,那么我们应该如果整理自己的项目结构,才能让我们的a ...

  8. Java并发——volatile的原理

    111 Java并发——volatile的原理

  9. SpringMVC之ModelAndView的用法

    https://blog.csdn.net/qq30211478/article/details/78016155

  10. Vue点到子路由,父级,无法高亮问题解决

    [问题] Vue点到子路由,父级,无法高亮 [原因]多是因为链接简写相对路径没有写完整导致 [解决]把子路由的router-link的to属性里链接写完整.并把router配置文件里path也写完整即 ...