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

Simfonija

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

의견: 0

설명

1 \(s / 64\) \(MB / 110\) points

Almost no one believed in the virtuous abilities of the composer Marin. Specifically, not until the day

he composed his 9th symphony.

The symphony can be represented as a series of frequencies that are integer numbers. In order for

Marin to prove his talent and demonstrate that this symphony is not just one of many, he decided to

compare it with the ancient symphony "Little Night Fiesta" of the best musician in history, Stjepan. In

the stars it is written that the lengths of these two symphonies are equal to \(N\) .

Marin compares the symphonies by writing them one under the other to a piece of paper. The

symphony diversity is defined as the sum of the absolute differences of the corresponding

frequencies. The diversity of symphonies \(A\) and \(B\) of length \(N\) is:

\(N\)
\(i = 1\)
\(A\)
||
{i} {−}|}^{|

Before comparing the two symphonies, Marin will do two things. First, he will modulate his symphony

by adding an integer number \(X\) to each frequency. Then he will change no more than \(K\)

frequencies to some other arbitrary frequency value because he had a vision in the dream as well as

every top author.

Marin will choose \(X\) and change some \(K\) frequencies so that his symphony is as similar to Stjepan's,

i.e. so the defined diversity is minimal. Help Marin and calculate the smallest possible diversity to

Stjepan's symphony.

제약

In the test samples totally worth 40% of the points it will hold \(K = 0\).

1 \(s / 64\) \(MB / 110\) points

입력 형식

In the first line there are integer numbers \(N\) and \(K\) (1 ≤ \(N \le 100\,000\), 0 ≤ \(K\)\(N\) ), numbers from the

task's text.
In the second line there are \(N\) integer \(A\) {i} (-1 000 000 ≤ \(A\) ≤1 000 000) which represent frequencies of

Marin's symphony.
In the third line there are \(N\) integer \(B\) {i} (-1 000 000 ≤ \(B\) ≤1 000 000) which represent frequencies of

Stjepan's symphony.

출력 형식

In the only line print out the smallest possible diversity between Marin and Stjepan's symphony.

예제 1
입력
3 0

1 2 3

4 5 7


3 1

1 2 3

4 5 7


4 1

1 2 1 2

5 6 7 8
출력
output
output
1


0


2
설명

Clarification of the second sample:
If Marin modulates his symphony for X = 3 and changes the last frequency to 7, his symphony will then be

completely equal to Stjepan's, so the required diversity is 0.

문제 정보

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

출처 COCI 2018/2019 Contest 6

평가 및 의견

Simfonija

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

Log in to rate problems.

개별 의견

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

풀이 제출

Simfonija

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