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 ...
随机推荐
- Yii2分页
Yii中的分页功能主要由yii\web: Linkable接口.yii\widgets: LinkPager类和yii\data: Pagination类三个组成 yii\data: Paginati ...
- BZOJ-1143&&BZOJ-2718 祭祀river&&毕业旅行 最长反链(Floyed传递闭包+二分图匹配)
蛋蛋安利的双倍经验题 1143: [CTSC2008]祭祀river Time Limit: 10 Sec Memory Limit: 162 MB Submit: 1901 Solved: 951 ...
- 【poj1962】 Corporative Network
http://poj.org/problem?id=1962 (题目链接) 时隔多年又一次写带权并查集. 题意 n个节点,若干次询问,I x y表示从x连一条边到y,权值为|x-y|%1000:E x ...
- Laravel 5.3 中文文档翻译完成
经过一个多月的紧张翻译和校对,翻译完成.以下是参与人员: Laravel 5.3 中文文档翻译完成 稿源:七星互联www . qixoo.com 文档地址在此:https://laravel-chin ...
- JSTL标签库简介
核心标签库 http://java.sun.com/jsp/jstl/core <c:catch>,<c:url>的使用 <!-- 捕获异常 --> <c:c ...
- C#中Delegate和Event以及它们的区别(转载)
一.Delegate委托可以理解为一个方法签名. 可以将方法作为另外一个方法的参数带入其中进行运算.在C#中我们有三种方式去创建委托,分别如下: public delegate void Print( ...
- mybatis 使用resultMap实现关联数据的查询(association 和collection )
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "- ...
- WPF控件模拟双击事件
Action a = () => { i += ; ) { Interval = }; timer.Elapsed += (sender, e) => { timer.Enabled = ...
- RHEL6.4记录一次添加一块新分区的操作
首先看了下挂载点及目录 fdisk /dev/sda [root@box ~]# fdisk /dev/sda WARNING: DOS-compatible mode is deprecated. ...
- C#面向对象面试题集锦
1.简述C#中的虚方法 答:注意:当使用virtual关键字修饰符后,不允许再同时使用abstract,static,或override关键字进行修饰 使用virtual关键字修饰的方法就是虚方法,虚 ...