#C784. Maximum Node Value in an Undirected Weighted Graph

    ID: 51755 Type: Default 1000ms 256MiB

Maximum Node Value in an Undirected Weighted Graph

Maximum Node Value in an Undirected Weighted Graph

You are given an undirected weighted graph with n nodes and m edges. The graph may contain self-loops and multiple edges. For each node, its value is defined as the sum of weights of all the edges incident to it. In the case of a self-loop (an edge from a node to itself), the weight is added twice to that node's value.

Your task is to compute and output the maximum value among all the nodes in the graph.

Formally, let the value of node i be:

$$V_i = \sum_{(u,v,w) \in E,\, (u=i \text{ or } v=i)} w $$

You need to output:

max1inVi\max_{1 \le i \le n} V_i

inputFormat

The input is given via stdin and has the following format:

  1. The first line contains two integers n and m: the number of nodes and the number of edges.
  2. Each of the following m lines contains three integers u, v, and w, representing an edge between nodes u and v with a weight of w.

outputFormat

Output a single integer to stdout — the maximum node value in the graph.

## sample
4 5
1 2 10
1 3 5
2 3 15
3 4 10
2 4 5
30

</p>