結果
| 問題 |
No.3185 Three Abs
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-06-24 13:33:50 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 477 bytes |
| コンパイル時間 | 2,276 ms |
| コンパイル使用メモリ | 194,236 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-06-24 13:33:58 |
| 合計ジャッジ時間 | 7,238 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const int N = 100005;
int n;
i64 s[N];
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> s[i];
s[i] += s[i - 1];
}
i64 ans = 0, mx = s[1], mn = s[1];
for (int j = 2; j < n; j++) {
mx = max(mx, s[j - 1]);
mn = min(mn, s[j - 1]);
ans = max(ans, abs(s[n] - s[j]) + max(abs(s[j] - mx) + abs(mx - s[1]), abs(s[j] - mn) + abs(mn - s[1])));
}
cout << ans << endl;
}