Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created February 19, 2018 01:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whatalnk/4b714ff8a67e3855d041ce47fd654aee to your computer and use it in GitHub Desktop.
Save whatalnk/4b714ff8a67e3855d041ce47fd654aee to your computer and use it in GitHub Desktop.
AtCoder ABC #088 B. Card Game for Two
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i).sort.reverse
ans = 0
n.times do |i|
if (i + 1).odd? then
ans += a[i]
else
ans -= a[i]
end
end
puts ans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment