• Social distancing (distance)


    Description


    A terrible new disease, COVID-19, has begun to spread all over the world. People try to take as many precautions as possible to protect themselves from infection, one of which is to increase the "social distance" between people.
    Now consider such a problem: There is a row of narrow seats in the waiting hall of a train station, with consecutive (N) seats in a straight line. Some of these seats are currently occupied and some are empty. After understanding the importance of "social distance" (D), later people hope to maximize (D), where (D) is the distance between the two nearest occupied seats. For example, if the seats 3 and 8 are the closest seats, then (D=5).
    Recently, a new passenger came and wanted to find a seat. He needs to determine which previously vacant seat should be taken so that the final value of (D) is still as large as possible.
    Note: Passengers who have already sat down cannot move.

    Format


    Input

    The first line of input contains an integer (N), which represents the number of consecutive seats in a row.
    The second line contains strings of length (N), 0 and 1, which describe the occupancy of the (N) seats, 0 means empty seats, and 1 means already occupied.
    To simplify the problem, the string has at least one 0, so there is at least a seat for the new passenger, and at least one 1.

    Output

    Output an integer representing the maximum (D) after the new passenger is seated.

    Sample


    Input

    14
    10001001000010
    

    Output

    2
    

    Hint


    For the data of (100\%), (2 le N le 100000).

    Sample Code


    Code is not available!
    
  • 相关阅读:
    subdomain takeover(子域名劫持)
    Kali linux UI missing close/minimize/maximize button
    vim比较多个文件内容
    vim多行缩进或缩出
    记一次centos8开机故障Internal error xfs XFS_WANT_CORRUPTED_GOTO
    Windows批处理(cmd/bat)常用命令小结
    git table无法自动补全问题
    git升级到指定版本
    linux 下find命令 --查找文件名
    Docker Nexus3 重置 admin 密码
  • 原文地址:https://www.cnblogs.com/jiupinzhimaguan/p/13812555.html
Copyright © 2020-2023  润新知