結果
問題 |
No.505 カードの数式2
|
ユーザー |
|
提出日時 | 2017-04-29 12:57:06 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,178 bytes |
コンパイル時間 | 994 ms |
コンパイル使用メモリ | 106,624 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-14 07:25:06 |
合計ジャッジ時間 | 1,997 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#define _USE_MATH_DEFINES #include <cstdio> #include <iostream> #include <sstream> #include <fstream> #include <iomanip> #include <algorithm> #include <cmath> #include <complex> #include <string> #include <vector> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <bitset> #include <numeric> #include <limits> #include <climits> #include <cfloat> #include <functional> #include <iterator> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for(int i=0; i<n; ++i) cin >> a[i]; long long x = a[0]; long long y = a[0]; for(int i=1; i<n; ++i){ vector<long long> v; if(a[i] == 0){ v = { x + a[i], x - a[i], x * a[i], y + a[i], y - a[i], y * a[i], }; } else { v = { x + a[i], x - a[i], x * a[i], x / a[i], y + a[i], y - a[i], y * a[i], y / a[i], }; } x = LLONG_MAX; y = LLONG_MIN; for(long long b : v){ x = min(x, b); y = max(y, b); } } cout << y << endl; return 0; }