結果

問題 No.505 カードの数式2
ユーザー 0w1
提出日時 2017-04-21 22:39:49
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 296 bytes
コンパイル時間 243 ms
コンパイル使用メモリ 81,992 KB
実行使用メモリ 75,080 KB
最終ジャッジ日時 2024-07-20 05:31:38
合計ジャッジ時間 2,776 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int( input() )
A = list( map( int, input().split() ) )

ans = 0
def dfs( x, v ):
  if x == N:
    global ans
    ans = max( ans, v )
    return
  if A[ x ] < 0:
    dfs( x + 1, v - A[ x ] )
  if A[ x ] > 0:
    dfs( x + 1, v + A[ x ] )
  dfs( x + 1, v * A[ x ] )
dfs( 1, A[ 0 ] )
print( ans )
0