結果

問題 No.505 カードの数式2
ユーザー trineutron
提出日時 2020-07-26 21:05:28
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 597 bytes
コンパイル時間 2,056 ms
コンパイル使用メモリ 196,804 KB
最終ジャッジ日時 2025-01-12 06:17:45
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    int64_t l = a.at(0), r = a.at(0);
    for (int i = 1; i < n; i++) {
        vector<int64_t> v;
        v.push_back(l + a.at(i));
        v.push_back(r + a.at(i));
        v.push_back(l - a.at(i));
        v.push_back(r - a.at(i));
        v.push_back(l * a.at(i));
        v.push_back(r * a.at(i));
        l = *min_element(v.begin(), v.end());
        r = *max_element(v.begin(), v.end());
    }
    cout << r << endl;
}
0