結果
| 問題 |
No.3289 Make More Happy Connection
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-10-03 22:55:57 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 331 ms / 2,000 ms |
| コード長 | 700 bytes |
| コンパイル時間 | 365 ms |
| コンパイル使用メモリ | 82,340 KB |
| 実行使用メモリ | 76,896 KB |
| 最終ジャッジ日時 | 2025-10-03 22:56:04 |
| 合計ジャッジ時間 | 6,912 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
import sys
sys.setrecursionlimit(10**7)
def ii(): return int(input())
def mi(d=0): return map(lambda x:int(x)-d,input().split())
INF = float("inf")
MOD = 998244353
def answer(s):
print(s)
exit()
def cross(xy):
x,y = xy
return (x+1,y),(x-1,y),(x,y+1),(x,y-1)
################################################
n = ii()
back = [-1,-1]
score = [0,0]
for _ in range(n):
x,y = mi()
nb = [-1,-1]
ns = [0,0]
i = 0
for x,y in ((x,y),(y,x)):
if x in back:
ns[i] = max(score[back.index(x)] + x,max(score))
else:
ns[i] = max(score)
nb[i] = y
i += 1
if x == y:
ns[0] += x
ns[1] += x
back = nb
score = ns
print(max(score))