## Min Cost Tree

Time Limit: 2 sec
Memory Limit: 256 MB
Attempts: 69
Accuracy: 1.45%
Author: Hritvi Bhandari

VeedPal has been given a tree with N vertices.

For a rooted tree, the cost of a node is defined as the size of its subtree. Now the cost of the tree is defined as the sum of the cost of all the nodes.

VeedPal is assigned the task of finding a node which when rooted gives the minimum cost of the tree.

Since Veedpal is too lazy to code, he asks you for help.

If there exist multiple answers print the node with the minimum index.

Constraints :

1 <= N <= 1000

Input:

First-line contains integer N (number of vertices)

Next, N - 1 lines contain u and v such that there is an edge between u and v

Output:

Print a single integer the node index.

Sample Test Case 1

Input:

3

1 2

2 3

Output:

2

ID

SUBMITTED AT

STATUS

LANGUAGE

TIME

MEMORY USED

USER

TIME

STATUS

LANGUAGE

TIME

MEMORY USED

6 months ago

cpp14

0.07 sec

64 KB

6 months ago

cpp

0.00 sec

0 KB

6 months ago

cpp

0.00 sec

0 KB

6 months ago

cpp

0.00 sec

0 KB

6 months ago

cpp

0.00 sec

0 KB