結果
問題 |
No.3103 Butterfly Effect
|
ユーザー |
![]() |
提出日時 | 2025-06-12 21:35:13 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 751 bytes |
コンパイル時間 | 511 ms |
コンパイル使用メモリ | 82,408 KB |
実行使用メモリ | 65,280 KB |
最終ジャッジ日時 | 2025-06-12 21:37:27 |
合計ジャッジ時間 | 9,550 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 1 |
other | RE * 50 |
ソースコード
n = int(input()) a = list(map(int, input().split())) if not a: print(0) exit() # Compute prefix_max: maximum up to each index prefix_max = [] current_max = a[0] prefix_max.append(current_max) for num in a[1:]: current_max = max(current_max, num) prefix_max.append(current_max) # Compute abs_A abs_a = [abs(num) for num in a] # Compute suffix_sum: sum from i to end suffix_sum = [0] * (n + 1) for i in range(n-1, -1, -1): suffix_sum[i] = suffix_sum[i+1] + abs_a[i] max_total = 0 for k in range(0, n+1): if k == 0: current = suffix_sum[0] else: current = prefix_max[k-1] * k if k < n: current += suffix_sum[k] if current > max_total: max_total = current print(max_total)