結果

問題 No.1374 Absolute Game
ユーザー simansiman
提出日時 2021-03-23 11:25:50
言語 Ruby
(3.2.2)
結果
AC  
実行時間 160 ms / 2,000 ms
コード長 215 bytes
コンパイル時間 238 ms
コンパイル使用メモリ 11,464 KB
実行使用メモリ 23,004 KB
最終ジャッジ日時 2023-08-16 13:56:19
合計ジャッジ時間 4,858 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
15,300 KB
testcase_01 AC 76 ms
15,092 KB
testcase_02 AC 78 ms
15,044 KB
testcase_03 AC 77 ms
15,344 KB
testcase_04 AC 78 ms
15,140 KB
testcase_05 AC 79 ms
15,088 KB
testcase_06 AC 78 ms
15,092 KB
testcase_07 AC 76 ms
15,240 KB
testcase_08 AC 102 ms
16,900 KB
testcase_09 AC 127 ms
20,636 KB
testcase_10 AC 130 ms
21,564 KB
testcase_11 AC 117 ms
19,152 KB
testcase_12 AC 102 ms
17,536 KB
testcase_13 AC 121 ms
20,296 KB
testcase_14 AC 148 ms
22,988 KB
testcase_15 AC 160 ms
22,868 KB
testcase_16 AC 149 ms
22,872 KB
testcase_17 AC 158 ms
22,764 KB
testcase_18 AC 143 ms
22,948 KB
testcase_19 AC 153 ms
23,004 KB
testcase_20 AC 104 ms
17,732 KB
testcase_21 AC 115 ms
19,148 KB
testcase_22 AC 154 ms
22,744 KB
testcase_23 AC 84 ms
15,500 KB
testcase_24 AC 89 ms
15,940 KB
testcase_25 AC 91 ms
16,476 KB
testcase_26 AC 102 ms
17,392 KB
testcase_27 AC 107 ms
18,580 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
C = gets.split.map(&:to_i)
S = C.sum

if S < 0
  N.times do |i|
    C[i] = -1 * C[i]
  end
end

C.sort!
C.reverse!
a = 0
b = 0

C.each_slice(2) do |x, y|
  a += x
  b += y if y
end

puts a.abs - b.abs
0