結果
| 問題 | No.297 カードの数式 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-10-25 08:21:12 |
| 言語 | PyPy2 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 541 bytes |
| 記録 | |
| コンパイル時間 | 155 ms |
| コンパイル使用メモリ | 77,496 KB |
| 最終ジャッジ日時 | 2025-12-03 22:22:01 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 WA * 7 |
ソースコード
N = input()
C = raw_input().split()
ops = sorted([s for s in C if s in '+-'])
nums = sorted([s for s in C if s not in '+-'])
maximum = []
for i in xrange(len(nums)):
maximum.append(nums[i])
if i < len(ops):
maximum.append(ops[-i-1])
maximum = eval(''.join(maximum[::-1]))
if all(op == '+' for op in ops):
L = [[] for _ in xrange(len(ops)+1)]
for i, n in enumerate(nums):
L[i%(len(ops)+1)].append(n)
minimum = sum(int(''.join(l)) for l in L)
print maximum, minimum
else:
print maximum, -maximum