QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#363673 | #7695. Double Up | lucasrpatten# | TL | 11ms | 10032kb | Python3 | 423b | 2024-03-24 01:43:07 | 2024-03-24 01:43:08 |
Judging History
answer
import sys
sys.setrecursionlimit(10000)
input()
l=[int(i) for i in input().split()]
d={}
def dp(i,j):
if j-i==1:
return l[i]
if (i,j) in d:
return d[(i,j)]
ans=0
for k in range(i+1,j):
a=dp(i,k)
b=dp(k,j)
if a==b:
ans=max(ans,2*a)
else:
ans=max(ans,max(a,b))
d[(i,j)]=ans
return d[(i,j)]
print(dp(0,len(l)))
詳細信息
Test #1:
score: 100
Accepted
time: 11ms
memory: 10032kb
input:
5 4 2 2 1 8
output:
16
result:
ok single line: '16'
Test #2:
score: -100
Time Limit Exceeded
input:
1000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...