RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00486

Dostavljač

Unrated 레이팅 미적용
난이도
2s
시간 제한
64MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

2 \(s / 64\) \(MB / 140\) points

Ever since Krešo started growing chili peppers, \(N\) restaurants all over Croatia showed

interest in his peppers so they could enrich their dishes with real spice. Because of high

demand, Krešo decided to start working as a delivery guy of chili peppers.

The restaurants are denoted with numbers from 1 to \(N\) and are mutually connected with \(N\) -

1 roads such that traveling between any two restaurants is possible. Krešo begins his

journey in the restaurant denoted with 1. In one unit of time, he can either drive to the

adjacent restaurant or deliver the peppers to the current restaurant. For each restaurant, we

know the required amount of peppers \(A\) {i}{ }.

Since delivering goods is tiring, Krešo decided to spend a total of \(M\) units of time on delivery

and travel, after which he plans to take a break.

Determine the maximal amount of peppers Krešo can deliver in the given timeframe. You

can assume that Krešo always carries an unlimited supply of peppers.

제약
입력 형식

The first line of input contains two integers \(N\) and \(M\) (1 ≤ \(N\) , \(M \le 500\)), the number of

restaurants and the time Krešo plans to spend delivering peppers.
The second line of input contains \(N\) integers \(A\) {i} (1 ≤ \(A\) ≤10 {6}{ }), the required amount of peppers

for restaurants denoted with \(i\) (1 ≤ \(i\)\(N\) ).
Each of the following \(N - 1\) lines contains two integers \(U\) and \(V\) (1 ≤ \(U\) , \(V\)\(N\) , \(U\)\(V\) ) that

represent the road between restaurants \(U\) and \(V\) .

출력 형식

You must output the maximal amount of peppers Krešo can deliver in the given timeframe.

예제 1
입력
3 5
9 2 5
1 2
1 3

4 5
1 1 1 2
1 2
2 3
3 4

5 10
1 3 5 2 4
5 2
3 1
2 3
4 2
출력
output
output
14

3

15




2 s / 64 MB / 140 points
설명

Clarification of the first test case:
In the first step, Krešo will deliver the peppers to restaurant 1.
In the second step, Krešo will travel to restaurant 3.
In the third step, Krešo will deliver the peppers to restaurant 3.
He is left with 2 units of time, in which he can drive to restaurant 2, but he lacks one unit of time to

deliver the peppers to that restaurant.

문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2017/2018 Contest 7

평가 및 의견

Dostavljač

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Dostavljač

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8