/*
Assuming we can have the correct tree with minimum sum.
4
0 1 1
0 2 2
0 3 3
ans: 6 3 1 0
*/
#include "roads.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<ll>
#define pi pair<ll,ll>
#define pb push_back
#define sz(x) ((ll)x.size())
#define sp ' '
#define endl "\n"
#define all(x) (x).begin(),(x).end()
#define rep(i,x,n) for(ll i=x; i<=n; ++i)
#define For(i,n) rep(i,0,n-1)
#define ff first
#define ss second
#define ld long double
#define mp make_pair
const ll mxN=6e5+10,OO=2e9,mod=1e9+7;
ll exp(ll b,ll p){
ll res=1;
while(p>0){
if(p&1)res=res*b%mod;
b=b*b%mod;
p/=2;
}
return res;
}
const ll inv=exp(6,mod-2);
const int dx[]{0,0,-1,1}, dy[]{1,-1,0,0};
void cmn(int &a,int b){a = min(a,b);}
void cmx(int &a,int b){a = max(a,b);}
vector<ll> minimum_closure_costs(int N, vector<int> U,vector<int> V,vector<int> W) {
sort(all(W));
ll c=0; vi ans{0};
For(i,N-1){
c+=W[i]; ans.pb(c);
} reverse(all(ans));
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |