#P6648. [CCC 2019] Triangle: The Data Structure

    ID: 7367 远端评测题 2000ms 128MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>动态规划 DP递推2019倍增CCC(加拿大)ST 表

[CCC 2019] Triangle: The Data Structure

Background

In Shuchong’s parallel universe, the most important data structure in computer science is the triangle.
Note: Since the original dataset package was too large, this problem removed some testdata. The removed test points are:

  • Subtask 1: 1 ~ 10
  • Subtask 2: 1 ~ 10

So the test points included in this problem are:

  • Subtask 1: 11 ~ 26
  • Subtask 2: 11 ~ 24

If you want to test the missing test points, please go to here.

Problem Description

A triangle of size mm consists of mm rows, and row ii contains ii elements.
Also, these rows must be arranged in the shape of an equilateral triangle.
For example, the following is a triangle with m=4m = 4.

Each triangle also contains sub-triangles.
For example, the triangle above contains:

  • 1010 triangles of size 11.
  • 66 triangles of size 22.
  • 33 triangles of size 33.

Note that each triangle is also a sub-triangle of itself.
Now you are given a triangle of size nn. For every sub-triangle of size kk, find the sum of the maximum value among the numbers inside that sub-triangle.

Input Format

The first line contains two integers n,kn, k, representing the size of the triangle and the required size of the sub-triangles.
The next nn lines describe the triangle: line ii contains ii integers.

Output Format

Output one integer: the sum, over all sub-triangles of size kk, 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): n1000n \le 1000.
  • Subtask 2 (75 pts): no special constraints.

For 100%100\% of the data, 1kn30001 \le k \le n \le 3000, and 00 \le each number in the triangle 109\le 10^9.

Notes

Translated from CCC 2019 Senior T5 Triangle: The Data Structure.
Translator: @一只书虫仔.

Translated by ChatGPT 5