#P6648. [CCC 2019] Triangle: The Data Structure
[CCC 2019] Triangle: The Data Structure
Description
A triangle of size consists of rows, and row contains elements.
Also, these rows must be arranged in the shape of an equilateral triangle.
For example, the following is a triangle with .

Each triangle also contains sub-triangles.
For example, the triangle above contains:
- triangles of size .
- triangles of size .
- triangles of size .
Note that each triangle is also a sub-triangle of itself.
Now you are given a triangle of size . For every sub-triangle of size , find the sum of the maximum value among the numbers inside that sub-triangle.
Input Format
The first line contains two integers , representing the size of the triangle and the required size of the sub-triangles.
The next lines describe the triangle: line contains integers.
Output Format
Output one integer: the sum, over all sub-triangles of size , of the maximum value inside each sub-triangle.
4 2
3
1 2
4 2 1
6 1 4 2
23
Hint
Constraints
- Subtask 1 (25 pts): .
- Subtask 2 (75 pts): no special constraints.
For of the data, , and each number in the triangle .
Notes
Translated from CCC 2019 Senior T5 Triangle: The Data Structure.
Translator: @一只书虫仔.
Translated by ChatGPT 5
京公网安备 11011102002149号