QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#363705#7695. Double Uplucasrpatten#RE 13ms10020kbPython3566b2024-03-24 02:10:322024-03-24 02:10:33

Judging History

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

  • [2024-03-24 02:10:33]
  • 评测
  • 测评结果:RE
  • 用时:13ms
  • 内存:10020kb
  • [2024-03-24 02:10:32]
  • 提交

answer

import sys
from functools import lru_cache
sys.setrecursionlimit(10000)
input()
l=[int(i) for i in input().split()]
@lru_cache(None)
def dp(i,j):
    if j-i==1:
        return l[i]
    a=dp(i,j-1)
    b=dp(i+1,j)
    if a!=b:
        return max(a,b)
    lo=i+1
    hi=j
    while lo < hi:
        m=(hi+lo)//2
        e=dp(i,m)
        f=dp(m,j)
        if e<a and f<a:
            return a
        if e==a and f==a:
            return 2*a
        if e<a:
            lo=m+1
        else:
            hi=m
    return a
print(dp(0,len(l)))

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 13ms
memory: 10020kb

input:

5
4 2 2 1 8

output:

16

result:

ok single line: '16'

Test #2:

score: -100
Dangerous Syscalls

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: