Submission #63856022


Source Code Expand

Copy
from atcoder.lazysegtree import LazySegTree
inf=1<<63
n=int(input())
a=list(map(int,input().split()))
def mapping(a,b):return a+b
def comp(a,b):return a+b
prefix=[]
dp=LazySegTree(max,-inf,mapping,comp,0,[0]*n)
pre=set()
for i in range(n):
pre.add(a[i])
prefix.append(len(pre))
idx=[-1]*(n+1)
for i in range(n):
if idx[a[i]]==-1:
dp.apply(0,i,1)
else:
dp.apply(idx[a[i]],i,1)
dp.set(i,pre[i])
idx[a[i]]=i
suf=set()
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
from atcoder.lazysegtree import LazySegTree
inf=1<<63
n=int(input())
a=list(map(int,input().split()))
def mapping(a,b):return a+b
def comp(a,b):return a+b
prefix=[]
dp=LazySegTree(max,-inf,mapping,comp,0,[0]*n)
pre=set()
for i in range(n):
    pre.add(a[i])
    prefix.append(len(pre))
idx=[-1]*(n+1)
for i in range(n):
    if idx[a[i]]==-1:
        dp.apply(0,i,1)
    else:
        dp.apply(idx[a[i]],i,1)
    dp.set(i,pre[i])
    idx[a[i]]=i
suf=set()
ans=0
suf.add(a[-1])
for i in range(n-2,0,-1):
    ans=max(ans,dp.prod(0,i)+len(suf))
    suf.add(a[i])
print(ans)

Submission Info

Submission Time
Task F - Variety Split Hard
User juten
Language Python (PyPy 3.10-v7.3.12)
Score 0
Code Size 595 Byte
Status RE
Exec Time 215 ms
Memory 213980 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 550
Status
RE × 2
RE × 44
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 01_test_28.txt, 01_test_29.txt, 01_test_30.txt, 01_test_31.txt, 01_test_32.txt, 01_test_33.txt, 01_test_34.txt, 01_test_35.txt, 01_test_36.txt, 01_test_37.txt, 01_test_38.txt, 01_test_39.txt, 01_test_40.txt, 01_test_41.txt
Case Name Status Exec Time Memory
00_sample_00.txt RE 130 ms 84928 KB
00_sample_01.txt RE 129 ms 84660 KB
01_test_00.txt RE 130 ms 85132 KB
01_test_01.txt RE 131 ms 85016 KB
01_test_02.txt RE 130 ms 84944 KB
01_test_03.txt RE 129 ms 84680 KB
01_test_04.txt RE 129 ms 85076 KB
01_test_05.txt RE 152 ms 112440 KB
01_test_06.txt RE 211 ms 196220 KB
01_test_07.txt RE 176 ms 127112 KB
01_test_08.txt RE 210 ms 196236 KB
01_test_09.txt RE 177 ms 127504 KB
01_test_10.txt RE 212 ms 196420 KB
01_test_11.txt RE 155 ms 119664 KB
01_test_12.txt RE 211 ms 196456 KB
01_test_13.txt RE 193 ms 164892 KB
01_test_14.txt RE 212 ms 196372 KB
01_test_15.txt RE 199 ms 172404 KB
01_test_16.txt RE 193 ms 172440 KB
01_test_17.txt RE 202 ms 179184 KB
01_test_18.txt RE 197 ms 179632 KB
01_test_19.txt RE 205 ms 183796 KB
01_test_20.txt RE 198 ms 183328 KB
01_test_21.txt RE 207 ms 188392 KB
01_test_22.txt RE 201 ms 187936 KB
01_test_23.txt RE 209 ms 193432 KB
01_test_24.txt RE 203 ms 192888 KB
01_test_25.txt RE 178 ms 146864 KB
01_test_26.txt RE 189 ms 165004 KB
01_test_27.txt RE 188 ms 164848 KB
01_test_28.txt RE 189 ms 165088 KB
01_test_29.txt RE 190 ms 163564 KB
01_test_30.txt RE 188 ms 163576 KB
01_test_31.txt RE 208 ms 213796 KB
01_test_32.txt RE 215 ms 213864 KB
01_test_33.txt RE 129 ms 84664 KB
01_test_34.txt RE 130 ms 84808 KB
01_test_35.txt RE 204 ms 196444 KB
01_test_36.txt RE 191 ms 167596 KB
01_test_37.txt RE 188 ms 160608 KB
01_test_38.txt RE 209 ms 213548 KB
01_test_39.txt RE 210 ms 213792 KB
01_test_40.txt RE 210 ms 213980 KB
01_test_41.txt RE 208 ms 213308 KB


2025-05-05 (Mon)
15:15:14 +09:00