← 返回 microsoft 的题目列表Maximum Sum of Edge Values in an Undirected Graph
类型:online_judge
Given an undirected graph, you need to assign each of the N nodes a value from 1 to N. The value of each edge equals the sum of the values of the two nodes it connects. Find the maximum possible sum of all edge values.
Input Format:
First line contains two integers, N (number of nodes) and M (number of edges).
The next M lines each contains two integers u and v, indicating there is an undirected edge between node u and node v.
Output Format:
Output an integer, representing the maximum possible sum of all edge values.
Constraints:
1 ≤ N ≤ 100000
1 ≤ M ≤ 200000
Example: Input: 4 3 1 2 2 3 3 4 Output: 14
Example
Input
4 3
1 2
2 3
3 4