結果
問題 | No.297 カードの数式 |
ユーザー | titia |
提出日時 | 2022-11-01 03:14:10 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 398 bytes |
コンパイル時間 | 438 ms |
コンパイル使用メモリ | 10,696 KB |
実行使用メモリ | 817,020 KB |
最終ジャッジ日時 | 2023-09-22 23:46:04 |
合計ジャッジ時間 | 3,782 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 16 ms
8,048 KB |
testcase_01 | AC | 15 ms
8,076 KB |
testcase_02 | AC | 17 ms
8,260 KB |
testcase_03 | AC | 32 ms
8,700 KB |
testcase_04 | MLE | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
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 | -- | - |
ソースコード
from itertools import permutations n=int(input()) C=input().split() X=list(permutations(range(n))) MAX=-1<<60 MIN=1<<60 for x in X: S="" for y in x: S+=C[y] flag=1 for i in range(1,len(S)): if S[0] in "+-" or S[-1] in "+-" or (S[i] in "+-" and S[i-1] in "+-"): break else: MAX=max(MAX,eval(S)) MIN=min(MIN,eval(S)) print(MAX,MIN)