#Lutece2991. a DP problem
a DP problem
Migrated from Lutece 2991 a DP problem
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
你知道DP吗? 没错,就是Dancing with Pole。(精神错乱) 块积木从左往右排成一排,其中第 块积木的高度为。由于积木排列起来不够美观,因此老实人决定拿走一些积木,且不改变剩余积木的相对位置关系,使得剩余积木构成的新排列是美观的。 不妨假设剩下了 块积木,第 块高度为,我们认为它是美观的,当且仅当存在一个 满足 的整数 满足下面两个条件:
- 对于满足 的所有整数 均有 成立。
- 对于满足 的所有整数 均有 成立。
老实人希望拿走的积木数量最少,你能告诉他最少拿走多少块积木吗?
Input
输入第一行包含一个整数 ,表示最初的积木数量。 第二行包含 个整数 ,第 个整数表示从左往右第 块积木的高度。
Output
输出包含一个非负整数,表示最少拿走多少块积木。
Samples
10
2 3 2 3 4 5 3 2 4 3
4
5
1 2 3 4 5
0
Constraints
Resources
2023 UESTC ICPC Training for Search and Dynamic Programming