結果

問題 No.505 カードの数式2
ユーザー ldsyb
提出日時 2017-04-21 23:01:32
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 217 bytes
コンパイル時間 610 ms
コンパイル使用メモリ 62,976 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-20 06:34:40
合計ジャッジ時間 1,625 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

using ll = long long;

int main(){
	int n;
	cin >> n;
	ll ans = 0;
	while(n--){
		ll x;
		cin >> x;
		ans = 0 < x ? max(ans * x, ans + x) : ans - x;
	}
	cout << ans << endl;
}
0