結果
| 問題 | No.3407 Birds-of-Paradise' Christmas Live |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-12-11 00:28:16 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,257 bytes |
| 記録 | |
| コンパイル時間 | 225 ms |
| コンパイル使用メモリ | 82,588 KB |
| 実行使用メモリ | 159,948 KB |
| 最終ジャッジ日時 | 2025-12-13 23:30:13 |
| 合計ジャッジ時間 | 5,537 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 |
| other | AC * 5 WA * 15 |
ソースコード
def solve(arr):
if len(arr)==1:
return arr[0]*arr[0]
arr[1]+=arr[0]
arr[-2]+=arr[-1]
arr.pop()
arr.pop(0)
if len(arr)==1:
return arr[0]*arr[0]
while len(arr)%4!=0:
arr.append(0)
s1=0
s2=0
arr=[0,0]+arr+[0,0]
for i in range(0,len(arr),4):
s1+=arr[i]**2+(arr[i+1]+arr[i+2]+arr[i+3])**2
for i in range(0,len(arr),4):
s2+=arr[i]**2+(arr[i+1]+arr[i+2]+arr[i+3])**2
return max(s1,s2)
n=int(input())
w=list(map(int,input().split()))
m=int(input())
s=list(map(int,input().split()))
run=[]
wp=0
sp=0
wl=0
sl=0
while wp<n and sp<m:
wr=wl+w[wp]
sr=sl+s[sp]
if min(wr,sr)-max(wl,sl)!=0:
run.append((((wp+1)%2)*2+(sp+1)%2,min(wr,sr)-max(wl,sl)))
if wr<sr:
wl=wr
wp+=1
else:
sl=sr
sp+=1
run.append((0,0))
now=[]
ans=0
bef=-1
for i in run:
if i[0]==0:
if len(now)%2==0:
now.append(0)
ans+=solve(now)
now=[]
bef=-1
elif i[0]==3:
now.append(i[1])
else:
if len(now)%2==0:
now.append(0)
if bef==i[0]:
now[-2]+=now[-1]+i[1]
now.pop()
else:
now.append(i[1])
bef=i[0]
print(ans)