結果
問題 |
No.3129 Multiple of Twin Subarray
|
ユーザー |
|
提出日時 | 2025-05-01 15:59:14 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,172 bytes |
コンパイル時間 | 408 ms |
コンパイル使用メモリ | 82,448 KB |
実行使用メモリ | 67,892 KB |
最終ジャッジ日時 | 2025-05-01 15:59:19 |
合計ジャッジ時間 | 5,392 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 3 |
other | RE * 46 |
ソースコード
from sortedcontainers import SortedList from itertools import accumulate N=int(input()) A=list(map(int, input().split())) to_right=list(accumulate(A)) to_left=list(accumulate(A[::-1]))[::-1] if N == 2: print(A[0]*A[1]) exit() left=SortedList([]) right=SortedList([]) mem1=[A[0]] mem2=[A[0]] rmem1=[A[-1]] rmem2=[A[-1]] left.add(A[0]) right.add(A[-1]) for i in range(1,N-1): mem1.append(max(to_right[i]-left[0], to_right[i])) mem2.append(min(to_right[i]-left[-1],to_right[i])) left.add(to_right[i]) for i in range(-2,-N,-1): rmem1.append(max(to_left[i]-right[0], to_left[i])) rmem2.append(min(to_left[i]-right[-1], to_left[i])) right.add(to_left[i]) to_rightmax = list(accumulate(mem1, lambda x,y: max(x,y))) to_rightmin = list(accumulate(mem2, lambda x,y: min(x,y))) to_leftmax = list(accumulate(rmem1, lambda x,y: max(x,y)))[::-1] to_leftmin = list(accumulate(rmem2, lambda x,y: min(x,y)))[::-1] ans=0 for i in range(N-1): ans = max(ans, to_rightmax[i]*to_leftmax[i]) ans = max(ans, to_rightmax[i]*to_leftmin[i]) ans = max(ans, to_rightmin[i]*to_leftmax[i]) ans = max(ans, to_rightmin[i]*to_leftmin[i]) print(ans)