結果

問題 No.297 カードの数式
ユーザー MJDigitMJDigit
提出日時 2015-11-11 00:06:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 442 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 10,784 KB
実行使用メモリ 12,620 KB
最終ジャッジ日時 2023-10-11 15:35:10
合計ジャッジ時間 2,747 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
12,620 KB
testcase_01 AC 16 ms
8,248 KB
testcase_02 AC 16 ms
8,112 KB
testcase_03 AC 18 ms
8,116 KB
testcase_04 TLE -
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 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.py:17: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if e[n] is "-":pm=-1

ソースコード

diff #

import itertools
N=int(input())
c=input().split()
f=1;M=0;m=0
prev=tuple()
for e in itertools.permutations(sorted(c),N):
 if e <= prev: continue
 prev=e
 S=0;s="";ncnt=0;pm=1
 for n in range(0,N):
  if e[n].isdigit():s=s+e[n];ncnt=ncnt+1
  else:
   if ncnt==0:break
   else:
    S+=pm*int(s)
    s="";ncnt=0;pm=1
    if e[n] is "-":pm=-1
 if ncnt==0:continue
 S+=pm*int(s)
 if f==1:M=S;m=S;f=0
 else:M=max(M,S);m=min(m,S)
print('%d %d'%(M,m))
0