QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#20968. Dystans społeczny I

Statistics

Straszna choroba COWVID-19 szerzy wśród krów świata. Farmer John podejmuje wszelkie środki dla ochrony stada.

Długa wąska stodoła $N$ stanowisk ($2 \leq N \leq 10^5$) w rzędzie, zajęte lub puste. Czytając ważność dystansu maksymalizuje $D$; $D$ odstęp dwóch najbliższych zajętych. Jeśli3 i8, $D = 5$.

Dwie nowe krowy w wcześniej puste dla maksimum $D$. Starych nie rusza, tylko nowe przydziela.

Wejście

Pierwszy wiersz $N$, następny ciąg01 długości $N$,0 puste1 zajęte. Co najmniej dwa0, miejsce wystarczy.

Wyjście

Wypisz maksymalne $D$ po optymalnym dodaniu dwóch, najmniejszy zajęty odstęp.

Przykład

Wejście 1

14
10001001000010

Wyjście 1

2

Uwagi

Możliwe 10x010010x0010, x nowe. $D = 2$, większe $D$ niemożliwe.

Podzadania

  • Testy2–6 spełniają $N\le 10$.
  • Testy7–8 spełniają $N\le 100$.
  • Testy9–11 spełniają $N \le 5000$.
  • Testy12–15 bez dodatkowych ograniczeń.

Autor zadania: Brian Dean

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.