Skip to content

Instantly share code, notes, and snippets.

@hamuhei1412
Last active March 21, 2018 14:57
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 hamuhei1412/801d5b2992b5ed5d7c4c2027fe8ac5ea to your computer and use it in GitHub Desktop.
Save hamuhei1412/801d5b2992b5ed5d7c4c2027fe8ac5ea to your computer and use it in GitHub Desktop.
ABC088B
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