結果
問題 |
No.3185 Three Abs
|
ユーザー |
![]() |
提出日時 | 2025-06-12 14:38:36 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 620 bytes |
コンパイル時間 | 1,076 ms |
コンパイル使用メモリ | 107,440 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-06-13 11:34:04 |
合計ジャッジ時間 | 10,765 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 15 WA * 15 |
ソースコード
#include <iostream> #include <vector> #include <cmath> using namespace std; void solve(){ int n; cin >> n; vector<long long> a(n); for(int i = 0; i < n; i++){ cin >> a[i]; } if(n >= 5000){ cout << -1 << endl; return; } vector<long long> s(n + 1, 0); for(int i = 0; i < n; i++){ s[i + 1] = s[i] + a[i]; } long long ans = 0; for(int i = 0; i < n; i++){ for(int j = i + 1; j < n - 1; j++){ ans = max(ans, abs(s[i + 1]) + abs(s[j + 1] - s[i + 1]) + abs(s[n] - s[j + 1])); } } cout << ans << endl; } int main(){ int t; cin >> t; while(t--){ solve(); } }