Logo
(追記) (追記ここまで)

33242번 - Excursion 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
7 초 2048 MB2410947.368%

문제

Jimmy goes on an excursion in the country of Treenidad and Treebago. People there are obsessed with trees so much, they modeled their country after them. Being a careful planner, Jimmy wants to know in advance which cities should be visited to maximize the total appeal of his excursion. The appeal of a city is defined by a not necessarily positive integer. Since he went through a lot of hassle to get his visa, he wants to visit at least one city. Jimmy's excursion can start from any city. His only requirement when visiting the country is that he mustn't visit the same city twice.

입력

The first line in the input contains an integer 1ドル\leq n \leq 10^6,ドル the number of cities in Treenidad and Treebago.\\ After that, $n$ lines follow, the first of which describes the root of the tree.\\ Each of the following lines contains two integers, $V$ and $C,ドル which describe the properties of a node in the tree:

  • $V$ represents the value at that node, with $-2^{31} \leq V < 2^{31}$.
  • $C$ represents the number of children of the node, with 0ドル \leq C < 10^6$.

After that, $C$ lines follow, each recursively defining the child trees. It is guaranteed that the height of the tree is less than or equal to 990ドル$.

출력

The maximum appeal Jimmy can gather in his excursion.

제한

예제 입력 1

5
5 2
2 2
1 0
10 0
-1 0

예제 출력 1

17

Figure E.1: Illustration of the first sample test case

예제 입력 2

7
1 3
3 2
5 0
6 0
2 1
3 0
4 0

예제 출력 2

15

Figure E.2: Illustration of the second sample test case

힌트

출처

University > Delft University of Technology > Freshmen Programming Contest 2020 E번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /