結果

問題 No.297 カードの数式
ユーザー MJDigit
提出日時 2015-11-11 00:06:01
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 442 bytes
コンパイル時間 106 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 16,256 KB
最終ジャッジ日時 2024-09-13 14:23:02
合計ジャッジ時間 2,757 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 1 TLE * 1 -- * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.py:17: 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
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