zoukankan      html  css  js  c++  java
  • 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!
    
  • 相关阅读:
    织梦会员注册邮箱验证发送邮件配置教程
    垃圾回收
    0910
    0909
    vs2008 打包中添加卸载工具
    CLR
    委托
    软考之存储方式
    软考之面向对象-关系
    软考之合同法
  • 原文地址:https://www.cnblogs.com/jiupinzhimaguan/p/13812555.html
Copyright © 2011-2022 走看看