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

now post-mortem time, all source codes will be revealed

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

BASIC _

RankUserSizeTimeDateStatistics
1Erik the Outgolfer20.02882019/04/27 02:09:290B / 1B / 1B

C _

RankUserSizeTimeDateStatistics
1Erik the Outgolfer180.01102019/04/27 02:02:340B / 9B / 9B

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
1Erik the Outgolfer40.01202019/04/27 01:59:140B / 1B / 3B
2cympfh60.02382019/04/17 15:46:160B / 5B / 0B

dc _

RankUserSizeTimeDateStatistics
1Erik the Outgolfer20.00022019/04/27 02:04:050B / 2B / 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
2Erik the Outgolfer30.13862019/04/27 01:58:290B / 2B / 1B

gs2 _

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

FerNANDo _

RankUserSizeTimeDateStatistics
1Erik the Outgolfer190.03462019/04/27 02:10:340B / 10B / 0B

Unlambda _

RankUserSizeTimeDateStatistics
1Erik the Outgolfer40.00012019/04/27 02:15:150B / 2B / 2B

DOS _

RankUserSizeTimeDateStatistics
1McBusLuck42.69162019/05/18 05:37:542B / ?B / ?B

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
3dcErik the Outgolfer25000
4BASICErik the Outgolfer25000
5><>Unihedron ユニ33333
6BefungeUnihedron ユニ33333
7Befunge-98Unihedron ユニ33333
8gorubyUnihedron ユニ33333
9RubyUnihedron ユニ33333
10Ruby2Unihedron ユニ33333
11BrainfuckUnihedron ユニ42500
12ZshErik the Outgolfer42500
13UnlambdaErik the Outgolfer42500
14DOSMcBusLuck42500
15PefungeUnihedron ユニ52000
16Bashmypetlion61666
17Pythonmypetlion71428
18Python3mypetlion81250
19Scalacympfh81250
20Vimcympfh81250
21JavaScriptmypetlion91111
22Schemecympfh91111
23Clojurecympfh91111
24Common LISPcympfh91111
25AWKUnihedron ユニ101000
26sedUnihedron ユニ101000
27CErik the Outgolfer18555
28FerNANDoErik the Outgolfer19526
29Rusthako22454
30Gomypetlion34294
31Javamypetlion71140

return to the top page