結果

問題 No.297 カードの数式
コンテスト
ユーザー taba
提出日時 2016-04-15 03:21:53
言語 PyPy2
(7.3.15)
結果
RE  
実行時間 -
コード長 419 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 151 ms
コンパイル使用メモリ 77,604 KB
最終ジャッジ日時 2025-12-03 20:22:38
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 RE * 1
other AC * 15 WA * 7 RE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n=input()
c=raw_input().split()
a=sorted([i for i in c if i.isdigit()])
p,m=c.count("+"),c.count("-")
#print a,p,m
#big
b=a[p+m:][::-1]
c=a[:p+m]
for i in range(m):
	b+=["-",c.pop(0)]
for i in range(p):
	b+=["+",c.pop()]
big=eval("".join(b))
#print b
#small
b=[a[0]]
c=a[1:]
for i in range(p):
	b+=["+",c.pop(0)]
for i in range(m-1):
	b+=["-",c.pop(0)]
b+=["-"]+c[::-1]
small=eval("".join(b))
#print b,c
print big,small
0