P28468 [洛谷] [COCI2009-2010#4] FENCE
提高-
题目描述

Problem Description

Translated from COCI 2010.02 T4 "OGRADA"

Matija's fence consists of $N$ planks, numbered from $1$ to $N$ from left to right. The height of the $i$-th plank is $h_i$, and each plank has a width of $1$ cm.

Matija wants to use a roller brush with a width of $X$ cm to paint the planks. When using the roller brush, it must be in full contact with the fence (no partial contact allowed), and the roller must be parallel to the ground. Therefore, each time he paints, Matija will choose $x$ consecutive planks and paint them from bottom to top up to the height of the shortest plank among these $x$ planks.

According to these rules, some planks may not be painted with the roller brush, and Matija will have to use a toothbrush to "paint" the remaining parts. Therefore, please help him calculate the minimum area in square centimeters that he needs to paint with a toothbrush. He also wants to know the minimum number of times he needs to use the roller brush to achieve this minimum toothbrush painting area.

Input Format

The first line contains $N$ and $X$.
The second line contains $h_1$ to $h_N$.

Output Format

Two lines.
The first line contains an integer representing the minimum area in square centimeters that Matija needs to paint with a toothbrush.
The second line contains an integer representing the minimum number of times he needs to use the roller brush.

Sample Input and Output

Sample Input #1

5 3
5 3 4 4 5

Sample Output #1

3
2

Sample Input #2

10 3
3 3 3 3 3 3 3 3 3 3

Sample Output #2

0
4

Sample Input #3

7 4
1 2 3 4 3 2 1

Sample Output #3

4
4

Notes

Sample Explanation 1

pp.png

Data Range and Hints

$1 \leq N \leq 10^6$, $1 \leq X \leq 10^5$, $1 \leq h_i \leq 10^6$.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
5 3 5 3 4 4 5
样例输出
3 2