結果
| 問題 |
No.505 カードの数式2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-04-21 23:13:19 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 522 bytes |
| コンパイル時間 | 1,757 ms |
| コンパイル使用メモリ | 174,776 KB |
| 実行使用メモリ | 408,960 KB |
| 最終ジャッジ日時 | 2024-09-25 02:07:52 |
| 合計ジャッジ時間 | 7,713 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 TLE * 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;
}