## The Christmas Swap

View as PDF

Points: 15
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

ImaxRed and ImaxBlue are preparing for Christmas. They have a row of Christmas lights, each initially either blue or red. They have enough time to do swap operations. In each swap operation, a single light is switched with an adjacent one. Imaxblue would like to know the length of the longest possible sequence of consecutive blue lights after or fewer swaps. ImaxRed would like to know the same thing for red lights.

#### Input Specification

Line : Two space separated integers and .
Line : integers, either 1 or 0, 1 a representing blue light and 0 representing a red light.

#### Output Specification

Two integers, the maximum number of consecutive blue lights after swaps, and the maximum number of consecutive red lights after swaps.

#### Sample Input

8 3
10101110

#### Sample Output

5 2

#### Explanation

We swap the following pairs (1-indexed): , , to get consecutive blue lights. allows us to have consecutive red lights. There is no combination that will result in more consecutive lights.