import java.io.*;
public class Main {
/**
* http://acm.tju.edu.cn/toj/showp3457.html
* @author hunglee
*/
public static void main(String[] args) throws IOException {
StreamTokenizer in = new StreamTokenizer(new BufferedReader(
new InputStreamReader(System.in)));
PrintWriter out = new PrintWriter(System.out);
int r, a[][];
in.nextToken();
r = (int) in.nval;
a = new int[r][];
for (int i = 0; i < r; ++i) {
a[i] = new int[i + 1];
for (int j = 0; j <= i; ++j) {
in.nextToken();
a[i][j] = (int) in.nval;
}
}
for (int i = 1; i < r; ++i) {
a[i][0] += a[i - 1][0];
a[i][i] += a[i - 1][i - 1];
for (int j = 1; j < i; ++j)
a[i][j] += Math.max(a[i - 1][j - 1], a[i - 1][j]);
}
int res = -1;
for (int j = 0; j < r; ++j)
if (res < a[r - 1][j])
res = a[r - 1][j];
out.println(res);
out.flush();
}
}
Thứ Hai, 3 tháng 1, 2011
3457. Cow Pinball
Đăng ký:
Đăng Nhận xét (Atom)
Không có nhận xét nào:
Đăng nhận xét