#P10377. [GESP202403 六级] 好斗的牛
[GESP202403 六级] 好斗的牛
Background
Related multiple-choice / true-false problem: https://ti.luogu.com.cn/problemset/1146.
Problem Description
You have cowsheds lined up from left to right. You want to place cows into the cowsheds. The troublesome part is that your cows are very aggressive: if there are other cows nearby, they will get restless and start trouble. For cow , its attack range is , which means that if there is any other cow within cowsheds to its left or within cowsheds to its right, it will start trouble.
You want to keep a continuous segment of cowsheds and sell all the other cowsheds. What is the minimum number of cowsheds you must keep to ensure that there exists at least one way to place all cows into the remaining cowsheds such that no cow will start trouble?
Input Format
The first line contains a positive integer .
The second line contains positive integers .
The third line contains positive integers .
Output Format
Output one line with one integer representing the answer.
2
1 2
1 2
4
3
1 2 3
3 2 1
7
Hint
Sample 1 Explanation
Keep cowsheds , and place two cows in cowsheds and , respectively.
Constraints
- For of the testdata, is guaranteed.
- For another of the testdata, is guaranteed.
- For of the testdata, is guaranteed.
- For all testdata, , are guaranteed.
Translated by ChatGPT 5