Language: C++

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vector<pii> > vvpii;

#define pb push_back
#define mp make_pair
#define endl '\n'
#define INF (int)1e9
#define EPS 1e-9
#define gcd __gcd
#define rs resize
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define by(T, x) [](const T& a, const T& b) { return a.x < b.x; } //for struct sorting

void printV(vector<int> v){
	for(int i = 0; i < v.size(); i++){
		cout << v[i] << " " ;
	}
	cout << endl;
}

void print2V(vvi v){
	FOR(i, 0, v.size()){
		FOR(j, 0, v[i].size()){
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
}

int n, m;
ll dsu[100010], weight[100010], cnt[100010];
vector<pair< int, pair<int,int> > > edges;

int root(int a){
	if(dsu[a] != a){
		dsu[a] = root(dsu[a]);
	}
	return dsu[a];
}

int main(){
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> weight[i];
		dsu[i] = i;
	}
	int a, b, w;
	for(int i = 0; i < m; i++){
		cin >> a >> b >> w;
		edges.push_back( mp(w, mp(a-1, b-1) ) );
	}
	sort(edges.begin(), edges.end());
	int good_edges = 0;
	for(int i = 0; i < m; i++){
		w = edges[i].first;
		a = root( edges[i].second.first );
		b = root( edges[i].second.second );
		if(a!=b){
			dsu[a] = b;
			weight[b] = min(weight[b]+weight[a],INF);
			cnt[b] += cnt[a];
		}
		cnt[b]++;
		if(weight[b] > w){
			good_edges += cnt[b];
			cnt[b] = 0;
		}
	}
	cout << m - good_edges;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:69:40: error: no matching function for call to 'min(ll, int)'
   69 |                         weight[b] = min(weight[b]+weight[a],INF);
      |                                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:69:40: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   69 |                         weight[b] = min(weight[b]+weight[a],INF);
      |                                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:69:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   69 |                         weight[b] = min(weight[b]+weight[a],INF);
      |                                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~