QOJ.ac

QOJ

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

#20968. Distanciamiento social I

Statistics

Terrible enfermedad COWVID-19 se extiende entre vacas mundiales. Farmer John toma toda precaución para proteger ganado.

Granero largo estrecho, $N$ puestos ($2 \leq N \leq 10^5$) en fila, ocupados o vacíos. Tras leer importancia de distancia, maximiza $D$; $D$ es distancia de dos ocupados más cercanos. Si3 y8, $D = 5$.

Dos nuevas vacas en puestos antes vacíos para máximo $D$. No mueve existentes, solo asigna nuevas.

Entrada

Primera línea $N$, siguiente cadena01 longitud $N$,0 vacío1 ocupado. Al menos dos0, suficiente lugar.

Salida

Imprime máximo $D$ tras colocar dos óptimamente, menor distancia entre ocupados.

Ejemplos

Entrada 1

14
10001001000010

Salida 1

2

Nota

Puede 10x010010x0010, x nuevas. $D = 2$, imposible mayor $D$.

Subtareas

  • Pruebas2–6 cumplen $N\le 10$.
  • Pruebas7–8 cumplen $N\le 100$.
  • Pruebas9–11 cumplen $N \le 5000$.
  • Pruebas12–15 sin límites adicionales.

Autor del problema: 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.