atcoder#ABC255E. [ABC255E] Lucky Numbers
[ABC255E] Lucky Numbers
Score : points
Problem Statement
You are given a sequence of integers , and distinct integers , which are called lucky numbers.
A sequence of integers satisfying the following condition is called a good sequence.
holds for every .
Find the maximum possible number of terms that are lucky numbers in a good sequence , that is, the maximum possible number of integers between and such that .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the maximum possible number of terms that are lucky numbers in a good sequence .
9 2
2 3 3 4 -4 -7 -4 -1
-1 5
4
A good sequence contains four terms that are lucky numbers: , which is the maximum possible count.
20 10
-183260318 206417795 409343217 238245886 138964265 -415224774 -499400499 -313180261 283784093 498751662 668946791 965735441 382033304 177367159 31017484 27914238 757966050 878978971 73210901
-470019195 -379631053 -287722161 -231146414 -84796739 328710269 355719851 416979387 431167199 498905398
8