#C5078. Minimum Adjacent Year Difference
Minimum Adjacent Year Difference
Minimum Adjacent Year Difference
You are given an integer n representing the number of coins and a list of n integers representing the years in which the coins were minted. Your task is to sort these years and then find the minimum difference between two consecutive years in the sorted sequence.
Formally, if the sorted years are \(y_1, y_2, \dots, y_n\), compute the differences \(y_2 - y_1, y_3 - y_2, \dots, y_n - y_{n-1}\) and output the minimum of these differences, i.e., $$\min_{1 \leq i < n}(y_{i+1}-y_i).$$
This problem will help you understand sorting and adjacent element comparison techniques.
inputFormat
The input is given via standard input (stdin) as follows:
- The first line contains an integer n (\(2 \leq n \leq 10^5\)), representing the number of coins.
- The second line contains n space-separated integers, each representing a year.
outputFormat
Output via standard output (stdout) a single integer which is the minimum difference between consecutive years in the sorted order.
## sample5
1990 2003 1985 2010 1995
5
</p>