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
2#c0ffee10.05292024/09/26 14:29:330B / ?B / ?B

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
2#c0ffee80.02762024/09/26 14:28:510B / ?B / ?B

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

iogii _

RankUserSizeTimeDateStatistics
1#c0ffee :(10.02112025/01/30 20:43:550B / ?B / ?B

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
3#c0ffee20.01372024/09/26 14:29:210B / ?B / ?B

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
3#c0ffee40.01422024/09/26 14:29:060B / ?B / ?B

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

return to the top page