QOJ.ac

QOJ

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

#20968. Soziale Distanz I

Statistics

Schreckliche Krankheit COWVID-19 verbreitet sich unter Kühen weltweit. Farmer John trifft alle Vorsichtsmaßnahmen fürs Vieh.

Lange schmale Scheune mit $N$ Ständen ($2 \leq N \leq 10^5$) in Reihe, besetzt oder leer. Liest Wichtigkeit der Distanz, maximiert $D$; $D$ Abstand nächster besetzter. Bei3 und8 gilt $D = 5$.

Zwei neue Kühe in vorher leere Stände für größtes $D$. Alte nicht bewegbar, nur neue zuordnen.

Eingabe

Erste Zeile $N$, nächste01-Zeichenfolge Länge $N$;0 leer1 besetzt. Mindestens zwei0, Platz reicht.

Ausgabe

Gib größtes $D$ nach optimalem Hinzufügen zweier aus, Mindestabstand besetzter.

Beispiele

Eingabe 1

14
10001001000010

Ausgabe 1

2

Hinweis

Möglich 10x010010x0010, x neue. $D = 2$, größeres $D$ unmöglich.

Teilaufgaben

  • Tests2–6 erfüllen $N\le 10$.
  • Tests7–8 erfüllen $N\le 100$.
  • Tests9–11 erfüllen $N \le 5000$.
  • Tests12–15 ohne weitere Bedingungen.

Aufgabenautor: 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.