結果

問題 No.297 カードの数式
ユーザー JunOnumaJunOnuma
提出日時 2017-05-30 13:45:22
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 491 bytes
コンパイル時間 570 ms
コンパイル使用メモリ 7,080 KB
実行使用メモリ 6,392 KB
最終ジャッジ日時 2023-10-21 18:00:37
合計ジャッジ時間 1,436 ms
ジャッジサーバーID
(参考情報)
judge9 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,392 KB
testcase_01 AC 12 ms
6,392 KB
testcase_02 AC 13 ms
6,392 KB
testcase_03 AC 12 ms
6,392 KB
testcase_04 AC 12 ms
6,392 KB
testcase_05 AC 12 ms
6,392 KB
testcase_06 WA -
testcase_07 AC 11 ms
6,392 KB
testcase_08 AC 12 ms
6,392 KB
testcase_09 AC 11 ms
6,392 KB
testcase_10 AC 12 ms
6,392 KB
testcase_11 AC 11 ms
6,392 KB
testcase_12 AC 11 ms
6,392 KB
testcase_13 AC 12 ms
6,392 KB
testcase_14 AC 11 ms
6,392 KB
testcase_15 AC 11 ms
6,392 KB
testcase_16 AC 12 ms
6,392 KB
testcase_17 AC 11 ms
6,392 KB
testcase_18 AC 11 ms
6,392 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 11 ms
6,392 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(raw_input())
l = raw_input().split()
ll = []
p = 0
m = 0
for c in l:
    if c == '+':
        p += 1
    elif c == '-':
        m += 1
    else:
        ll.append(int(c))
k = len(ll)
ll.sort()
ll.reverse()
ln = ll[0:k-(p+m)]
ll = ll[k-(p+m):]
i = 0
for j in ln:
    i *= 10
    i += j
mx = i
for j in ll[0:p]:
    mx += j
for j in ll[p:]:
    mx -= j
if m == 0:
    mn = mx
else:
    mn = -i
    for j in ll[0:m-1]:
        mn -= j
    for j in ll[m-1:]:
        mn += j
print mx,mn
0