2069Trip

2069   Trip

题目描述

Xiao wang has a new car, so he wants to have a trip from his home to hefei, however, there is no road from his house directly to Hefei, so he has to go through a number of cities to get to hefei, his car takes one unit of time driving a unit distance at first, but his car will be slow after every city that he pass, so he will take one more unit of time to take a unit of distance after every city (that is, if he has passed k cities, then he needs k units of time to take a unit of distance, we think his home is the first city), can you tell him how to spend the least time to reach Hefei?

输入格式:

The first line contains two numbers n and m (0 < n ≤ 200, 0 < m < n×(n-1)/2 ), n is the number of city, 1 is xiaowang's home, n is hefei, m is the number of road, bi-directional edge, then the following m line contains 3 numbers x, y, z, means there is a road from x to y, the distance is z.(You can make sure that there is always a path exist between his home ande hefei).

输出格式:

The least time xiao wang must use from his home to hefei.

输入样例 复制
5 6
1 2 1
1 4 5
2 3 2
3 5 1
4 5 1
2 4 2
输出样例 复制
7

说明

1
2
通过提交
时空限制1000ms/128mb
题目来源
评测方式在线评测
题目类型
难        度