很无爱的一道题。

题解都看得一知半解的。

acm之家的题解,留着以后慢慢体会:

把这题转化为背包模型,每个%20能量算一个单位,最多有15个,如果大于5个有一个加速卡,如果大于10个有2个加速卡,如果等于16则边为10,2个满时清0.15就是背包的最多容量,正常跑算一个物品,权值(这里不说重量有负值)为1,价值为ai,加速也算一个物品,权值为-5,价值为bi,每次都必须选一个物品,问最后获得得最少价值。恩,有点牵强,但只要转化好理解些。

那么状态转移方程为:dp[i+1][j+1] = min(dp[i][j]+a[i],dp[i+1][j+1]);  (dp[i][j]表示跑了i个赛道能量为j时最少的耗时,a[i]为正常跑的时间,和背包的转移方程很像吧)

dp[i+1][j-5] = min(dp[i][j]+b[i],dp[i+1][j-5];

 //#define LOCAL
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std; const int maxn = + ;
const int INF = 0xffffff0;
int dp[maxn][];
int a[maxn], b[maxn]; int main(void)
{
#ifdef LOCAL
freopen("1494in.txt", "r", stdin);
#endif int L, N;
while(scanf("%d%d", &L, &N) == )
{
int tot = L * N;
int i;
for(i = ; i < L; ++i)
scanf("%d", &a[i]);
for(i = ; i < L; ++i)
scanf("%d", &b[i]);
for(i = L; i < tot; ++i)
{
a[i] = a[i % L];
b[i] = b[i % L];
} for(i = ; i <= tot; ++i)
for(int j = ; j <= ; ++j)
dp[i][j] = INF;
dp[][] = a[]; for(i = ; i < tot; ++i)
for(int j = ; j < ; ++j)
{
int k = j + ;
if(k == )
k = ;
dp[i+][k] = min(dp[i][j] + a[i], dp[i+][k]);
if(j >= )
dp[i+][j-] = min(dp[i][j] + b[i], dp[i+][j-]);
} int ans = INF;
for(i = ; i < ; ++i)
ans = min(ans, dp[tot][i]);
printf("%d\n", ans);
} return ;
}

代码君

HDU 1494 跑跑卡丁车的更多相关文章

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

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

  2. HDU 1494 题解(DP)

    题面: 跑跑卡丁车 Problem Description 跑跑卡丁车是时下一款流行的网络休闲游戏,你可以在这虚拟的世界里体验驾驶的乐趣.这款游戏的特别之处是你可以通过漂移来获得一种 加速卡,用这种加 ...

  3. 【HDOJ】1494 跑跑卡丁车

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

  4. 2019的hdu暑假作业(欢迎纠错)

    1219 遍历计数. #include<bits/stdc++.h> #define QAQ 0 using namespace std; ]; ]; int main(){ )){ me ...

  5. hdu 1520Anniversary party(简单树形dp)

    Anniversary party Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  6. HDU 1520.Anniversary party 基础的树形dp

    Anniversary party Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  7. HDU 5643 King's Game 打表

    King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...

  8. 转载:hdu 题目分类 (侵删)

    转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...

  9. hdu 1520 Anniversary party(第一道树形dp)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1520 Anniversary party Time Limit: 2000/1000 MS (Java ...

随机推荐

  1. IE6下div遮盖select的最优解决方案

    a.本节精选html5/css频道里一款IE6下div遮盖select的最优解决方案 原理:利用iframe来遮挡select,再用div来遮挡iframe,就这么简单. 1)首先,建一个div层和i ...

  2. 编写单例的 dojo class

    define([ "dojo/_base/declare" ],function( declare ){ var TimeChartService = declare(" ...

  3. Unity3D 批量图片资源导入设置

    原地址:http://blog.csdn.net/asd237241291/article/details/8433548 创文章如需转载请注明:转载自 脱莫柔Unity3D学习之旅 QQ群:[] 本 ...

  4. HDU2829 Lawrence(斜率优化dp)

    学了模板题之后上网搜下斜率优化dp的题目,然后就看到这道题,知道是斜率dp之后有思路就可以自己做不出来,要是不事先知道的话那就说不定了. 题意:给你n个数,一开始n个数相邻的数之间是被东西连着的,对于 ...

  5. cf 383 D

    D. Antimatter time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  6. POJ 1953

    //FINBONACI数列 #include <iostream> #define MAXN 100 using namespace std; int _m[MAXN]; int main ...

  7. root 授权

    错误:The user specified as a definer ('root'@'%') does not exist 解决: grant all privileges on *.* to ro ...

  8. Codeforces Round #262 (Div. 2) A B C

    题目链接 A. Vasya and Socks time limit per test:2 secondsmemory limit per test:256 megabytesinput:standa ...

  9. UVA 11361 - Investigating Div-Sum Property 数位DP

    An integer is divisible by 3 if the sum of its digits is also divisible by 3. For example, 3702 is d ...

  10. 内存分析_.Net内存原理介绍

    内存原理介绍 1.       .Net应用程序中的内存 1.1.Net内存类型 Windows使用一个系统:虚拟寻址系统.这个系统的作用是将程序可用的内存地址映射到硬件内存中的实际地址上.其实际结果 ...