結果

問題 No.505 カードの数式2
ユーザー h_nosonh_noson
提出日時 2017-06-13 23:43:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 571 bytes
コンパイル時間 79 ms
コンパイル使用メモリ 11,828 KB
実行使用メモリ 10,112 KB
最終ジャッジ日時 2023-10-24 21:54:38
合計ジャッジ時間 1,805 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,112 KB
testcase_01 AC 29 ms
10,112 KB
testcase_02 AC 29 ms
10,112 KB
testcase_03 AC 30 ms
10,112 KB
testcase_04 AC 27 ms
10,112 KB
testcase_05 AC 27 ms
10,112 KB
testcase_06 AC 26 ms
10,112 KB
testcase_07 AC 26 ms
10,112 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 26 ms
10,112 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 27 ms
10,112 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int,input().split(' ')))

i = 0
while i < n and a[i] == 0: i += 1
if i == n:
    print(0)
    exit(0)
ans = abs(a[i])
i += 1
sign = 0
for x in a[i:]:
    sign ^= x < 0
if sign == 0:
    for x in a[i:]:
        if x in [0,1]:
            ans += x
        else:
            ans *= x
else:
    mx = -10 ** 9
    for x in a[i:]:
        if x < 0:
            mx = max(mx,x)
    for x in a[i:]:
        if x in [0,1]:
            ans += x
        elif x == mx:
            ans -= x
            mx = 0
        else:
            ans *= x
print(ans)
0