Advertisement
Guest User

Untitled

a guest
Mar 29th, 2015
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.58 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. read N
  5. for (( i=0; i<N; i++ )); do
  6.     read P[$i]
  7. done
  8. readarray -t sorted < <(for a in "${P[@]}"; do echo "$a"; done | sort)
  9. lowest=$((P[0]-P[1]))
  10. lowest=$((lowest**2))
  11. lowest='echo "sqrt($lowest)" | bc -l'
  12.  
  13. for(( i=0; i<N; i++ )); do
  14.     y=$((P[i]-P[i+1]))
  15.     y=$((y**2))
  16.     y='echo "sqrt($y)" | bc -l'
  17.     if [ $lowest -gt $y ] ; then
  18.         lowest=$((P[i]))
  19.     fi
  20. done
  21. echo $((lowest))
  22. # Write an action using echo
  23. # To debug: echo "Debug messages..." >&2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement