結果

問題 No.297 カードの数式
ユーザー roiti46
提出日時 2015-12-09 18:56:25
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 587 bytes
コンパイル時間 105 ms
コンパイル使用メモリ 6,944 KB
実行使用メモリ 8,192 KB
最終ジャッジ日時 2024-09-15 05:53:00
合計ジャッジ時間 2,169 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

n = int(raw_input())
a = raw_input().split()

x = ""
p = m = 0
for c in a:
    if c == "+": p += 1
    elif c == "-": m += 1
    else: x += c

x = sorted(x, reverse = True)
nums = []
for i in xrange(p + m):
    nums.append(int(x.pop()))
nums.append(int("".join(x)))
nums = nums[::-1]

mx = nums[0]
mn = nums[-1]
for i in xrange(p + m):
    if i < p:
        mx += nums[i + 1]
        mn += nums[-i - 2]
    else:
        mx -= nums[i + 1]
        mn -= nums[-i - 2]
print mx, mn
0