結果

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

ソースコード

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 (a < 0) ans += -a;
        else {
            if (ans <= 0 || a <= 1) ans += a;
            else ans *= a;
        }
    }
    cout << ans << endl;
    return 0;
}
0