結果

問題 No.505 カードの数式2
ユーザー okchan08
提出日時 2018-04-05 23:22:34
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 321 bytes
コンパイル時間 411 ms
コンパイル使用メモリ 54,112 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-26 10:39:54
合計ジャッジ時間 1,494 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;

int main(){
    int N; cin >> N;
    int a;
    int ans = 0;
    for(int i=0;i<N;i++){
        cin >> a;
        if(a == 0) continue;
        else if(a < 0) ans -= a;
        else{
            ans = max(ans + a, ans * a);
        }
    }
    cout << ans << endl;
    return 0;
}
0