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

S2. Symmetric Mountains

Unrated 레이팅 미적용
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Rebecca is a tour guide and is trying to market the Rocky Mountains
for her magazine. She recently took a beautiful picture consisting of
\(N\) mountains where the \(i\)-th mountain from the left has a height
\(h_i\). She will crop this picture for
her magazine, by possibly removing some mountains from the left side of
the picture and possibly removing some mountains from the right side of
the picture. That is, a crop consists of consecutive mountains starting
from the \(l\)-th to the \(r\)-th mountain where \(l \le r\). To please her magazine readers,
Rebecca will try to find the most symmetric crop.

We will measure the asymmetric value of a crop as the sum of
the absolute difference for every pair of mountains equidistant from the
midpoint of the crop. To help understand that definition, note that the
absolute value of a number \(v\),
written as \(|v|\), is the non-negative
value of \(v\): for example \(|-6| = 6\) and \(|14|=14\). The asymmetric value of a crop
is the sum of all \(|h_{l + i} - h_{r - i}|\) for \(0 \le i \le \frac{r - l }{2}\). To put that formula in a different way, we pair up the
mountains working from the outside in toward the centre, calculate the
absolute difference in height of each of these pairs, and sum them
up.

Because Rebecca does not know how wide the picture needs to be, for
all possible crop lengths, find the asymmetric value of the most
symmetric crop (the crop with the minimum asymmetric value).

제약

\(l \le r\)
\(0 \le i \le \frac{r - l }{2}\)

입력 형식

The first line consists of an integer \(N\), representing the number of mountains
in the picture.

The second line consists of \(N\)
space-separated integers, where the \(i\)-th integer from the left represents
\(h_i\).

출력 형식

Output on one line \(N\)
space-separated integers, where the \(i\)-th integer from the left is the
asymmetric value of the most symmetric picture of crops of length \(i\).

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

1

34점

\(1 \le N \le 300\)\(0 \le h_i \le 10^5\) — None

2

33점

\(1 \le N \le 5000\)\(0 \le h_i \le 10^5\) — Height of mountains are in non-decreasing order from left to right.

3

33점

\(1 \le N \le 5000\)\(0 \le h_i \le 10^5\) — None

예제 1
입력
7
3 1 4 1 5 9 2
출력
0 2 0 5 2 10 10
설명

We will show why the fifth value from the left is 2. Let us try to
compute all the asymmetric values of crops with length 5.

The height of the mountains in the first crop is \([3, 1, 4, 1, 5]\). The asymmetric value of
this crop is \(|3 - 5| + |1 - 1| + |4 - 4| = 2\).

The height of the mountains in the second crop is \([1, 4, 1, 5, 9]\). The asymmetric value of
this crop is \(|1 - 9| + |4 - 5| + |1 - 1| = 9\).

The height of the mountains in the last crop is \([4, 1, 5, 9, 2]\). The asymmetric value of
this crop is \(|4 - 2| + |1 - 9| + |5 - 5| = 10\).

Hence, the most symmetric crop of length 5 is 2.

예제 2
입력
4
1 3 5 6
출력
0 1 3 7
설명

This sample satisfies the second subtask. Note that the only crop of
length 4 is \([1,3,5,6]\) which has
asymmetric value of \(|1 - 6| + |3 - 5| = 7\).

문제 정보

생성자가 기록되지 않았습니다.

출처 CCC 2023 Senior

평가 및 의견

S2. Symmetric Mountains

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

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

풀이 제출

S2. Symmetric Mountains

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