DP:Cow Bowling(POJ 3176)

题目很简单的,我就不翻译了,简单来说就是储存每一行的总数,类似于状态压缩
#include <stdio.h>
#include <stdlib.h>
#define MAX(a,b) a>b?a:b int Cow_Map[][]; void Search(const int); int main(void)
{
int N, i, line;
while (~scanf("%d", &N))
{
Cow_Map[][] = ;
for (line = ; line <= N; line++)//读图
for (i = ; i < line; i++)
scanf("%d", &Cow_Map[line][i]);
Search(N);
}
return ;
} void Search(const int N)
{
int line, i, ans = ;
for (line = ; line <= N; line++)
{
Cow_Map[line][] = Cow_Map[line][] + Cow_Map[line - ][];
for (i = ; i < line - ; i++)
Cow_Map[line][i] = (MAX(Cow_Map[line - ][i - ], Cow_Map[line - ][i])) + Cow_Map[line][i];
Cow_Map[line][line - ] = Cow_Map[line][line - ] + Cow_Map[line - ][line - ];
}
for (i = ; i < N; i++)
ans = MAX(Cow_Map[N][i], ans);
printf("%d\n", ans);
}
DP:Cow Bowling(POJ 3176)的更多相关文章
- (01背包变形) Cow Exhibition (poj 2184)
http://poj.org/problem?id=2184 Description "Fat and docile, big and dumb, they look so stupid ...
- DP:Corn Fields(POJ 3254)
北大教你如何高效养牛(误)(点我查看) 2015-08-21: 问题的大意就是有一片稻田,里面有很多坑,你要在上面种稻谷,然后呢田里面还会养牛,牛不喜欢扎堆吃饭,所以呢你种的稻谷要间隔种在坑里面,所 ...
- H-The Cow Lineup(POJ 1989)
The Cow Lineup Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 5367 Accepted: 3196 De ...
- 水dp第二天(背包有关)
水dp第二天(背包有关) 标签: dp poj_3624 题意:裸的01背包 注意:这种题要注意两个问题,一个是要看清楚数组要开的范围大小,然后考虑需要空间优化吗,还有事用int还是long long ...
- POJ 3268 Silver Cow Party (双向dijkstra)
题目链接:http://poj.org/problem?id=3268 Silver Cow Party Time Limit: 2000MS Memory Limit: 65536K Total ...
- POJ 2018 Best Cow Fences(二分答案)
题目链接:http://poj.org/problem?id=2018 题目给了一些农场,每个农场有一定数量的奶牛,农场依次排列,问选择至少连续排列F个农场的序列,使这些农场的奶牛平均数量最大,求最大 ...
- 01背包问题:Charm Bracelet (POJ 3624)(外加一个常数的优化)
Charm Bracelet POJ 3624 就是一道典型的01背包问题: #include<iostream> #include<stdio.h> #include& ...
- Scout YYF I(POJ 3744)
Scout YYF I Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5565 Accepted: 1553 Descr ...
- 洛谷 P2986 [USACO10MAR]伟大的奶牛聚集Great Cow Gat…(树规)
题目描述 Bessie is planning the annual Great Cow Gathering for cows all across the country and, of cours ...
随机推荐
- BZOJ-3524 Couriers 可持久化线段树
可持久化线段树,其实就是类主席树了.. 3524: [Poi2014]Couriers Time Limit: 20 Sec Memory Limit: 128 MB Submit: 1124 Sol ...
- 【poj1080】 Human Gene Functions
http://poj.org/problem?id=1080 (题目链接) 题意 给出两个只包含字母ACGT的字符串s1.s2,可以在两个字符串中插入字符“-”,使得s1与s2的相似度最大. Solu ...
- 洛谷P2327 [SCOI2005] 扫雷
题目描述 输入输出格式 输入格式: 第一行为N,第二行有N个数,依次为第二列的格子中的数.(1<= N <= 10000) 输出格式: 一个数,即第一列中雷的摆放方案数. 输入输出样例 输 ...
- Tomcat Server Configuration Automation Reinforcement
目录 . 引言 . 黑客针对WEB Server会有那些攻击面 . 针对Tomcat Server可以做的安全加固 . Managing Security Realms with JMX . 实现对T ...
- 关于mysql乱码的问题
ALTER TABLE TABLE_NAME CONVERT TO CHARACTER SET utf8 COLLATE UTF8_GENERAL_CI; 第一步,用mysql的自带修复工具在bin文 ...
- --hdu 1050 Moving Tables(贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1050 AC code: #include<stdio.h> #include<str ...
- Linux下修改计算机名
SuSe操作系统: 1. 修改/etc/HOSTNAME 文件 ,其内容为计算机名. 输入命令:vi /etc/HOSTNAME 使用键盘上的 x 键一个一个删除所有内容 ,然后使用键盘上的 i ...
- Html Div 拖拽
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- spark1.6配置sparksql 的元数据存储到postgresql中
1:首先配置hive-site.xml <configuration> <property> <name>javax.jdo.option.ConnectionUR ...
- MSN
msn (微软软件) 编辑 MSN,全称Microsoft Service Network,是微软公司(Microsoft)旗下的门户网站. MSN(门户网站)提供包括必应搜索.文娱.健康.理财.汽车 ...