#437
Unrated
Balancing Inversions
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Bessie and Elsie were playing a game on a boolean array AA of length 2N2N (1N1051 \leq N \leq 10^5). Bessie's score was the number of inversions in the first half of AA, and Elsie's score was the number of inversions in the second half of AA. An inversion is a pair of entries A[i]=1A[i]=1 and A[j]=0A[j]=0 where i<ji<j. For example, an array consisting of a block of 0s followed by a block of 1s has no inversions, and an array consisting of a block of XX 1s follows by a block of YY 0s has XYXY inversions.

Farmer John has stumbled upon the game board and is curious to know the minimum number of swaps between adjacent elements needed so that the game looks like it was a tie. Please help out Farmer John figure out the answer to this question.

입력

The first line of input contains NN, and the next line contains 2N2N integers that are either zero or one.

출력

Please write the number of adjacent swaps needed to make the game tied.

예제 입력 1

5
0 0 0 1 0 1 0 0 0 1

예제 출력 1

1
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.