結果
| 問題 |
No.1221 木 *= 3
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-09-05 10:27:23 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 588 bytes |
| コンパイル時間 | 336 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 113,260 KB |
| 最終ジャッジ日時 | 2024-11-27 21:36:33 |
| 合計ジャッジ時間 | 6,570 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 13 RE * 5 |
ソースコード
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
tree=[[] for i in range(n)]
for i in range(n-1):
u,v=map(int,input().split())
tree[u-1].append(v-1)
tree[v-1].append(u-1)
check=[False]*n
dp=[[0,0] for i in range(n)]
def dfs(i):
global n,a,b,tree,check,dp
#頂点iを消さない場合
dp[i]=[a[i],0]
for j in tree[i]:
if not check[j]:
check[j]=True
dfs(j)
dp[i][0]+=max(dp[j][0],dp[j][1])
dp[i][1]+=max(dp[j][0],dp[j][1]+b[i]+b[j])
check[0]=True
dfs(0)
print(max(dp[0]))