a564. ITSA201205 P4 Group without direct leaders
標籤 :
通過比率 : 26人/31人 ( 84% ) [非即時]
評分方式:
Tolerant

最近更新 : 2012-10-24 20:17

內容
In X company, everyone, except the CEO, has a direct leader. There are n persons in the company and everyone has a unique ID from 0 to n-1. The ID of the CEO is 0, and the ID of any one is larger than the one of his/her direct leader. Besides everyone has a weight which is a positive integer. We want to find a group of weight as large as possible such that no one is the direct leader of any other in the group.
輸入說明
The input contains three lines. The first line is an integers n, 1<n<=90000, which indicates the number of persons in the company. The second line consists of n integers which are the weights of person 0,1,…, n-1, respectively. The total weight is no more than 100,000,000. In the third line, there are n-1 integers which are the ID of direct leaders of person 1, 2,…, n-1, respectively.
輸出說明
Output the maximum number of person we can group in one line.
範例輸入 #1
5
10 20 30 40 50
0 1 1 3
範例輸出 #1
90
測資資訊:
記憶體限制: 512 MB
公開 測資點#0 (100%): 1.0s , <10M
提示 :
標籤:
出處:
ITSA201205 [管理者: morris1028 (碼畜) ]

本題狀況 本題討論 排行

編號 身分 題目 主題 人氣 發表日期
沒有發現任何「解題報告」