結果

問題 No.3289 Make More Happy Connection
ユーザー miho-4
提出日時 2025-10-03 23:09:30
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 328 bytes
コンパイル時間 363 ms
コンパイル使用メモリ 82,672 KB
実行使用メモリ 107,872 KB
最終ジャッジ日時 2025-10-03 23:09:40
合計ジャッジ時間 8,171 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 3 WA * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
L=[list(map(int,input().split())) for _ in range(n)]
l1,l2=L[0]
s1,s2=0,0
for i in range(1,n):
	a,b=L[i]
	nx1,nx2=s1,s2
	if a==l1:
		nx1=max(nx1,s1+a)
	if a==l2:
		nx1=max(nx1,s2+a)
	if b==l1:
		nx2=max(nx2,s1+b)
	if b==l2:
		nx2=max(nx2,s2+b)
	l1,l2=b,a
	s1,s2=nx1,nx2
	if a==b:
		s1+=a
		s2+=a
print(max(s1,s2))
0