結果
| 問題 |
No.505 カードの数式2
|
| コンテスト | |
| ユーザー |
tancahn2380
|
| 提出日時 | 2017-04-27 05:00:14 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 488 bytes |
| コンパイル時間 | 692 ms |
| コンパイル使用メモリ | 71,696 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-13 14:08:58 |
| 合計ジャッジ時間 | 1,539 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 WA * 15 |
ソースコード
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>
int main() {
int n;
std::cin >> n;
long long ans = 0;
long long a;
std::cin >> a;
ans = a;
for (int i = 1; i < n; i++) {
std::cin >> a;
if (a != 0 && ans > 0) ans = std::max(ans + a, std::max(ans - a, std::max(ans / a, std::max(ans * a,std::max(-ans*a,-ans/a)))));
else ans = std::max(ans+a,std::max(ans-a,ans+a));
//std::cout << ans << std::endl;
}
std::cout << ans << std::endl;
}
tancahn2380