Language: C++

#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

int main(){
    ll N; cin >> N;
    vvll e(N+1, vll(0));
    vector<P> h(0);
    rep(i, 0, N-1){
        ll a, b; cin >> a >> b;
        e[a].emplace_back(b);
        e[b].emplace_back(a);
        h.emplace_back(P(max(a,b), min(a,b)));
    }
    vll c(N);
    ll s = 0;
    rep(i, 0, N){
        cin >> c[i];
        s += c[i];
    }
    sort(c.begin(),c.end(),greater<ll>());
    vll num(N+1);
    num[1] = c[0];
    queue<ll> q(0);
    for(auto x:e[1]){
        q.push(x);
    }
    vb ald(N+1, false);
    ald[1] = true;
    ll t = 1;
    while(!q.empty()){
        ll a = q.front();
        ald[a] = true;
        num[a] = c[t];
        q.pop();
        for(auto x: e[a]){
            if(!ald[x]){
                q.push(x);
            }
        }
        t++;
    }
    prtl(s-c[0]);
    rep(i, 1, N+1){
        prt(num[i]); prt(" ");
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:18: error: no matching function for call to 'std::queue<long long int>::queue(int)'
   48 |     queue<ll> q(0);
      |                  ^
In file included from /usr/include/c++/14/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_queue.h:195:9: note: candidate: 'template<class _Alloc, class _Requires> std::queue<_Tp, _Sequence>::queue(std::queue<_Tp, _Sequence>&&, const _Alloc&) [with _Requires = _Alloc; _Tp = long long int; _Sequence = std::deque<long long int, std::allocator<long long int> >]'
  195 |         queue(queue&& __q, const _Alloc& __a)
      |         ^~~~~
/usr/include/c++/14/bits/stl_queue.h:195:9: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_queue.h:191:9: note: candidate: 'template<class _Alloc, class _Requires> std::queue<_Tp, _Sequence>::queue(const std::queue<_Tp, _Sequence>&, const _Alloc&) [with _Requires = _Alloc; _Tp = long long int; _Sequence = std::deque<long long int, std::allocator<long long int> >]'
  191 |         queue(const queue& __q, const _Alloc& __a)
      |         ^~~~~
/usr/include/c++/14/bits/stl_queue.h:191:9: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_queue.h:187:9: note: candidate: 'template<class _Alloc, class _Requires> std::queue<_Tp, _Sequence>::queue(_Sequence&&, const _Alloc&) [with _Requires = _Alloc; _Tp = long long int; _Sequence = std::deque<long long int, std::allocator<long long int> >]'
  187 |         queue(_Sequence&& __c, const _Alloc& __a)
      |         ^~~~~
/usr/include/c++/14/bits/stl_queue.h:187:9: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_queue.h:183:9: note: candidate: 'template<class _Alloc, class _Requires> std::queue<_Tp, _Sequence>::queue(const _Sequence&, const _Alloc&) [with _Requires = _Alloc; _Tp = long long int; _Sequence = std::deque<long long int, std::allocator<long long int> >]'
  183 |         queue(const _Sequence& __c, const _Alloc& __a)
      |         ^~~~~
/usr/include/c++/14/bits/stl_queue.h:183:9: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_queue.h:179:9: note: candidate: 'template<class _Alloc, class _Requires> std::queue<_Tp, _Sequence>::queue(const _Alloc&) [with _Requires = _Alloc; _Tp = long long int; _Sequence = std::deque<long long int, std::allocator<long long int> >]'
  179 |         queue(const _Alloc& __a)
      |         ^~~~~
/usr/include/c++/14/bits/stl_queue.h:179:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_queue.h: In substitution of 'template<class _Tp, class _Sequence> template<class _Alloc> using std::queue<_Tp, _Sequence>::_Uses = typename std::enable_if<std::uses_allocator<_Sequence, _Alloc>::value>::type [with _Alloc = int; _Tp = long long int; _Sequence = std::deque<long long int, std::allocator<long long int> >]':
/usr/include/c++/14/bits/stl_queue.h:177:33:   required from here
  177 |       template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
      |                                 ^~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:125:15: error: no type named 'type' in 'struct std::enable_if<false, void>'
  125 |         using _Uses = typename
      |               ^~~~~
/usr/include/c++/14/bits/stl_queue.h:166:9: note: candidate: 'template<class _Seq, class _Requires> std::queue<_Tp, _Sequence>::queue() [with _Requires = _Seq; _Tp = long long int; _Sequence = std::deque<long long int, std::allocator<long long int> >]'
  166 |         queue()
      |         ^~~~~
/usr/include/c++/14/bits/stl_queue.h:166:9: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/bits/stl_queue.h:174:7: note: candidate: 'std::queue<_Tp, _Sequence>::queue(_Sequence&&) [with _Tp = long long int; _Sequence = std::deque<long long int, std::allocator<long long int> >]'
  174 |       queue(_Sequence&& __c)
      |       ^~~~~
/usr/include/c++/14/bits/stl_queue.h:174:25: note:   no known conversion for argument 1 from 'int' to 'std::deque<long long int, std::allocator<long long int> >&&'
  174 |       queue(_Sequence&& __c)
      |             ~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_queue.h:170:7: note: candidate: 'std::queue<_Tp, _Sequence>::queue(const _Sequence&) [with _Tp = long long int; _Sequence = std::deque<long long int, std::allocator<long long int> >]'
  170 |       queue(const _Sequence& __c)
      |       ^~~~~
/usr/include/c++/14/bits/stl_queue.h:170:30: note:   no known conversion for argument 1 from 'int' to 'const std::deque<long long int, std::allocator<long long int> >&'
  170 |       queue(const _Sequence& __c)
      |             ~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_queue.h:96:11: note: candidate: 'std::queue<long long int>::queue(const std::queue<long long int>&)'
   96 |     class queue
      |           ^~~~~
/usr/include/c++/14/bits/stl_queue.h:96:11: note:   no known conversion for argument 1 from 'int' to 'const std::queue<long long int>&'
/usr/include/c++/14/bits/stl_queue.h:96:11: note: candidate: 'std::queue<long long int>::queue(std::queue<long long int>&&)'
/usr/include/c++/14/bits/stl_queue.h:96:11: note:   no known conversion for argument 1 from 'int' to 'std::queue<long long int>&&'