Apple tree
Submit
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
Rank | User | Size | Time | Date | Statistics |
---|
1 | ZED.CWT | 1 | 0.1442 | 2019/04/14 11:42:24 | 0B / 1B / 0B |
2 | #c0ffee | 1 | 0.0529 | 2024/09/26 14:29:33 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | pooq | 4 | 0.7924 | 2019/08/08 11:19:26 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | cympfh | 9 | 0.7492 | 2019/04/17 15:44:49 | 0B / 6B / 2B |
2 | pooq | 6 | 0.6721 | 2019/08/10 05:24:36 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | pooq | 6 | 0.0667 | 2019/09/06 04:04:39 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | pooq | 6 | 0.0368 | 2019/08/19 11:13:51 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | pooq | 4 | 0.0360 | 2019/08/08 17:15:31 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | pooq | 3 | 0.0118 | 2019/08/12 18:00:53 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | pooq | 8 | 0.0112 | 2019/08/22 05:55:26 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | pooq | 5 | 0.0196 | 2019/08/28 18:45:20 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | pooq | 13 | 0.0108 | 2019/08/10 04:11:55 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | pooq | 8 | 0.0001 | 2019/08/04 07:48:08 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | pooq | 3 | 0.0114 | 2019/08/15 13:15:11 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | pooq | 5 | 0.6687 | 2019/10/14 06:21:33 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | pooq | 8 | 0.1377 | 2019/09/20 13:07:35 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | pooq | 5 | 0.0398 | 2019/08/25 19:30:18 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | hako | 22 | 0.0137 | 2019/04/20 20:58:10 | 0B / 12B / 9B |
2 | cympfh | 25 | 0.0142 | 2019/04/17 15:49:19 | 0B / 12B / 12B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | pooq | 9 | 0.0137 | 2019/08/11 10:36:59 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | pooq | 9 | 0.0564 | 2019/09/28 11:39:57 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | pooq | 4 | 0.0232 | 2021/04/03 11:44:34 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | pooq | 6 | 0.1306 | 2019/09/07 10:42:05 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | _ | 2 | 0.0125 | 2019/08/13 12:45:00 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | pooq | 1 | 0.0106 | 2019/07/16 06:52:04 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | pooq | 6 | 0.0132 | 2019/10/14 11:40:33 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | pooq | 2 | 0.0110 | 2019/07/24 04:39:43 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | pooq | 3 | 0.1243 | 2019/10/06 06:11:57 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | pooq | 6 | 0.2605 | 2019/07/27 12:58:33 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | pooq | 3 | 0.0621 | 2019/08/05 21:32:01 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | pooq | 3 | 0.0195 | 2019/08/13 10:24:05 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | pooq | 4 | 0.0001 | 2019/10/03 18:54:56 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | pooq | 2 | 0.0549 | 2019/10/14 04:43:09 | 0B / ?B / ?B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | pooq | 2 | 0.0879 | 2019/08/03 07:53:19 | 0B / ?B / ?B |
Language Ranking_
Rank | Lang | User | Size | Score |
1 | PHP | ZED.CWT | 1 | 10000 |
2 | gs2 | Unihedron ユニ | 1 | 10000 |
3 | jq | pooq | 1 | 10000 |
4 | m4 | McBusLuck | 1 | 10000 |
5 | Jelly | pooq | 1 | 10000 |
6 | dc | Erik the Outgolfer | 2 | 5000 |
7 | BASIC | Erik the Outgolfer | 2 | 5000 |
8 | bc | pooq | 2 | 5000 |
9 | Burlesque | pooq | 2 | 5000 |
10 | Euphoria | | 2 | 5000 |
11 | FlogScript | pooq | 2 | 5000 |
12 | GolfScript | Erik the Outgolfer | 2 | 5000 |
13 | ><> | Unihedron ユニ | 3 | 3333 |
14 | Befunge | Unihedron ユニ | 3 | 3333 |
15 | Befunge-98 | Unihedron ユニ | 3 | 3333 |
16 | goruby | Unihedron ユニ | 3 | 3333 |
17 | Ruby | Unihedron ユニ | 3 | 3333 |
18 | Ruby2 | Unihedron ユニ | 3 | 3333 |
19 | Labyrinth | pooq | 3 | 3333 |
20 | Crystal | pooq | 3 | 3333 |
21 | Hexagony | pooq | 3 | 3333 |
22 | Forth | pooq | 3 | 3333 |
23 | Postscript | pooq | 3 | 3333 |
24 | Brainfuck | Unihedron ユニ | 4 | 2500 |
25 | Zsh | Erik the Outgolfer | 4 | 2500 |
26 | Unlambda | Erik the Outgolfer | 4 | 2500 |
27 | DOS | McBusLuck | 4 | 2500 |
28 | z80 | McBusLuck | 4 | 2500 |
29 | Arc | pooq | 4 | 2500 |
30 | Xtal | pooq | 4 | 2500 |
31 | Minus | pooq | 4 | 2500 |
32 | gnuplot | pooq | 4 | 2500 |
33 | Pefunge | Unihedron ユニ | 5 | 2000 |
34 | K | pooq | 5 | 2000 |
35 | REXX | pooq | 5 | 2000 |
36 | Perl6 | pooq | 5 | 2000 |
37 | AWK | Fleur | 5 | 2000 |
38 | Bash | mypetlion | 6 | 1666 |
39 | R | pooq | 6 | 1666 |
40 | Clojure | pooq | 6 | 1666 |
41 | Tcl | pooq | 6 | 1666 |
42 | Io | pooq | 6 | 1666 |
43 | Octave | pooq | 6 | 1666 |
44 | Fish | pooq | 6 | 1666 |
45 | Bash (builtins) | Erik the Outgolfer | 6 | 1666 |
46 | Python | mypetlion | 7 | 1428 |
47 | Python3 | mypetlion | 8 | 1250 |
48 | Scala | cympfh | 8 | 1250 |
49 | Vim | cympfh | 8 | 1250 |
50 | Squirrel | pooq | 8 | 1250 |
51 | Kite | pooq | 8 | 1250 |
52 | A+ | pooq | 8 | 1250 |
53 | JavaScript | #c0ffee | 8 | 1250 |
54 | Scheme | cympfh | 9 | 1111 |
55 | Common LISP | cympfh | 9 | 1111 |
56 | Chapel | pooq | 9 | 1111 |
57 | Maxima | pooq | 9 | 1111 |
58 | sed | Unihedron ユニ | 10 | 1000 |
59 | PARI/GP | pooq | 13 | 769 |
60 | C | Erik the Outgolfer | 18 | 555 |
61 | FerNANDo | Erik the Outgolfer | 19 | 526 |
62 | Rust | hako | 22 | 454 |
63 | Go | mypetlion | 34 | 294 |
64 | Java | mypetlion | 71 | 140 |
return to the top page