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!
    
  • 相关阅读:
    Java笔记(一)Eclipse 操作MySQL数据库的效率问题
    C# 笔记(六)关于switch 语句
    C# 笔记(五)关于static
    arcgis server 9.3初步
    C# 笔记(三)关于结构体变量
    OpenBSD随笔(一)
    Windows 脚本WSH
    Java笔记(二)Eclipse 连接SQlServer
    ArcGIS Server 9.3 JavaScript API实战(二)一个具体的小系统示例介绍
    C#笔记(二)类型转换
  • 原文地址:https://www.cnblogs.com/jiupinzhimaguan/p/13812555.html
Copyright © 2011-2022 走看看