結果
問題 |
No.3185 Three Abs
|
ユーザー |
|
提出日時 | 2025-06-24 13:34:33 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 523 bytes |
コンパイル時間 | 2,490 ms |
コンパイル使用メモリ | 193,572 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-06-24 13:34:45 |
合計ジャッジ時間 | 12,036 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | WA * 22 RE * 8 |
ソースコード
#include <bits/stdc++.h> using namespace std; using i64 = long long; const int N = 100005; int n; i64 s[N]; int main() { int t; cin >> t; while (t--) {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; } }