DP,将能量映射为0~14,注意当选择这圈加速的时候,这圈就不能再储存能量,同时能量14可能转化为10。

 #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std; #define MAXN 105
#define MAXM 20
#define GATE 15
#define INF 0x3f3f3f3f
int A[MAXN];
int B[MAXN];
int dp[MAXN*MAXN][MAXM]; int main() {
int l ,n;
int i, j, k; #ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
#endif while (scanf("%d %d", &l, &n) != EOF) {
for (i=; i<=l; ++i)
scanf("%d", &A[i]);
for (i=; i<=l; ++i)
scanf("%d", &B[i]);
memset(dp, 0x3f, sizeof(dp));
/*
for (j=0; j<MAXM; ++j)
dp[0][j] = INF;
*/
dp[][] = ;
int p = ;
for (k=; k<=n; ++k) {
for (i=; i<=l; ++i) {
++p;
for (j=; j<GATE; ++j) {
// no speed
if (j)
dp[p][j] = min(dp[p][j], dp[p-][j-]+A[i]);
// speed
if (j+<GATE)
dp[p][j] = min(dp[p][j], dp[p-][j+]+B[i]);
}
// check the j=10 because, it can be turn from 14
dp[p][] = min(dp[p][], dp[p-][]+A[i]);
}
}
int ans = INF;
i = l*n;
for (j=; j<GATE; ++j)
ans = min(ans, dp[i][j]);
printf("%d\n", ans);
} return ;
}

【HDOJ】1494 跑跑卡丁车的更多相关文章

  1. HDU 1494 跑跑卡丁车 (DP)

    题目链接 题意 : 中文题不详述. 思路 : sum = L*N 段,每走过一段如果不用加速卡的话,能量会增20%,将20%看作1,也就是说每涨到15就要变为10,所以最多是14才不浪费. dp[i] ...

  2. HDU 1494 跑跑卡丁车

    很无爱的一道题. 题解都看得一知半解的. acm之家的题解,留着以后慢慢体会: 把这题转化为背包模型,每个%20能量算一个单位,最多有15个,如果大于5个有一个加速卡,如果大于10个有2个加速卡,如果 ...

  3. HDOJ 1009. Fat Mouse' Trade 贪心 结构体排序

    FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  4. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  5. HDOJ 1326. Box of Bricks 纯水题

    Box of Bricks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) To ...

  6. 【BZOJ 1494】【NOI 2007】生成树计数

    http://www.lydsy.com/JudgeOnline/problem.php?id=1494 这道题..因为k很小,而且我们只关心连续的k个节点的连通性,所以把连续的k个点轮廓线上的连通性 ...

  7. HDOJ 1004 Let the Balloon Rise

    Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...

  8. hdoj 1385Minimum Transport Cost

    卧槽....最近刷的cf上有最短路,本来想拿这题复习一下.... 题意就是在输出最短路的情况下,经过每个节点会增加税收,另外要字典序输出,注意a到b和b到a的权值不同 然后就是处理字典序的问题,当松弛 ...

  9. HDOJ(2056)&HDOJ(1086)

    Rectangles    HDOJ(2056) http://acm.hdu.edu.cn/showproblem.php?pid=2056 题目描述:给2条线段,分别构成2个矩形,求2个矩形相交面 ...

随机推荐

  1. [Angular 2] A Simple Form in Angular 2

    When you create a Form in Angular 2, you can easily get all the values from the Form using ControlGr ...

  2. Windows与自定义USB HID设备通信说明.

    1 .   所使用的典型 Windows API CreateFile ReadFile WriteFile 以下函数是 DDK 的内容: HidD_SetFeature HidD_GetFeatur ...

  3. 【转】关于Ubuntu的sources.list 的总结

    一.作用 文件/etc/apt/sources.list是一个普通可编辑的文本文件,保存了ubuntu软件更新的源服务器的地址.和sources.list功能一样的是/etc/apt/sources. ...

  4. hdu 5124

    bc上的题目,很水,有很多方法做吧,题意大概就是给定你票数,然后让你求出票数最多的那个下标...... 之前我用两个for循环分开写,一个是读入,然后是判断,提交就wa,后来网上看了别人的,就是不能分 ...

  5. python 下的数据结构与算法---8:哈希一下【dict与set的实现】

    少年,不知道你好记不记得第三篇文章讲python内建数据结构的方法及其时间复杂度时里面关于dict与set的时间复杂度[为何访问元素为O(1)]原理我说后面讲吗?其实就是这篇文章讲啦. 目录: 一:H ...

  6. AJAX校验用户名是否存在,焦点离开用户名、点击 【 检 查用户名 】的校验。分别用 XMLHttp 和 JQueryAJAX实现。

     XMLHttp方法: $("#name").blur(function () { var xmlhttp = new ActiveXObject("Microsoft. ...

  7. iOS UI_APPEARANCE_SELECTOR

    iOS后属性带UI_APPEARANCE_SELECTOR 可以统一设置全局作用 例如: 1>开关控件 @property(nullable, nonatomic, strong) UIColo ...

  8. ubuntu 安装 maven3

    sudo add-apt-repository ppa:natecarlson/maven3 sudo apt-get update && sudo apt-get install m ...

  9. 27 Java动态加载第三方jar包中的类

    我加载的方法是://参数fileName是jar包的路径,processorName 是业务类的包名+类名public static A load(String fileName, String pr ...

  10. poj1182 并查集

     题目连接:http://poj.org/problem?id=1182 基础并查集,需要维护与根节点关系,解析见代码: /* poj 1182 并查集 思路分析:让你分析这些话里面多少假的 只需要用 ...