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

Arc _

RankUserSizeTimeDateStatistics
1pooq40.79242019/08/08 11:19:260B / ?B / ?B

Clojure _

RankUserSizeTimeDateStatistics
1cympfh90.74922019/04/17 15:44:490B / 6B / 2B
2pooq60.67212019/08/10 05:24:360B / ?B / ?B

Io _

RankUserSizeTimeDateStatistics
1pooq60.06672019/09/06 04:04:390B / ?B / ?B

JavaScript _

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

Tcl _

RankUserSizeTimeDateStatistics
1pooq60.03682019/08/19 11:13:510B / ?B / ?B

Xtal _

RankUserSizeTimeDateStatistics
1pooq40.03602019/08/08 17:15:310B / ?B / ?B

Crystal _

RankUserSizeTimeDateStatistics
1pooq30.01182019/08/12 18:00:530B / ?B / ?B

Kite _

RankUserSizeTimeDateStatistics
1pooq80.01122019/08/22 05:55:260B / ?B / ?B

REXX _

RankUserSizeTimeDateStatistics
1pooq50.01962019/08/28 18:45:200B / ?B / ?B

PARI/GP _

RankUserSizeTimeDateStatistics
1pooq130.01082019/08/10 04:11:550B / ?B / ?B

Squirrel _

RankUserSizeTimeDateStatistics
1pooq80.00012019/08/04 07:48:080B / ?B / ?B

Forth _

RankUserSizeTimeDateStatistics
1pooq30.01142019/08/15 13:15:110B / ?B / ?B

BASIC _

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

Perl6 _

RankUserSizeTimeDateStatistics
1pooq50.66872019/10/14 06:21:330B / ?B / ?B

A+ _

RankUserSizeTimeDateStatistics
1pooq80.13772019/09/20 13:07:350B / ?B / ?B

K _

RankUserSizeTimeDateStatistics
1pooq50.03982019/08/25 19:30:180B / ?B / ?B

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

Chapel _

RankUserSizeTimeDateStatistics
1pooq90.01372019/08/11 10:36:590B / ?B / ?B

Maxima _

RankUserSizeTimeDateStatistics
1pooq90.05642019/09/28 11:39:570B / ?B / ?B

Octave _

RankUserSizeTimeDateStatistics
1pooq60.13062019/09/07 10:42:050B / ?B / ?B

Euphoria _

RankUserSizeTimeDateStatistics
1_20.01252019/08/13 12:45:000B / ?B / ?B

AWK _

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

sed _

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

jq _

RankUserSizeTimeDateStatistics
1pooq10.01062019/07/16 06:52:040B / ?B / ?B

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

Fish _

RankUserSizeTimeDateStatistics
1pooq60.01322019/10/14 11:40:330B / ?B / ?B

bc _

RankUserSizeTimeDateStatistics
1pooq20.01102019/07/24 04:39:430B / ?B / ?B

dc _

RankUserSizeTimeDateStatistics
1Erik the Outgolfer20.00022019/04/27 02:04:050B / 2B / 0B

m4 _

RankUserSizeTimeDateStatistics
1McBusLuck10.01882019/07/27 18:49:240B / 1B / 0B

Postscript _

RankUserSizeTimeDateStatistics
1pooq30.12432019/10/06 06:11:570B / ?B / ?B

R _

RankUserSizeTimeDateStatistics
1pooq60.26052019/07/27 12:58:330B / ?B / ?B

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

Labyrinth _

RankUserSizeTimeDateStatistics
1pooq30.06212019/08/05 21:32:010B / ?B / ?B

Hexagony _

RankUserSizeTimeDateStatistics
1pooq30.01952019/08/13 10:24:050B / ?B / ?B

><> _

RankUserSizeTimeDateStatistics
1Unihedron ユニ30.05272019/04/17 14:49:570B / 3B / 0B
2Erik the Outgolfer30.13862019/04/27 01:58:290B / 2B / 1B

Minus _

RankUserSizeTimeDateStatistics
1pooq40.00012019/10/03 18:54:560B / ?B / ?B

gs2 _

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

FlogScript _

RankUserSizeTimeDateStatistics
1pooq20.05492019/10/14 04:43:090B / ?B / ?B

Burlesque _

RankUserSizeTimeDateStatistics
1pooq20.08792019/08/03 07:53:190B / ?B / ?B

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

z80 _

RankUserSizeTimeDateStatistics
1McBusLuck40.00022019/07/27 18:48:231B / 2B / 1B

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
2pooq30.04772019/07/29 10:57:450B / ?B / ?B

Scala _

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

Language Ranking_

RankLangUserSizeScore
1PHPZED.CWT110000
2gs2Unihedron ユニ110000
3jqpooq110000
4m4McBusLuck110000
5dcErik the Outgolfer25000
6BASICErik the Outgolfer25000
7bcpooq25000
8Burlesquepooq25000
9Euphoria25000
10FlogScriptpooq25000
11><>Unihedron ユニ33333
12BefungeUnihedron ユニ33333
13Befunge-98Unihedron ユニ33333
14gorubyUnihedron ユニ33333
15RubyUnihedron ユニ33333
16Ruby2Unihedron ユニ33333
17Labyrinthpooq33333
18Crystalpooq33333
19Hexagonypooq33333
20Forthpooq33333
21Postscriptpooq33333
22BrainfuckUnihedron ユニ42500
23ZshErik the Outgolfer42500
24UnlambdaErik the Outgolfer42500
25DOSMcBusLuck42500
26z80McBusLuck42500
27Arcpooq42500
28Xtalpooq42500
29Minuspooq42500
30PefungeUnihedron ユニ52000
31Kpooq52000
32REXXpooq52000
33Perl6pooq52000
34Bashmypetlion61666
35Rpooq61666
36Clojurepooq61666
37Tclpooq61666
38Iopooq61666
39Octavepooq61666
40Fishpooq61666
41Pythonmypetlion71428
42Python3mypetlion81250
43Scalacympfh81250
44Vimcympfh81250
45Squirrelpooq81250
46Kitepooq81250
47A+pooq81250
48JavaScriptmypetlion91111
49Schemecympfh91111
50Common LISPcympfh91111
51Chapelpooq91111
52Maximapooq91111
53AWKUnihedron ユニ101000
54sedUnihedron ユニ101000
55PARI/GPpooq13769
56CErik the Outgolfer18555
57FerNANDoErik the Outgolfer19526
58Rusthako22454
59Gomypetlion34294
60Javamypetlion71140

return to the top page