#K69732. Maximum Distance to Nearest Exit

    ID: 33152 Type: Default 1000ms 256MiB

Maximum Distance to Nearest Exit

Maximum Distance to Nearest Exit

You are given a row of n seats and m exit points. Each exit point is located at a specified seat position. You are also given an occupancy string of length n where each character is either '0' (empty) or '1' (occupied).

Your task is to determine the maximum distance any visitor (i.e. a seat with '1') needs to walk to reach the nearest exit. The distance between seat positions x and y is given by \(|x-y|\), where the seats are numbered from 1 to n.

If there are no visitors, the answer is 0.

inputFormat

The input is read from standard input and consists of three lines:

  • The first line contains two integers n and m, where n is the number of seats and m is the number of exit points.
  • The second line contains m integers, representing the positions of the exit points. These positions are given in increasing order and are 1-indexed.
  • The third line contains a string of length n consisting of the characters '0' and '1'. '0' means the seat is empty and '1' means the seat is occupied.

outputFormat

Output a single integer to standard output, which is the maximum distance any occupied seat has to the nearest exit point.

## sample
10 3
2 5 9
1001000010
1