結果

問題 No.297 カードの数式
ユーザー MitI_7MitI_7
提出日時 2015-11-30 18:17:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 16 ms / 1,000 ms
コード長 777 bytes
コンパイル時間 122 ms
コンパイル使用メモリ 10,916 KB
実行使用メモリ 8,340 KB
最終ジャッジ日時 2023-08-26 22:50:13
合計ジャッジ時間 1,401 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,340 KB
testcase_01 AC 14 ms
8,140 KB
testcase_02 AC 15 ms
8,140 KB
testcase_03 AC 15 ms
8,216 KB
testcase_04 AC 15 ms
8,216 KB
testcase_05 AC 15 ms
8,168 KB
testcase_06 AC 14 ms
8,116 KB
testcase_07 AC 15 ms
8,196 KB
testcase_08 AC 14 ms
8,236 KB
testcase_09 AC 14 ms
8,260 KB
testcase_10 AC 14 ms
8,220 KB
testcase_11 AC 15 ms
8,208 KB
testcase_12 AC 14 ms
8,220 KB
testcase_13 AC 14 ms
8,200 KB
testcase_14 AC 14 ms
8,212 KB
testcase_15 AC 15 ms
8,192 KB
testcase_16 AC 14 ms
8,200 KB
testcase_17 AC 14 ms
8,200 KB
testcase_18 AC 14 ms
8,296 KB
testcase_19 AC 16 ms
8,192 KB
testcase_20 AC 15 ms
8,168 KB
testcase_21 AC 15 ms
8,276 KB
testcase_22 AC 14 ms
8,228 KB
testcase_23 AC 14 ms
8,304 KB
testcase_24 AC 14 ms
8,248 KB
testcase_25 AC 15 ms
8,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import zip_longest


def main():
    n = input()
    l = input().split()
    num = sorted([int(i) for i in l if i.isnumeric()])
    ope = sorted([i for i in l if not i.isnumeric()])

    nums = [x for x in num[:len(ope)]]
    nums.append(int("".join(map(str, sorted(num[len(ope):], reverse=True)))))
    max_ans = eval("".join([str(a) + b for a, b in zip_longest(sorted(nums, reverse=True), ope, fillvalue='')]))
    min_ans = eval("".join([str(a) + b for a, b in zip_longest(sorted(nums), ope, fillvalue='')]))

    if '-' not in ope:
        l = ["" for i in range(len(ope) + 1)]
        for i, x in enumerate(num):
            l[i % len(l)] += str(x)

        min_ans = sum(map(int, l))

    print(max_ans, min_ans)
    
if __name__ == '__main__':
    main()
0