結果
| 問題 | No.3289 Make More Happy Connection |
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2025-10-07 02:25:17 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
AC
|
| 実行時間 | 1,202 ms / 2,000 ms |
| + 732µs | |
| コード長 | 662 bytes |
| 記録 | |
| コンパイル時間 | 293 ms |
| コンパイル使用メモリ | 21,280 KB |
| 実行使用メモリ | 15,740 KB |
| 最終ジャッジ日時 | 2026-07-15 14:53:39 |
| 合計ジャッジ時間 | 19,473 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
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]=max(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