結果
| 問題 | No.505 カードの数式2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-04-21 23:13:19 |
| 言語 | C++14 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
MLE
不安定
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 522 bytes |
| 記録 | |
| コンパイル時間 | 1,118 ms |
| コンパイル使用メモリ | 189,168 KB |
| 実行使用メモリ | 753,536 KB |
| 最終ジャッジ日時 | 2026-09-03 16:33:14 |
| 合計ジャッジ時間 | 7,712 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 MLE * 1 -- * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<ll> a(n);
for (int i = 0; i < n; i++) cin >> a[i];
set<ll> b;
b.insert(a[0]);
for (int i = 1; i < n; i++) {
set<ll> c(b);
bool flag = (a[i] != 0);
for (ll x : c) {
b.insert(x * a[i]);
b.insert(x + a[i]);
b.insert(x - a[i]);
if (flag) b.insert(x / a[i]);
}
}
ll ans = -1e9;
for (ll x : b) ans = max(ans, x);
cout << ans << endl;
return 0;
}