結果

問題 No.297 カードの数式
ユーザー tjaketjake
提出日時 2015-12-19 15:30:05
言語 Python2
(2.7.18)
結果
RE  
実行時間 -
コード長 373 bytes
コンパイル時間 1,105 ms
コンパイル使用メモリ 6,516 KB
実行使用メモリ 11,360 KB
最終ジャッジ日時 2023-10-14 22:27:42
合計ジャッジ時間 3,676 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

from itertools import permutations
n = input()
c = raw_input().split()
mi = 10**9
ma = -10**9
join = ''.join
for p in permutations(c):
    if p[0] in "+-" or p[-1] in "+-": continue
    for i in xrange(n-1):
        if p[i] in "+-" and p[i+1] in "+-":
            break
    else:
        res = eval(join(p))
        mi = min(mi, res)
        ma = max(ma, res)
print ma, mi
0