7324: Triangle: The Data Structure(Problem S5)

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:0 解决:0

题目描述

输入

The first line contains two space-separated integers N and K (1 ≤ K ≤ N ≤ 3000).
Following this are N lines describing the triangle. The i-th of these lines contains i space-separated integers ai,j (0 ≤ ai,j ≤ 109 ), representing the i-th row of the triangle.
For 4 of the 15 available marks, N ≤ 1000.

输出

Output the integer sum of the maximum elements of every sub-triangle of size K.

样例输入 复制

4 2
3
1 2
4 2 1
6 1 4 2

样例输出 复制

23