Advertisement
Guest User

Untitled

a guest
Aug 1st, 2015
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.51 KB | None | 0 0
  1. # Auto-generated code below aims at helping you parse
  2. # the standard input according to the problem statement.
  3.  
  4. last="";
  5. read N
  6. for (( i=0; i<N; i++ )); do
  7.     read Pi
  8.     echo $Pi
  9. done | sort -n | while read current;
  10. do
  11.     if [[ -z $last ]]
  12.     then
  13.         last=$current;
  14.         continue;
  15.     fi
  16.    
  17.     currentDiff=$((last - current));
  18.     if [[ $currentDiff -lt 0 ]]
  19.     then
  20.         currentDiff=$((current - last))
  21.     fi
  22.     echo $currentDiff;
  23.    
  24.     last=$current;
  25. done | sort -n | head -n 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement