AlgoUniversity
  • Go Back
Discussion
Marathon Race :

Author

Ujjwal Srivastava

Difficulty Level : Medium

Submissions : 275

Asked In : Cred

Marks :30

: 3 | : 0

$$$N$$$ cities are there connected using $$$(n-1)$$$ bidirectional roads. Each city has a score given by $$$A[i]$$$.

Two Marathons were to be organized. But the path of the marathon to contain cities with only an even score or an odd score. You have to tell the max number of cities in the marathon path if the cities were with an even score or with an odd score.

Here path refers to simple path.

Input

The first line contains $$$n$$$, the number of cities. The second line contains an array of $$$n$$$ integers denoting the score of cities from 1 to $$$n$$$. The next $$$n-1$$$ lines contain two integers each, which are connected by an edge.$$$(1 \le n \le 10^5)$$$$$$(1 \le A[i] \le 10^5).$$$

Output

The output contains a single line containing two integers $$$x$$$ and $$$y$$$ where $$$x$$$ = max number of cities in the marathon path if the cities were with an even score, $$$y$$$ = max number of cities in the marathon path if the cities were with an odd score respectively.

Examples

Input
5
4 3 2 3 5
1 2
1 3
2 4
2 5
Output
2 3
Input
1
9429
Output
0 1
Input
3
1035 28296 99007
1 3
1 2
Output
1 2

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.