Picking Numbers
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 122.174 megabytes
Given an array of integers, find and print the maximum number of integers you can select from the array such that the absolute difference between any two of the chosen integers is less or equal to 1.
Input
The first line contains a single integer n (2 ≤ n ≤ 100), denoting the size of the array. The second line contains n integers describing the respective values of a[0]
, a[1]
, ..., a[n-1]
(0 < a[i]
< 100).
Output
Print a single integer denoting the maximum number of integers you can choose from the array such that the absolute difference between any two of the chosen integers is ≤ 1. The answer is ≥ 2.
Examples
Input #1
Answer #1
Input #2
Answer #2
Submissions 5K
Acceptance rate 44%