#GD0000209. Giữ khoảng cách (Social Distance)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Giữ khoảng cách (Social Distance)
Social Distance
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
A restaurant has tables numbered through along a straight line. A binary string records occupancy: 1 is occupied and 0 is empty.
Any two occupied table indices must satisfy . The initial seating arrangement is guaranteed to satisfy this rule.
You may seat more people at currently empty tables without moving existing customers or violating the distance requirement. Find the maximum number of additional people who can be seated.
Input
- The first line contains integers and , the number of tables and the forbidden distance.
- The second line contains a binary string of length ; the -th character describes table .
Output
Print a non-negative integer: the maximum number of empty tables that can be occupied while all occupied table pairs remain more than positions apart.
Subtasks
- Subtask 1 (20 points): ; ; any two original
1positions differ by more than . - Subtask 2 (30 points): ; ; any two original
1positions differ by more than . - Subtask 3 (50 points): ; ; any two original
1positions differ by more than .
Examples
Input
6 1
100010
Output
1
Explanation
There are six tables with . Tables 1 and 5 are occupied. Tables 2 and 4 are adjacent to an occupied table and therefore forbidden, and table 6 is adjacent to table 5. Table 3 is two positions away from both tables 1 and 5, so exactly one additional person can sit there. Print 1.