POJ-3176-Cow Bowling
来源:互联网 发布:java date 加减 编辑:程序博客网 时间:2024/05/18 14:24
Cow Bowling
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 17747 Accepted: 11827
Description
The cows don't use actual bowling balls when they go bowling. They each take a number (in the range 0..99), though, and line up in a standard bowling-pin-like triangle like this:
Given a triangle with N (1 <= N <= 350) rows, determine the highest possible sum achievable.
7 3 8 8 1 0 2 7 4 4 4 5 2 6 5Then the other cows traverse the triangle starting from its tip and moving "down" to one of the two diagonally adjacent cows until the "bottom" row is reached. The cow's score is the sum of the numbers of the cows visited along the way. The cow with the highest score wins that frame.
Given a triangle with N (1 <= N <= 350) rows, determine the highest possible sum achievable.
Input
Line 1: A single integer, N
Lines 2..N+1: Line i+1 contains i space-separated integers that represent row i of the triangle.
Lines 2..N+1: Line i+1 contains i space-separated integers that represent row i of the triangle.
Output
Line 1: The largest sum achievable using the traversal rules
Sample Input
573 88 1 02 7 4 44 5 2 6 5
Sample Output
30
Hint
Explanation of the sample:
7 * 3 8 * 8 1 0 * 2 7 4 4 * 4 5 2 6 5The highest score is achievable by traversing the cows as shown above.
Source
USACO 2005 December Bronze
#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;int a[360][360];int main(){ int n,i,j; scanf("%d",&n); for(i=0;i<n;i++) { for(j=0;j<=i;j++) scanf("%d",&a[i][j]); } for(i=n-2;i>=0;i--) { for(j=0;j<=i;j++) { if((a[i][j]+a[i+1][j])>(a[i+1][j+1]+a[i][j])) a[i][j]+=a[i+1][j]; else a[i][j]+=a[i+1][j+1]; } } printf("%d\n",a[0][0]); return 0;}
0 0
- POJ 3176 COW BOWLING
- POJ 3176 Cow Bowling
- poj 3176 Cow Bowling
- POJ 3176 Cow Bowling
- Poj 3176 Cow Bowling
- POJ 3176 Cow Bowling
- poj 3176 Cow Bowling
- poj 3176 Cow Bowling
- POJ 3176 Cow Bowling
- POJ 3176 Cow Bowling
- poj 3176 cow bowling
- POJ 3176 Cow Bowling
- POJ 3176 Cow Bowling
- POJ 3176 Cow Bowling
- poj 3176 Cow Bowling
- poj 3176 Cow Bowling
- POJ 3176 Cow Bowling
- poj 3176 Cow Bowling
- BZOJ 3158: 千钧一发 && BZOJ 3275: Number && 考试的T2【网络流
- Android 之是时候沉浸式状态栏到了
- hadoop之hdfs api的简单使用
- Python:深拷贝与浅拷贝
- 最全面的Android Webview详解
- POJ-3176-Cow Bowling
- 模拟自然动画的精髓——TimeInterpolator与TypeEvaluator
- java泛型、通配符、泛型数据和方法的用例代码
- 1097. Deduplication on a Linked List
- 【JZOJ4799】我的快乐时代
- Linux 安装 MongoDB总结
- POJ 2262 Goldbach's Conjecture 简单的素数
- 3 Python 函数传参_(不)可变类型
- hdu1083——Courses(匈牙利算法)