Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- import java.math.*;
- /**
- * Auto-generated code below aims at helping you parse
- * the standard input according to the problem statement.
- **/
- class Solution {
- public static void main(String args[]) {
- Scanner in = new Scanner(System.in);
- int N = in.nextInt();
- Vector<Integer> list = new Vector<Integer>();
- for (int i = 0; i < N; i++) {
- list.add(in.nextInt());
- }
- Collections.sort(list);
- int min = list.elementAt(1) - list.elementAt(0);
- for(int i = 2;i<list.size();i++){
- int diff = list.elementAt(i) - list.elementAt(i-1);
- if(diff < min){
- min = diff;
- }
- }
- // Write an action using System.out.println()
- // To debug: System.err.println("Debug messages...");
- System.err.println(list);
- System.out.println("" + min);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement