結果
| 問題 | No.3407 Birds-of-Paradise' Christmas Live |
| コンテスト | |
| ユーザー |
sasa8uyauya
|
| 提出日時 | 2025-12-29 17:41:46 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,462 bytes |
| 記録 | |
| コンパイル時間 | 264 ms |
| コンパイル使用メモリ | 82,452 KB |
| 実行使用メモリ | 309,568 KB |
| 最終ジャッジ日時 | 2025-12-29 17:42:06 |
| 合計ジャッジ時間 | 18,685 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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
p=[[1,0]]+p+[[1,0]]
l=0
while l<len(p):
if p[l][1]==3 and p[l-1][1]==0 and p[l+1][1]!=0:
p[l:l+2]=[[p[l][0]+p[l+1][0],p[l+1][1]]]
l+=1
p=p[::-1]
l=0
while l<len(p):
if p[l][1]==3 and p[l-1][1]==0 and p[l+1][1]!=0:
p[l:l+2]=[[p[l][0]+p[l+1][0],p[l+1][1]]]
l+=1
p=p[::-1]
a=0
l=0
while l<len(p):
if p[l][1]!=0:
q=[0,0]
q[1]=p[l][0]**2
l+=1
while p[l][1]!=0:
nq=[0,0]
nq[0]=max(q[1],q[0]+p[l-1][0]**2)
nq[1]=max(q[1],q[0]+p[l-1][0]**2)+p[l][0]**2
if p[l][1]==3 or p[l-1][1]==3:
nq[1]=max(nq[1],q[0]+(p[l-1][0]+p[l][0])**2)
q=nq
l+=1
a+=q[1]
l+=1
print(a)
sasa8uyauya