HDU 5477: A Sweet Journey
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
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)
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.
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.
1
2 2 2 5
1 2
3 4
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的更多相关文章
- HDU 5477 A Sweet Journey 水题
A Sweet Journey Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pi ...
- CodeForces 567B Berland National Library hdu-5477 A Sweet Journey
这类题一个操作增加多少,一个操作减少多少,求最少刚开始为多少,在中途不会出现负值,模拟一遍,用一个数记下最大的即可 #include<cstdio> #include<cstring ...
- 2015 ACM/ICPC Asia Regional Shanghai Online
1001 Puzzled Elena 1002 Antonidas 1003 Typewriter 1004 Count the Grid 1005 Code Formatting 1006 Ther ...
- HDU5477(模拟)
A Sweet Journey Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- HDU 6042 - Journey with Knapsack | 2017 Multi-University Training Contest 1
/* HDU 6042 - Journey with Knapsack [ 生成函数,五边形定理 ] | 2017 Multi-University Training Contest 1 题意: n种 ...
- HDU 5025:Saving Tang Monk(BFS + 状压)
http://acm.hdu.edu.cn/showproblem.php?pid=5025 Saving Tang Monk Problem Description <Journey to ...
- hdu 5326 Work
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5326 Work Description It’s an interesting experience ...
- hdu 2822 Dogs
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2822 Dogs Description Prairie dog comes again! Someda ...
- HDU 5584 LCM Walk 数学
LCM Walk Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5584 ...
随机推荐
- VUE 父子组件之间通信传值 props和 $emit
1.父组件传值给子组件 $props,子组件传值给父组件 $emit 父组件 <div id="app" > <tr ...
- 安装lnmp1.5到最后出现Error: MySQL install failed的解决方法
解决方法: mv /usr/bin/cmake /usr/bin/cmake.backup wget http://www.cmake.org/files/v3.0/cmake-3.0.2.tar.g ...
- 7.2 Varnish 模式
- 多实例mysql的安装和管理
多实例mysql的安装和管理 http://blog.chinaunix.net/uid-20639775-id-3438560.html mysql的多实例有两种方式可以实现,两种方式各有利弊.第一 ...
- 二 配置数据字典&异步查询客户
数据字典: 字典表和客户表的关系 配置字典表 配置客户表 Spring管理映射文件 1 字典表和客户表的关系 2 配置字典表 3 配置客户表 4 Spring管理映射文件 异步查询客户: 页面加载 ...
- SQL注入的原理及分析
注入攻击的本质:将用户输入的数据当做代码执行. 有2个限制条件: 1.用户能够控制输入. 2.原本程序要执行的代码,拼接了用户输入的数据后进行执行. 定义:用户输入的数据被当做SQL语句执行. 以下面 ...
- NO16 第二关课后考试-aw-F-过滤已知的一级目录
·总结的经验:1.学会总结时学好运维的重要前提.2.通过案列或例子来总结一个技术点或者命令.3.画一张逻辑图,形象的卡通记忆这个知识技术点.4.通过管道过滤数据时,最好先输出结果,然后回退再使用管道看 ...
- Codeforces Round #624 (Div. 3)(题解)
Codeforces Round #624 (Div.3) 题目地址:https://codeforces.ml/contest/1311 B题:WeirdSort 题意:给出含有n个元素的数组a,和 ...
- ModelSim安装步骤
刚成功安装了软件的我反手就是一篇安装步骤分享. 这是我自己创建的永久百度云链接. ModelSim10.7软件下载百度云链接 网址:https://pan.baidu.com/s/14oGZytocA ...
- 通过 Service 访问 Pod【转】
本节开始学习 Service.我们不应该期望 Kubernetes Pod 是健壮的,而是要假设 Pod 中的容器很可能因为各种原因发生故障而死掉.Deployment 等 controller 会通 ...