• 微信公众号：美女很有趣。 工作之余，放松一下，关注即送10G+美女照片！

# P2387母牛回家

2周前 (04-30) 8次浏览

``````import java.io.BufferedReader;
import java.nio.Buffer;
import java.util.*;

public class Main {
public static void main(String[] args) throws Exception {
int T = Integer.parseInt(st.nextToken());
int N = Integer.parseInt(st.nextToken());

for(int i = 0;i<T;i++){
int start = Integer.parseInt(st.nextToken());
int end = Integer.parseInt(st.nextToken());
int weight = Integer.parseInt(st.nextToken());
}
}
}

PriorityQueue<int[]> pq = new PriorityQueue<int[]>(new Comparator<int[]>() {
@Override
public int compare(int[] o1, int[] o2) {
return o1[1]-o2[1];
}
});

int[] visitDist = new int[N+1];
Arrays.fill(visitDist,100000000);
visitDist[N] = 0;

int cost=0;
while(!pq.isEmpty()){
int[] visit = pq.poll();
if(visit[0] == 1){
cost = visit[1];
break;
}
for(int i =0;i<conn.size();i++){
int[] nextPoint = conn.get(i).clone();
nextPoint[1] = nextPoint[1]+visit[1];
if(nextPoint[1]<visitDist[nextPoint[0]]){
visitDist[nextPoint[0]] = nextPoint[1];