RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00130

Ograda

Gold II 골드 II
난이도
1s
시간 제한
32MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Matija needs to paint his old fence. The fence is made from \(N\) planks, each \(1\) cm in width and varying in height. To do this easy and fast, he bought himself a Super Paint Roller Deluxe. The paint roller is \(X\) cm wide. The Super Paint Roller Deluxe model comes with a catch, however. Matija must at all times touch the planks with the full width of the roller, otherwise paint drops all around and stains everything. Also, the roller must always be parallel to the ground to prevent leakage. This means that in order for Matija to use the roller safely, he needs to select \(X\) consecutive planks, and paint them from the bottom up to the top of the lowest plank in one swoop. Then he selects some other \(X\) planks, paints them and so on.

This leaves parts of some planks unpainted. Matija will have to paint such parts with a toothbrush. This is obviously quite tedious so he asked you to help him paint as much as possible using the Super Paint Roller Deluxe. Since there is more than one way to do this he is also interested in the painting that requires the minimal number of swoops.

제약

If only one of the output numbers is correct, you will receive 50% of points for that
test case. You must always follow the output format to the letter, even if you do
not calculate both numbers. In such case, you may output any integer in place of the
number you did not calculate.
8

입력 형식

The first line of input contains two integers \(N\) (\(1 \le N \le 1\,000\,000\)), number of planks, and \(X\) (\(1 \le X \le 100\,000\)), width of the Super Paint Roller. Width of the Super Paint Roller will not exceed the width of the fence.

The second line of input contains \(N\) positive integers, smaller than \(1\,000\,000\), heights of planks in the fence.

출력 형식

The first line of output should contain the smallest possible area Matija will have to paint manually.

The second line of output should contain the smallest number of swoops needed.

Scoring: If only one of the output numbers is correct, you will receive \(50\%\) of points for that test case. You must always follow the output format to the letter, even if you do not calculate both numbers. In such case, you may output any integer in place of the number you did not calculate.

First sample description: Matija needs two swoops with his roller — one to paint planks \(1\), \(2\) and \(3\) to the height of \(3\) cm, the other to paint planks \(3\), \(4\) and \(5\) to the height of \(4\) cm. Note that \(3\text{ cm}^2\) (\(2\text{ cm}^2\) on plank \(1\) and \(1\text{ cm}^2\) on plank \(5\)) are left unpainted. Also, \(3\text{ cm}^2\) on plank \(3\) are painted over twice, but that's OK.

서브태스크
서브태스크점수설명

Test 1

10점

None

Test 2

10점

None

Test 3

10점

None

Test 4

10점

None

Test 5

10점

None

Test 6

10점

None

Test 7

10점

None

Test 8

10점

None

Test 9

10점

None

Test 10

10점

None

예제 1
입력
5 3
5 3 4 4 5
출력
3
2
예제 2
입력
10 3
3 3 3 3 3 3 3 3 3 3
출력
0
4
예제 3
입력
7 4
1 2 3 4 3 2 1
출력
4
4
문제 정보

riseoj 작성

출처 COCI 2009/2010 Contest 4

평가 및 의견

Ograda

개요
출제자 난이도 Gold II 골드 II 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Ograda

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8