結果
| 問題 | No.297 カードの数式 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-10-25 08:20:35 |
| 言語 | PyPy2 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 556 bytes |
| 記録 | |
| コンパイル時間 | 132 ms |
| コンパイル使用メモリ | 77,588 KB |
| 最終ジャッジ日時 | 2025-12-03 22:21:58 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 RE * 1 |
| other | AC * 7 WA * 7 RE * 9 |
ソースコード
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, eval(''.join(minimum))
else:
print maximum, -maximum