結果
| 問題 |
No.3289 Make More Happy Connection
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2025-10-07 02:23:18 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 650 bytes |
| コンパイル時間 | 677 ms |
| コンパイル使用メモリ | 12,160 KB |
| 実行使用メモリ | 10,496 KB |
| 最終ジャッジ日時 | 2025-10-07 02:23:47 |
| 合計ジャッジ時間 | 28,598 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 WA * 3 |
ソースコード
import sys
input = sys.stdin.readline
from collections import Counter
n=int(input())
DP=Counter()
DP[-1]=0
for i in range(n):
x,y=map(int,input().split())
NDP=Counter()
if x==y:
for dp in DP:
score=DP[dp]
if dp==x:
score+=x
score+=x
NDP[x]=score
else:
for dp in DP:
score=DP[dp]
if x==dp:
score+=x
NDP[y]=max(NDP[y],score)
score=DP[dp]
if y==dp:
score+=y
NDP[x]=max(NDP[x],score)
DP=NDP
ANS=max(DP.values())
print(ANS)
titia