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

Jelly _

RankUserSizeTimeDateStatistics
1pooq10.14622021/03/22 06:13:580B / ?B / ?B
2Erik the Outgolfer10.15592021/05/19 16:57:280B / 1B / 0B

C _

RankUserSizeTimeDateStatistics
1Erik the Outgolfer180.01102019/04/27 02:02:340B / 9B / 9B
2鳴神裁4.1号(Dis:45 bytes)7230.01382021/09/28 16:26:540B / 371B / 249B

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

gnuplot _

RankUserSizeTimeDateStatistics
1pooq40.02322021/04/03 11:44:340B / ?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
2Fleur50.01392021/09/28 20:33:090B / 2B / 3B

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
3Erik the Outgolfer60.01442020/11/14 09:04:500B / 5B / 0B

Bash (builtins) _

RankUserSizeTimeDateStatistics
1Erik the Outgolfer60.01452020/11/14 09:04:570B / 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
2Fleur20.01392021/09/28 20:33:420B / 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

GolfScript _

RankUserSizeTimeDateStatistics
1Erik the Outgolfer20.02102020/11/14 09:05:490B / 1B / 1B

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

return to the top page