QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#363673#7695. Double Uplucasrpatten#TL 11ms10032kbPython3423b2024-03-24 01:43:072024-03-24 01:43:08

Judging History

你现在查看的是最新测评结果

  • [2024-03-24 01:43:08]
  • 评测
  • 测评结果:TL
  • 用时:11ms
  • 内存:10032kb
  • [2024-03-24 01:43:07]
  • 提交

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...

output:


result: