Back
Close
  • 284

Statement

 Goal

Given a list of 1 and 0, you must regroup all the 1 at the begin of the list in a minimum number of steps. A step is the interchange of two elements located at different positions.

The expected result is the minimum number of steps required to obtain a sorted list.
Input
Line 1: an integer N.
Line 2: a list of N numbers that can take the values 0 or 1.
Output
Line 1 : The minimum number of steps to regroup all the 1 at the beginning of the list.
Constraints
1 ≤ N < 500
Example
Input
5
1 0 1 0 1
Output
1

A higher resolution is required to access the IDE