結果
問題 |
No.999 てん vs. ほむ
|
ユーザー |
![]() |
提出日時 | 2023-04-21 11:13:13 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 120 ms / 2,000 ms |
コード長 | 898 bytes |
コンパイル時間 | 639 ms |
コンパイル使用メモリ | 82,348 KB |
実行使用メモリ | 124,196 KB |
最終ジャッジ日時 | 2024-11-06 07:37:55 |
合計ジャッジ時間 | 3,902 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
# 区間dpだと間に合わない、左右からの累積和で解ける # 左からのネット得点累積和、右からのネット得点累積和 # どこまで左、どこまで右なら最大値となるか N = int(input()) A = list(map(int, input().split())) from_left = [] for i in range(N): calc = A[i*2]-A[i*2+1] from_left.append(calc) from_left_cumu = [0] temp = 0 for i in range(N): temp += from_left[i] from_left_cumu.append(temp) #print(from_left) #print(from_left_cumu) from_right = [] for i in range(N): calc = A[N*2-i*2-1]-A[N*2-i*2-2] from_right.append(calc) from_right_cumu = [0] temp = 0 for i in range(N): temp += from_right[i] from_right_cumu.append(temp) from_right_cumu.reverse() #print(from_right) #print(from_right_cumu) ans = -10**20 for i in range(N+1): ans = max(ans, from_left_cumu[i]+from_right_cumu[i]) print(ans)