結果

問題 No.297 カードの数式
ユーザー roiti46roiti46
提出日時 2015-12-09 18:56:25
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 587 bytes
コンパイル時間 65 ms
コンパイル使用メモリ 6,684 KB
実行使用メモリ 7,992 KB
最終ジャッジ日時 2023-10-13 08:43:47
合計ジャッジ時間 2,592 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
7,736 KB
testcase_01 AC 23 ms
7,744 KB
testcase_02 AC 23 ms
7,772 KB
testcase_03 AC 22 ms
7,796 KB
testcase_04 AC 23 ms
7,732 KB
testcase_05 AC 23 ms
7,904 KB
testcase_06 WA -
testcase_07 AC 23 ms
7,976 KB
testcase_08 AC 23 ms
7,948 KB
testcase_09 AC 23 ms
7,932 KB
testcase_10 AC 23 ms
7,916 KB
testcase_11 AC 23 ms
7,788 KB
testcase_12 AC 23 ms
7,784 KB
testcase_13 AC 23 ms
7,780 KB
testcase_14 AC 22 ms
7,904 KB
testcase_15 AC 23 ms
7,848 KB
testcase_16 AC 23 ms
7,800 KB
testcase_17 AC 24 ms
7,860 KB
testcase_18 AC 23 ms
7,860 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 23 ms
7,916 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

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