結果
問題 |
No.3289 Make More Happy Connection
|
ユーザー |
![]() |
提出日時 | 2025-10-07 02:25:17 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 1,730 ms / 2,000 ms |
コード長 | 662 bytes |
コンパイル時間 | 321 ms |
コンパイル使用メモリ | 12,160 KB |
実行使用メモリ | 10,368 KB |
最終ジャッジ日時 | 2025-10-07 02:25:45 |
合計ジャッジ時間 | 25,894 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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)