跑跑卡丁车(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版本的升级版本,该产品现已开源并 ...
随机推荐
- .net core Redis库 CSRedis
由于servicestack.redis收费,基于有人说StackExchange.Redis 使用会出现一些问题比如会超时, 找到了CSRedis这个库,很强大很实用.另外有兴趣的朋友还可以试试另一 ...
- Redis 4.x RCE 复现学习
攻击场景: 能够访问远程redis的端口(直接访问或者SSRF) 对redis服务器可以访问到的另一台服务器有控制权 实际上就是通过主从特性来 同步传输数据,同时利用模块加载来加载恶意的用来进行命令执 ...
- ArcGIS Python 获得坐标
import arcpy infc = arcpy.GetParameterAsText(0) # Identify the geometry field # desc = arcpy.Describ ...
- MySQL 中<=>用法(长知识)
https://www.runoob.com/mysql/mysql-operator.html MySQL 运算符 本章节我们主要介绍 MySQL 的运算符及运算符的优先级. MySQL 主要有以下 ...
- MAC-下安装php-redis扩展
MAC下安装php-redis扩展 下载php-redis,地址:https://nodeload.github.com/nicolasff/phpredis/zip/master 下载完成得到p ...
- docker 管理应用程序数据和网络管理
Volume和Bind Mount Docker提供三种不同方式将数据从宿主机挂载到容器中:volumes,bind mounts和tmpfs volumes:Docker管理宿主机文件系统的一部分( ...
- jeecg中的datagrid显示一条记录为橙色表示完结
效果如图: 1.操作小结后面的已完结js $(document).ready(function(){ $('.datagrid-toolbar').children("span") ...
- ResourceUtils 创建资源目录工具类
package com.jcf.utilsdemo; import android.content.Context; import android.content.res.Resources; pub ...
- C# VS预生成事件命令行 和 生成后事件命令行
宏 说明 $(ConfigurationName) 当前项目配置的名称(例如,“Debug|Any CPU”). $(OutDir) 输出文件目录的路径,相对于项目目录.这解析为“输出目录”属性的值. ...
- 用es6实现一个promsie
Promise 使用方法:https://www.runoob.com/w3cnote/javascript-promise-object.html 直接上代码,相关的解释都在代码的注释里面,这里以m ...