feat: added alternative python solutions.

This commit is contained in:
2026-05-17 13:20:58 -03:00
parent 7e9caaea6e
commit c85571e157
451 changed files with 3777 additions and 3495 deletions

View File

@@ -43,7 +43,7 @@
},
"solutions": {
"main-ac": "ac.cpp",
"alternative-ac": [],
"alternative-ac": ["alternative-ac.py"],
"wrong-answer": [],
"time-limit": ["TLE.cpp"],
"time-limit-or-ac": [],

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,32 @@
n = int(input())
prices = list(map(int, input().split()))
dp = [0] * (n + 1)
choice = [0] * (n + 1)
for i in range(1, n + 1):
max_revenue = prices[i - 1]
best_cut = 0
for j in range(1, i):
revenue = prices[j - 1] + dp[i - j]
if revenue > max_revenue:
max_revenue = revenue
best_cut = j
dp[i] = max_revenue
choice[i] = best_cut
pieces = []
remaining = n
while remaining > 0:
cut = choice[remaining]
if cut == 0:
pieces.append(remaining)
remaining = 0
else:
pieces.append(cut)
remaining -= cut
print(dp[n])
print(' '.join(map(str, pieces)))