結果
| 問題 | 
                            No.1374 Absolute Game
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-02-05 22:45:53 | 
| 言語 | Ruby  (3.4.1)  | 
                    
| 結果 | 
                             
                                RE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 436 bytes | 
| コンパイル時間 | 71 ms | 
| コンパイル使用メモリ | 7,424 KB | 
| 実行使用メモリ | 22,912 KB | 
| 最終ジャッジ日時 | 2024-07-02 13:34:46 | 
| 合計ジャッジ時間 | 5,254 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 4 WA * 20 RE * 2 | 
コンパイルメッセージ
Syntax OK
ソースコード
def lscan; gets.split.map(&:to_i); end
gets
li = lscan.sort
n = li.size
n2 = n/2
n1 = n - n2
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