Created
February 19, 2018 01:15
-
-
Save whatalnk/4b714ff8a67e3855d041ce47fd654aee to your computer and use it in GitHub Desktop.
AtCoder ABC #088 B. Card Game for Two
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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