結果

問題 No.297 カードの数式
ユーザー mkawa2mkawa2
提出日時 2019-12-25 21:47:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 1,079 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 12,032 KB
実行使用メモリ 50,068 KB
最終ジャッジ日時 2024-04-08 13:39:19
合計ジャッジ時間 12,437 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 892 ms
50,068 KB
testcase_01 AC 539 ms
43,264 KB
testcase_02 AC 523 ms
43,264 KB
testcase_03 AC 531 ms
43,264 KB
testcase_04 RE -
testcase_05 AC 522 ms
43,264 KB
testcase_06 AC 546 ms
43,264 KB
testcase_07 AC 515 ms
43,264 KB
testcase_08 AC 525 ms
43,264 KB
testcase_09 AC 526 ms
43,264 KB
testcase_10 AC 519 ms
43,264 KB
testcase_11 AC 678 ms
43,264 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 *
from bisect import *
from math import *
from collections import *
from heapq import *
from random import *
import numpy as np
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    def ng(pc):
        pm=["+","-"]
        if pc[0] in pm or pc[-1] in pm:
            return True
        for c0,c1 in zip(pc,pc[1:]):
            if c0 in pm and c1 in pm:
                return True
        return False

    inf=10**16
    n=II()
    cc=input().split()
    mn=inf
    mx=-inf
    for pc in permutations(cc):
        if ng(pc):continue
        val=eval("".join(pc))
        if val<mn:mn=val
        if val>mx:mx=val
    print(mx,mn)

main()
0