#P5751. [NOI1999] 01 串
[NOI1999] 01 串
Description
Given integers , you are asked to design a binary string that satisfies:
- or , .
- For any consecutive substring of with length , namely (), the number of s is at least and at most .
- For any consecutive substring of with length , namely (), the number of s is at least and at most .
For example, if $N = 6, A_0 = 1, B_0 = 2, L_0 = 3, A_1 = 1, B_1 = 1, L_1 = 2$, then there exists a binary string that satisfies all the above conditions.
Input Format
Only one line containing integers, in order: (, , ). Adjacent integers are separated by one space.
Output Format
Only one line. If there is no binary string satisfying all conditions, output the integer -1. Otherwise, output the maximum possible number of s among all binary strings that satisfy all conditions.
6 1 2 3 1 1 2
3
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号