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

Kockice

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

의견: 0

설명

\(6^{th}\) round, March \(8^{th}\), 2014

Mirko and Slavko are playing with bricks. Both of them have their own pile of bricks. The piles consist
of N columns (where N is an odd number). The number of bricks in the i^{th} column of Mirko's pile is
labeled with m_{i} and Slavko's pile with s_{i}.
They have decided to create two equal piles constructed in a way that the heights of columns are
strictly descending at first and then strictly ascending (see right image below) and the heights of
adjacent columns differ exactly by 1 (see image). The lowest of the columns must have an equal
number of columns to the left and to the right of it.
The piles can be modified by removing one brick from the top of some column and throw it out the
window (they cannot reuse it) or by taking one brick from the box and place it on the top of some
column (there is an infinite amount of bricks in the box). Removing or placing a brick counts as one
move.
You have to determine the minimal number of moves so that Mirko and Slavko can rearrange their
piles in the described way.

On the left, there is a pile with column heights 3, 2, 0, 1 and 4.
On the right, there is one of the possible final layouts.

제약

In test cases worth 40% of total points, the following will hold: \(1 \le N \le 1\,000\) i \(0 \le m_{i}\), \(s_{i} \le 1\,000\).

입력 형식

The first line of input contains an odd number N. (\(1 \le N \le 300\,000\)), the number of columns in both
piles.
The second line of input contains N integers m_{i} (\(0 \le m_{i} \le 10^{12}\)), column heights in Mirko's pile.
The third line of input contains N integers s_{i} (\(0 \le s_{i} \le 10^{12}\)), column heights in Slavko's pile.

출력 형식

The first and only line of output must contain the minimal number of moves.

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

Clarification of the first example: Mirko places two bricks on the top the first column in his pile and
Slavko places one brick on the top of the third column in his pile.

문제 정보

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

출처 COCI 2013/2014 Contest 6

평가 및 의견

Kockice

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

Log in to rate problems.

개별 의견

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

풀이 제출

Kockice

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