Codeforces - Yet-Another-Yet-Another-Task
本文最後更新於:2024年1月12日 下午
Codeforces
出處
Educational Codeforces Round 88 (Rated for Div. 2)難度
2000
標籤
data structures
dp
implementation
two pointers
*2000
Codeforces - Yet-Another-Yet-Another-Task
Yet-Another-Yet-Another-Task.py
# Author : ysh
# 2023/08/24 Thu 14:47:28
# https://codeforces.com/contest/1359/problem/D
n = int(input())
f = [int(i) for i in input().split()]
ans = 0
for i in range(31)[::-1]:
mmin = 0
now = 0
sig = 0
for j in f:
if j > i:
j = -1e9
sig = sig + j
mmin = min(sig,mmin)
now = max(sig - mmin,now)
ans = max(ans,now - i)
print(int(ans))
quit()
Codeforces - Yet-Another-Yet-Another-Task
http://mysh212.github.io/algosolution/Yet-Another-Yet-Another-Task.py/