#K38982. Subsequence Arithmetic Progression
Subsequence Arithmetic Progression
Subsequence Arithmetic Progression
You are given a list of m integers and two additional integers: n and d. Your task is to determine whether there exists a subsequence of length n that can be rearranged to form an arithmetic progression with common difference d. In other words, you need to check if there exists a number a in the list such that the numbers
all appear in the list. Note that when d = 0, the problem reduces to checking whether any number appears at least n times.
It is guaranteed that if n = 1, the answer is always True
.
inputFormat
The input is provided via stdin and consists of two lines:
- The first line contains three space-separated integers: m (m is the total number of elements), n (the length of the subsequence), and d (the common difference).
- The second line contains m space-separated integers representing the list.
outputFormat
Output a single line to stdout: True
if there exists a subsequence of length n that can form an arithmetic progression with common difference d, and False
otherwise.
6 3 2
3 5 1 7 9 11
True
</p>