
#include <bits/stdc++.h>
using namespace std;
#define ll long long


using namespace std;

void mincammino(int N, int M, vector<int> X, vector<int> Y, vector<int> P, vector<long long>& D) {
    fill(D.begin(), D.end(), -1);

  


    vector<vector<pair<ll,ll>>> grapo (N);
    for (ll i=0; i<M; i++){
        grapo[X[i]].push_back({Y[i],P[i]});
        
    }

    priority_queue<pair<ll,ll>,vector<pair<ll,ll>>, greater<pair<ll,ll>>> pq;
    pq.push({0,0});
   

    pair<ll,ll> temp;

    while (!pq.empty()){
     
        temp=pq.top();
         pq.pop();
         if (D[temp.second]!=-1) continue;
      
         
      
      D[temp.second]=temp.first;

         for (pair<ll,ll> node : grapo[temp.second]){
            pq.push({temp.first+node.second,node.first});
         }


    }

    
}
