Last active
March 21, 2018 14:57
-
-
Save hamuhei1412/801d5b2992b5ed5d7c4c2027fe8ac5ea to your computer and use it in GitHub Desktop.
ABC088B
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.to_i | |
hoge = gets.split.map(&:to_i) | |
#ここまで入力 | |
hoge.sort! #小さい順にソート | |
hoge.reverse! #それを逆順にひっくり返すことによって実質大きい順ソートに | |
s = 0 #これが偶数の時はAliceの番で、奇数の時はBobの番 | |
Alice = 0 | |
Bob = 0 | |
while s < N | |
if(s%2==0) | |
Alice += hoge[s] | |
else | |
Bob += hoge[s] | |
end | |
s+=1 | |
end | |
puts Alice - Bob |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment