結果
| 問題 | No.3407 Birds-of-Paradise' Christmas Live |
| コンテスト | |
| ユーザー |
sasa8uyauya
|
| 提出日時 | 2025-12-29 15:28:38 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,155 bytes |
| 記録 | |
| コンパイル時間 | 277 ms |
| コンパイル使用メモリ | 82,392 KB |
| 実行使用メモリ | 297,232 KB |
| 最終ジャッジ日時 | 2025-12-29 15:28:57 |
| 合計ジャッジ時間 | 18,368 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 5 WA * 14 TLE * 1 |
ソースコード
n=int(input())
t=list(map(int,input().split()))
p=[]
x=0
for i in range(n):
x+=t[i]
p+=[[x,(i+1)%2]]
if p[0][0]==0:
p=p[1:]
p1=p[:]
n=int(input())
t=list(map(int,input().split()))
p=[]
x=0
for i in range(n):
x+=t[i]
p+=[[x,(i+1)%2]]
if p[0][0]==0:
p=p[1:]
p2=p[:]
t=sorted(set(t for t,f in p1+p2))
p=[]
l=0
for x,f in p1:
while l<len(t) and t[l]<=x:
p+=[(t[l],f)]
l+=1
p1=p[:]
p=[]
l=0
for x,f in p2:
while l<len(t) and t[l]<=x:
p+=[(t[l],f)]
l+=1
p2=p[:]
p=[]
x=0
for i in range(len(t)):
w=t[i]-x
f=p1[i][1]*2+p2[i][1]
if len(p)==0 or p[-1][1]!=f:
p+=[[0,f]]
p[-1][0]+=w
x=t[i]
l=0
while l<len(p):
if p[l][1] in [1,2]:
f=p[l][1]
r=l
while r+1<len(p) and (p[r+1][1] in [f,3]):
r+=1
if p[r][1]==3:
r-=1
p[l:r+1]=[[sum(w for w,f in p[l:r+1]),f]]
l=r
l+=1
a=0
l=0
while l<len(p):
if p[l][1]!=0:
r=l
while r+1<len(p) and p[r+1][1]!=0:
r+=1
q=[[0,0] for i in range(r-l+1)]
q[0][1]=p[l][0]**2
for i in range(1,r-l+1):
q[i][0]=q[i-1][1]
q[i][1]=max(q[i-1][1],q[i-1][0]+(p[i-1+l][0]+p[i+l][0])**2)
a+=q[-1][1]
l=r
l+=1
print(a)
sasa8uyauya