시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB32266.667%

문제

There is a connected weighted graph with $N$ vertices, numbered from $1$ to $N$, and $M$ edges, numbered from $1$ to $M$. Edge $i$ connects vertex $U_i$ and vertex $V_i$ bidirectionally with weight $W_i$.

You want to travel from vertex $1$ to vertex $2$, then from vertex $2$ to vertex $3$. You are allowed to visit any vertex or any edge more than once. The cost of your entire travel is the sum of the weights you passed through.

There is, however, a catch, in which every time you pass through an edge, its weight will be halved then rounded up to the nearest integer. Formally, if its weight is previously $w$, then it will change into $\lceil \frac{w}{2} \rceil$ after you pass through it.

Calculate the minimum cost of your entire travel.

입력

The first line contains an integer $N$ and $M$ ($3 \leq N \leq 100000$; $N - 1 \leq M \leq 200000$). Each of the next $M$ lines contains $U_i$, $V_i$, and $W_i$ ($1 \leq U_i < V_i \leq N$; $1 \leq W_i \leq 10^9$) describing an edge. The graph you are given contains no multi-edges.

출력

Output the cost of your entire travel in a single line.

예제 입력 1

6 7
5 6 1
4 5 1
3 4 1
1 4 5
2 5 2
3 6 1
2 6 2

예제 출력 1

11

예제 입력 2

3 2
1 2 265
1 3 265

예제 출력 2

663

노트

Explanation of Sample 1: The graph can be illustrated as follows.

You can travel from vertex $1$ to vertex $2$ by traversing the vertices $1 \to 4 \to 5 \to 2$. The weights of the traversed edges are changed into $3$, $1$, and $1$ respectively.

Then, you travel from vertex $2$ to vertex $3$ by traversing the vertices $2 \to 5 \to 6 \to 3$. The cost of the entire travel is $5+1+2+1+1+1 = 11$.