제출 #740560

#제출 시각아이디문제언어결과실행 시간메모리
740560ALVIN수열 (APIO14_sequence)Pypy 3
0 / 100
41 ms18228 KiB
def max_points(n, k, arr): dp = [[0 for _ in range(n+1)] for _ in range(k+1)] pref = [0 for _ in range(n+1)] track = [[0 for _ in range(n+1)] for _ in range(k+1)] for i in range(1, n+1): pref[i] = pref[i-1] + arr[i-1] for i in range(1, n+1): dp[1][i] = pref[i]*pref[n] - pref[i]*pref[i-1] track[1][i] = 0 for i in range(2, k+1): mx = [(dp[i-1][j] + pref[j]*pref[i-1] - pref[j]*pref[j-1], j) for j in range(i-1)] for j in range(i, n+1): mx[0] = max(mx[0], (dp[i-1][j-1] + pref[j-1]*pref[n] - pref[j-1]*pref[j-2], j-1)) dp[i][j], track[i][j] = mx[0] res = [0]*k cur = n for i in range(k, 0, -1): res[i-1] = track[i][cur] cur = res[i-1] return dp[k][n], res
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...