cf D. Dima and Hares
http://codeforces.com/contest/358/problem/D
题意:ai代表相邻的两个野兔都没有吃食物情况下的快乐系数,bi代表的是在相邻的两个野兔中有一个吃到食物的快乐系数,ci代表的是相邻的两个野兔都迟到事物的快乐系数,给你n个野兔的快乐系数,求最大快乐系数。
dp[i][0]表示先于i+1个吃到食物的最大快乐系数,dp[i][1]表示后于i+1个吃到食物的最大快乐系数。
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 10000
using namespace std; int n;
int a[maxn],b[maxn],c[maxn];
int dp[maxn][]; int main()
{
while(scanf("%d",&n)!=EOF)
{
for(int i=; i<=n; i++)
scanf("%d",&a[i]);
for(int i=; i<=n; i++)
scanf("%d",&b[i]);
for(int i=; i<=n; i++)
scanf("%d",&c[i]);
dp[n][]=a[n];
dp[n][]=b[n];
for(int j=n-; j>=; j--)
{
dp[j][]=max(dp[j+][]+b[j],dp[j+][]+a[j]);
dp[j][]=max(dp[j+][]+b[j],dp[j+][]+c[j]);
}
printf("%d\n",dp[][]);
}
return ;
}
cf D. Dima and Hares的更多相关文章
- Codeforces 358 D. Dima and Hares
dp[i][0]表示i号兔子先于i-1号兔子喂食,dp[i][1]反过来. 倒着DP D. Dima and Hares time limit per test 2 seconds memory li ...
- CF358D Dima and Hares
CF358D Dima and Hares 洛谷评测传送门 题目描述 Dima liked the present he got from Inna very much. He liked the p ...
- cf D. Dima and Trap Graph
http://codeforces.com/contest/366/problem/D 遍历下界,然后用二分求上界,然后用dfs去判断是否可以. #include <cstdio> #in ...
- CF 366E Dima and Magic Guitar(最远哈密顿距离)
题目链接:http://codeforces.com/problemset/problem/366/E 题意:给出一个n*m的数字矩阵A,每个矩阵元素的范围[1,K].给出一个长度为s的数字串B,B的 ...
- Codeforces Round #208 (Div. 2) 358D Dima and Hares
题目链接:http://codeforces.com/problemset/problem/358/D 开始题意理解错,整个就跪了= = 题目大意:从1到n的位置取数,取数的得到值与周围的数有没有取过 ...
- [CodeForce]358D Dima and Hares
有N<3000只宠物要喂,每次只能喂一只,每喂一只宠物,宠物的满足度取决于: 1 紧靠的两个邻居都没喂,a[i] 2 邻居中有一个喂过了,b[i] 3 两个邻居都喂过了,c[i] 把所有宠物喂一 ...
- cf E. Dima and Magic Guitar
http://codeforces.com/contest/366/problem/E |x1-x2|+|y1-y2|有四种情况 1.-(x1-x2)+(y1-y2); 2.(x1-x2)-(y1-y ...
- cf C. Dima and Salad
http://codeforces.com/contest/366/problem/C 转化为背包问题,可以将a[i]-b[i]*k看成重量,a[i]为价值: 因为a[i]-b[i]*k可以为负数,所 ...
- cf B. Dima and To-do List
http://codeforces.com/contest/366/problem/B 从0到k枚举起点,然后i+k判断是不是i+k>=n如果是i=(i+k)%n;否则i=i+k; #inclu ...
随机推荐
- 【转】Everything中文绿色版在Win7/8用不了?
原文网址:http://pcedu.pconline.com.cn/472/4727542.html 用过Everything的朋友应该都知道,Everything有两个版本,一个是安装版,另一个是E ...
- HDU_2054——A=B问题
Problem Description Give you two numbers A and B, if A is equal to B, you should print "YES&quo ...
- arrayPointer
1,分别使用指针加减 int wages[2] = {100000000,20000000}; int *pw = wages or int *pw = &wages[0] 表示指针指向数组的 ...
- powerdesigner 字段大小写转换\id 自增
转换:tools --> model options-->naming convention name code 自增: 在你所要设为自增型的键上(比如你的id)双击 ,弹出一个Colu ...
- js时间基本操作
js 获取前一天的时 var today=new Date(); var yesterday_milliseconds=today.getTime()-1000*60*60*24; var yeste ...
- StoryBoard 页面传值
如图新建一个viewController和DetailViewController VC 和DetailVC 联线的Idetnifier 设置为:GoDetailVC ViewController主要 ...
- HID class request.
1.get report. 2.set report report request. Get report范例: 下面这张图是Host跟Device来要设备描述符. USB主机向设备控制器请求数据时, ...
- Could not find the Visual SourceSafe Internet Web Service connection information
Visual SourceSafe Internet---------------------------Could not find the Visual SourceSafe Internet W ...
- JS客户端读取Excel文件插件js-xls使用方法
js-xls是一款客户端读取Excel的插件,亲测IE11.FireFox.Chrome可用,读取速度也客观. 插件Demo地址:http://oss.sheetjs.com/js-xlsx/ ...
- zip命令的使用
zip命令可以用来将文件压缩成为常用的zip格式.unzip命令则用来解压缩zip文件. 1. 我想把一个文件abc.txt和一个目录dir1压缩成为yasuo.zip: # zip -r yasuo ...