跑跑卡丁车(dp)
题意:https://www.nitacm.com/problem_show.php?pid=1470
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#include <cstdio>//sprintf islower isupper
#include <cstdlib>//malloc exit strcat itoa system("cls")
#include <iostream>//pair
#include <fstream>//freopen("C:\\Users\\13606\\Desktop\\草稿.txt","r",stdin);
#include <bitset>
//#include <map>
//#include<unordered_map>
#include <vector>
#include <stack>
#include <set>
#include <string.h>//strstr substr
#include <string>
#include <time.h>//srand(((unsigned)time(NULL))); Seed n=rand()%10 - 0~9;
#include <cmath>
#include <deque>
#include <queue>//priority_queue<int, vector<int>, greater<int> > q;//less
#include <vector>//emplace_back
//#include <math.h>
//#include <windows.h>//reverse(a,a+len);// ~ ! ~ ! floor
#include <algorithm>//sort + unique : sz=unique(b+1,b+n+1)-(b+1);+nth_element(first, nth, last, compare)
using namespace std;//next_permutation(a+1,a+1+n);//prev_permutation
//******************
int abss(int a);
int lowbit(int n);
int Del_bit_1(int n);
int maxx(int a,int b);
int minn(int a,int b);
double fabss(double a);
void swapp(int &a,int &b);
clock_t __STRAT,__END;
double __TOTALTIME;
void _MS(){__STRAT=clock();}
void _ME(){__END=clock();__TOTALTIME=(double)(__END-__STRAT)/CLOCKS_PER_SEC;cout<<"Time: "<<__TOTALTIME<<" s"<<endl;}
//***********************
#define rint register int
#define fo(a,b,c) for(rint a=b;a<=c;++a)
#define fr(a,b,c) for(rint a=b;a>=c;--a)
#define mem(a,b) memset(a,b,sizeof(a))
#define pr printf
#define sc scanf
#define ls rt<<1
#define rs rt<<1|1
typedef long long ll;
const double E=2.718281828;
const double PI=acos(-1.0);
//const ll INF=(1LL<<60);
const int inf=(<<);
const double ESP=1e-;
const int mod=(int)1e9+;
const int N=(int)1e6+; int dp[N][];
int a[N],b[N]; int main()
{
int l,n;
while(~sc("%d%d",&l,&n))
{
for(int i=;i<=l;++i)
{
int t;
sc("%d",&t);
for(int j=;j<n;++j)
a[i+j*l]=t;
}
for(int i=;i<=l;++i)
{
int t;
sc("%d",&t);
for(int j=;j<n;++j)
b[i+j*l]=t;
}
int tot=l*n;
for(int i=;i<=tot;++i)
for(int j=;j<=;++j)
dp[i][j]=inf;
dp[][]=; for(int i=;i<=tot;++i)
{
for(int j=;j<=;++j)
{
if(j!=&&dp[i-][j-]!=inf)
dp[i][j]=dp[i-][j-]+a[i];//不加速
if(dp[i-][]!=inf)
dp[i][]=min(dp[i][],dp[i-][]+a[i]);
if(j<=)
dp[i][j]=min(dp[i][j],dp[i-][j+]+b[i]);//加速
}
}
/* for(int i=0;i<=tot;++i)
pr("%5d%c",i," \n"[i==tot]);
for(int j=0;j<=10;++j)
{
for(int i=0;i<=tot;++i)
pr("%5d%c",dp[i][j]," \n"[i==tot]);
}*/
int ans=inf;
for(int i=;i<=;++i)
ans=min(ans,dp[tot][i]);
pr("%d\n",ans);
}
return ;
} /**************************************************************************************/ int maxx(int a,int b)
{
return a>b?a:b;
} void swapp(int &a,int &b)
{
a^=b^=a^=b;
} int lowbit(int n)
{
return n&(-n);
} int Del_bit_1(int n)
{
return n&(n-);
} int abss(int a)
{
return a>?a:-a;
} double fabss(double a)
{
return a>?a:-a;
} int minn(int a,int b)
{
return a<b?a:b;
}
跑跑卡丁车(dp)的更多相关文章
- HDU 1494 跑跑卡丁车 (DP)
题目链接 题意 : 中文题不详述. 思路 : sum = L*N 段,每走过一段如果不用加速卡的话,能量会增20%,将20%看作1,也就是说每涨到15就要变为10,所以最多是14才不浪费. dp[i] ...
- HDU1494(dp)
跑跑卡丁车 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- hdu1494 跑跑卡丁车(动态规划)
Description 跑跑卡丁车是时下一款流行的网络休闲游戏,你可以在这虚拟的世界里体验驾驶的乐趣.这款游戏的特别之处是你可以通过漂移来获得一种 加速卡,用这种加速卡可以在有限的时间里提高你的速度. ...
- HDU 1494 题解(DP)
题面: 跑跑卡丁车 Problem Description 跑跑卡丁车是时下一款流行的网络休闲游戏,你可以在这虚拟的世界里体验驾驶的乐趣.这款游戏的特别之处是你可以通过漂移来获得一种 加速卡,用这种加 ...
- G - 跑跑卡丁车
跑跑卡丁车是时下一款流行的网络休闲游戏,你可以在这虚拟的世界里体验驾驶的乐趣.这款游戏的特别之处是你可以通过漂移来获得一种加速卡,用这种加速卡可以在有限的时间里提高你的速度.为了使问题简单化,我们假设 ...
- BZOJ 1911: [Apio2010]特别行动队 [斜率优化DP]
1911: [Apio2010]特别行动队 Time Limit: 4 Sec Memory Limit: 64 MBSubmit: 4142 Solved: 1964[Submit][Statu ...
- 2013 Asia Changsha Regional Contest---Josephina and RPG(DP)
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=4800 Problem Description A role-playing game (RPG and ...
- AEAI DP V3.7.0 发布,开源综合应用开发平台
1 升级说明 AEAI DP 3.7版本是AEAI DP一个里程碑版本,基于JDK1.7开发,在本版本中新增支持Rest服务开发机制(默认支持WebService服务开发机制),且支持WS服务.RS ...
- AEAI DP V3.6.0 升级说明,开源综合应用开发平台
AEAI DP综合应用开发平台是一款扩展开发工具,专门用于开发MIS类的Java Web应用,本次发版的AEAI DP_v3.6.0版本为AEAI DP _v3.5.0版本的升级版本,该产品现已开源并 ...
随机推荐
- Zookeeper系列(十三)Zookeeper的请求处理
作者:leesf 掌控之中,才会成功:掌控之外,注定失败. 出处:http://www.cnblogs.com/leesf456/p/6179118.html尊重原创,奇文共欣赏: 一.前言 在 ...
- IntelliJ IDEA 2017.3 创建多Module项目时,右边栏出现多个root模块的问题。如图。
我新建了一个项目,里面有三个模块(Module),结果建好后,出现了三个root.然后我发现主模块的pom文件,包含这样一段配置 <modules> <module>desig ...
- cassandra3.11.4集群搭建
环境:[centos7.cassandra-3.11.4] 三个节点:[主机名为master,slave-1,slave-2, 用户均为root] 1.下载cassandra cassandra下载地 ...
- 在debian下安装QT 5.10 32位
准备工作: 在开始之前最好把GCC升级到5.0以上. 如果升级后出现“libstdc++.so.6: version `CXXABI_1.3.9' not found”错误,可以参考https://b ...
- leetcode-hard-array-179 Largest Number-NO
mycode 写的很复杂,还报错... 参考: class Solution: # @param {integer[]} nums # @return {string} def largestNum ...
- React入门----基础篇
React 背景介绍 React 起源于 Facebook 的内部项目,因为该公司对市场上所有 JavaScript MVC 框架,都不满意,就决定自己写一套,用来架设 Instagram 的网站.做 ...
- Android局部更新(RecyclerView+ DiffUtil)
一 概述 DiffUtil是support-v7:24.2.0中的新工具类,它用来比较两个数据集,寻找出旧数据集->新数据集的最小变化量. 说到数据集,相信大家知道它是和谁相关的了,就是我的最爱 ...
- 记一个微信支付-1错误JSAPI缺少参数app|get_brand_request:Fail
最近公司要做一个H5小游戏里边涉及到微信公众号支付,中间摸爬滚打遇到了很多坑.记录一下,留待后人看. 我们来看一下这个方法 GetJsApiParameters 怎么样,看起来像不像输出了一个JSON ...
- 使用注解实现Spring的声明式事务管理
使用注解实现Spring的声明式事务管理,更加简单! 步骤: 1) 必须引入Aop相关的jar文件 2) bean.xml中指定注解方式实现声明式事务管理以及应用的事务管理器类 3)在需要添加事务控制 ...
- iOS tableHeaderView有默认高度?
在给tableView设置tableHeaderView的时候发现,如果设置tableView.tableHeaderView = [UIView new] , 这里未设置tableView的高度,但 ...