結果
| 問題 | 
                            No.1374 Absolute Game
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-02-05 22:47:35 | 
| 言語 | Ruby  (3.4.1)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 468 bytes | 
| コンパイル時間 | 231 ms | 
| コンパイル使用メモリ | 7,552 KB | 
| 実行使用メモリ | 23,040 KB | 
| 最終ジャッジ日時 | 2024-07-02 13:37:34 | 
| 合計ジャッジ時間 | 4,732 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 5 WA * 21 | 
コンパイルメッセージ
Syntax OK
ソースコード
def lscan; gets.split.map(&:to_i); end
gets
li = lscan.sort
n = li.size
n2 = n/2
n1 = n - n2
if n == 1
  p li[0]
  exit
end
odd, even = li.each_slice(2).reduce([0, 0]){|s,e| s[0] += e[0]; e[1] and s[1] += e[1]; s }
score1 = li[0...n1].reduce(:+).abs - li[n1..-1].reduce(:+).abs
score2 = -li[0...n2].reduce(:+).abs + li[n2..-1].reduce(:+).abs
score3 = odd.abs - even.abs
best = [score1, score2, score3].max
best = [even.abs - odd.abs, best].max if n.even?
p best