結果

問題 No.505 カードの数式2
ユーザー teketeke5000
提出日時 2017-08-25 01:24:35
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 321 bytes
コンパイル時間 1,194 ms
コンパイル使用メモリ 157,656 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-15 14:27:20
合計ジャッジ時間 2,207 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11 WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(void) {
    int N;
    cin >> N;
    int a;
    ll ans = 0;
    for (int i=0; i<N; i++) {
        cin >> a;
        if (ans == 0 || (-1 <= a && a <= 1)) ans += abs(a);
        else ans *= abs(a);
    }
    cout << ans << endl;
    return 0;
}
0