結果

問題 No.297 カードの数式
ユーザー MJDigit
提出日時 2015-11-10 23:47:41
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 389 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 17,824 KB
最終ジャッジ日時 2024-09-13 14:22:57
合計ジャッジ時間 2,736 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 1 TLE * 1 -- * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.py:14: SyntaxWarning: "is" with 'str' 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
for e in itertools.permutations(c,N):
 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