1. Problem
2. Others' Solutions
import sys
n = int(sys.stdin.readline().rstrip())
sequence = list(map(int,sys.stdin.readline().rstrip().split()))
dp = [[0,0] for _ in range(n)]
dp[0][0] = sequence[0]
result = sequence[0]
for i in range(1,n):
dp[i][0] = max(dp[i-1][0] + sequence[i], sequence[i]) # 제거하지 않았을 때
dp[i][1] = max(dp[i-1][0], dp[i-1][1] + sequence[i]) # 제거할 때, 전자는 i번째 요소 제거 (자기 자신)
# 후자는 전에 특정 요소를 제거했을 때
result = max(result,dp[i][0],dp[i][1])
print(result)
3. Learned
1. Problem
2. My Solution
import sys
n = int(sys.stdin.readline().rstrip())
dp = [0] * (5001)
dp[1] = dp[2] = dp[4] = -1
dp[3] = dp[5] = 1
for i in range(6,n+1):
if i % 5 == 0:
dp[i] = i // 5
elif dp[i-3] == -1:
dp[i] = -1
else:
dp[i] = dp[i-3] + 1
print(dp[n])
3. Others' Solutions
import sys
n = int(sys.stdin.readline().rstrip())
five = n // 5
three = n // 3
for i in range(three+1):
for j in range(five+1):
if (3 * i) + (5 * j) == n:
print(i+j)
exit()
print(-1)
4. Learned