Apple tree

Submit

Your name:
File:
Open code-statistics:

Language is selected by the extension of the file. See the list of supported languages to know the extension of your language.

Problem

A wants to pick apples from a tree with n apples(numbered from 1 to n). The ith apple's weight is the ith element of w. The largest weight that A can handle is m. Also, he wishes that the apples picked is a connected graph.

A wants to take as many apples as possible. Please help him find out the maximum number of apples possible to be taken by him.

n and m are inputted on the first line. They represent the weight of the apples on the tree and the maximum weight that A can handle.

The second line contains n integers, where the ith integer represents the ith element of w.

In the following n-1 lines, the ith element of u and v are inputted on each line. They represent that the ith element of u and v are on the same branch.

Output an integer in a line, which shows the maximum number of apples that A can take.

Options

exec is denied

rejudge feature is enabled

6day(s) and 2:34:53 before deadline (04/27 14:14:13 JST), all source codes will be revealed after the deadline

Sample input:_

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

Sample output:

3

Ranking

Ruby _

RankUserSizeTimeDateStatistics
1Unihedron ユニ30.00012019/04/17 14:52:430B / 2B / 0B

Ruby2 _

RankUserSizeTimeDateStatistics
1Unihedron ユニ30.04832019/04/17 14:52:500B / 2B / 0B

Python _

RankUserSizeTimeDateStatistics
1mypetlion70.02332019/04/16 06:31:260B / 6B / 0B

Python3 _

RankUserSizeTimeDateStatistics
1mypetlion80.03752019/04/16 01:30:430B / 6B / 2B

PHP _

RankUserSizeTimeDateStatistics
1ZED.CWT10.14422019/04/14 11:42:240B / 1B / 0B

Scheme _

RankUserSizeTimeDateStatistics
1cympfh90.02652019/04/17 15:39:090B / 6B / 2B
2mypetlion110.05892019/04/17 00:43:460B / 8B / 2B

Common LISP _

RankUserSizeTimeDateStatistics
1cympfh90.01552019/04/17 15:45:300B / 6B / 2B

Clojure _

RankUserSizeTimeDateStatistics
1cympfh90.74922019/04/17 15:44:490B / 6B / 2B

JavaScript _

RankUserSizeTimeDateStatistics
1mypetlion90.01222019/04/17 00:42:450B / 7B / 2B

Go _

RankUserSizeTimeDateStatistics
1mypetlion340.01032019/04/17 00:45:230B / 25B / 6B

Rust _

RankUserSizeTimeDateStatistics
1hako220.01372019/04/20 20:58:100B / 12B / 9B
2cympfh250.01422019/04/17 15:49:190B / 12B / 12B

Java _

RankUserSizeTimeDateStatistics
1mypetlion710.04692019/04/17 00:41:160B / 53B / 13B

AWK _

RankUserSizeTimeDateStatistics
1Unihedron ユニ100.01042019/04/17 14:56:030B / 4B / 6B

sed _

RankUserSizeTimeDateStatistics
1Unihedron ユニ100.01042019/04/17 15:00:520B / 4B / 5B

Bash _

RankUserSizeTimeDateStatistics
1mypetlion60.00022019/04/17 00:43:020B / 5B / 0B
2cympfh60.00012019/04/17 15:35:240B / 5B / 0B

Zsh _

RankUserSizeTimeDateStatistics
1cympfh60.02382019/04/17 15:46:160B / 5B / 0B

Brainfuck _

RankUserSizeTimeDateStatistics
1Unihedron ユニ40.01052019/04/17 14:51:480B / 0B / 4B
2mypetlion230.00022019/04/16 06:32:440B / 0B / 23B

Befunge _

RankUserSizeTimeDateStatistics
1Unihedron ユニ30.00022019/04/17 14:52:050B / 1B / 2B

Befunge-98 _

RankUserSizeTimeDateStatistics
1Unihedron ユニ30.00022019/04/17 14:52:130B / 1B / 2B

Pefunge _

RankUserSizeTimeDateStatistics
1Unihedron ユニ50.01092019/04/17 14:53:070B / 2B / 3B

><> _

RankUserSizeTimeDateStatistics
1Unihedron ユニ30.05272019/04/17 14:49:570B / 3B / 0B

gs2 _

RankUserSizeTimeDateStatistics
1Unihedron ユニ10.06002019/04/17 15:02:080B / 1B / 0B

Vim _

RankUserSizeTimeDateStatistics
1cympfh80.00972019/04/17 15:53:481B / 6B / 0B

goruby _

RankUserSizeTimeDateStatistics
1Unihedron ユニ30.01842019/04/17 14:52:250B / 2B / 0B

Scala _

RankUserSizeTimeDateStatistics
1cympfh81.70422019/04/17 15:47:590B / 6B / 2B

Language Ranking_

RankLangUserSizeScore
1PHPZED.CWT110000
2gs2Unihedron ユニ110000
3><>Unihedron ユニ33333
4BefungeUnihedron ユニ33333
5Befunge-98Unihedron ユニ33333
6gorubyUnihedron ユニ33333
7RubyUnihedron ユニ33333
8Ruby2Unihedron ユニ33333
9BrainfuckUnihedron ユニ42500
10PefungeUnihedron ユニ52000
11Bashmypetlion61666
12Zshcympfh61666
13Pythonmypetlion71428
14Python3mypetlion81250
15Scalacympfh81250
16Vimcympfh81250
17JavaScriptmypetlion91111
18Schemecympfh91111
19Clojurecympfh91111
20Common LISPcympfh91111
21AWKUnihedron ユニ101000
22sedUnihedron ユニ101000
23Rusthako22454
24Gomypetlion34294
25Javamypetlion71140

return to the top page