結果
| 問題 |
No.1374 Absolute Game
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-03-02 16:28:46 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 97 ms / 2,000 ms |
| コード長 | 277 bytes |
| コンパイル時間 | 347 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 91,648 KB |
| 最終ジャッジ日時 | 2024-10-03 01:50:04 |
| 合計ジャッジ時間 | 4,147 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 26 |
ソースコード
import sys
input = sys.stdin.readline
N = int(input())
c = list(map(int, input().split()))
if sum(c)<0:
c = list(map(lambda x: -x, c))
c.sort(reverse=True)
a, b = 0, 0
for i in range(N):
if i%2==0:
a += c[i]
else:
b += c[i]
print(abs(a)-abs(b))