結果
問題 | No.1374 Absolute Game |
ユーザー |
👑 |
提出日時 | 2022-04-28 09:27:38 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 100 ms / 2,000 ms |
コード長 | 347 bytes |
コンパイル時間 | 80 ms |
コンパイル使用メモリ | 6,688 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-28 07:53:55 |
合計ジャッジ時間 | 2,565 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 26 |
ソースコード
local n = io.read("*n")local a = {}local asum = 0for i = 1, n doa[i] = io.read("*n")asum = asum + a[i]endif 0 <= asum thentable.sort(a, function(x, y) return x > y end)elsetable.sort(a)endlocal x, y = 0, 0for i = 1, n doif i % 2 == 1 thenx = x + a[i]elsey = y + a[i]endendprint(math.abs(x) - math.abs(y))