logo AlgoBeat OnlineJudge
登录 注册

#216750. [GKS 2020 #A] Plates

内存限制:1024 MiB 时间限制:3000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Dr. Patel has stacks of plates. Each stack contains plates. Each plate has a positive beauty value, describing how beautiful it looks.

Dr. Patel would like to take exactly plates to use for dinner tonight. If he would like to take a plate in a stack, he must also take all of the plates above it in that stack as well.

Help Dr. Patel pick the plates that would maximize the total sum of beauty values.

输入格式

The first line of the input gives the number of test cases, . test cases follow. Each test case begins with a line containing the three integers , and . Then, lines follow. The -th line contains integers, describing the beauty values of each stack of plates from top to bottom.

输出格式

For each test case, output one line containing Case #x: y, where is the test case number (starting from 1) and is the maximum total sum of beauty values that Dr. Patel could pick.

样例

样例输入 1

2
2 4 5
10 10 100 30
80 50 10 50
3 2 3
80 80
15 50
20 10

样例输出 1

Case #1: 250
Case #2: 180

数据范围与提示

In Sample Case #1, Dr. Patel needs to pick plates:

  • He can pick the top plates from the first stack ().
  • He can pick the top plates from the second stack () .

In total, the sum of beauty values is .

In Sample Case #2, Dr. Patel needs to pick plates:

  • He can pick the top plates from the first stack ().
  • He can pick no plates from the second stack.
  • He can pick the top plate from the third stack ().

In total, the sum of beauty values is .

Limits

.

.

.

The beauty values are between and , inclusive.

Test Set 1

.

Test Set 2

.