QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#363705 | #7695. Double Up | lucasrpatten# | RE | 13ms | 10020kb | Python3 | 566b | 2024-03-24 02:10:32 | 2024-03-24 02:10:33 |
Judging History
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...