QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#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)))
Details
Tip: Click on the bar to expand more detailed information
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...