結果
| 問題 | No.3407 Birds-of-Paradise' Christmas Live |
| コンテスト | |
| ユーザー |
sasa8uyauya
|
| 提出日時 | 2025-12-29 18:44:29 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,226 bytes |
| 記録 | |
| コンパイル時間 | 378 ms |
| コンパイル使用メモリ | 82,096 KB |
| 実行使用メモリ | 308,676 KB |
| 最終ジャッジ日時 | 2025-12-29 18:44:49 |
| 合計ジャッジ時間 | 20,302 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 10 WA * 9 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:
if len(p)>0 and (p[-1][1] in [1,2]) and (f in [1,2]):
p+=[[0,3]]
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+2<len(p) and p[r+1][1]==3 and p[r+2][1]==f:
r+=2
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
w=[w for w,f in p[l:r+1]]
f=p[l][1]==3
m=len(w)
q=[0]*(m+1)
for i in range(m):
for k in range([2,3][(i+f)%2]):
if i-k>=0:
q[i]=max(q[i],q[i-k-1]+sum(w[i-k:i+1])**2)
a+=q[m-1]
l=r
l+=1
print(a)
sasa8uyauya