結果
問題 | No.3129 Multiple of Twin Subarray |
ユーザー |
![]() |
提出日時 | 2025-04-25 21:42:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 82 ms / 2,000 ms |
コード長 | 1,004 bytes |
コンパイル時間 | 4,620 ms |
コンパイル使用メモリ | 253,872 KB |
実行使用メモリ | 12,672 KB |
最終ジャッジ日時 | 2025-04-25 21:43:05 |
合計ジャッジ時間 | 8,055 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
ソースコード
#include <stdio.h> #include <atcoder/all> #include <bits/stdc++.h> using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 4000000000000000001LL vector<long long> get(vector<long long> a){ int n = a.size(); vector<long long> res(n+1,-Inf64); long long cs = 0; long long mins = 0; rep(i,n){ cs += a[i]; res[i+1] = cs - mins; mins = min(mins,cs); } rep(i,n){ res[i+1] = max(res[i+1],res[i]); } return res; } int main(){ int n; cin>>n; vector<long long> a(n); rep(i,n){ cin>>a[i]; } vector<vector<long long>> res(4); rep(i,2){ rep(j,2){ res[i*2+j] = get(a); reverse(a.begin(),a.end()); } rep(j,n)a[j] *= -1; } long long ans = -Inf64; rep(i,2){ rep(j,2){ for(int k=1;k<n;k++){ long long v0 = res[i*2][k]; long long v1 = res[j*2+1][n-k]; if(i)v0 *= -1; if(j)v1 *= -1; ans = max(ans,v0*v1); } } } cout<<ans<<endl; return 0; }