#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define TASK ""
#define bit(x) (1LL << (x))
#define getbit(x, i) (((x) >> (i)) & 1)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
template <typename T1, typename T2> bool mini(T1 &a, T2 b) {
if (a > b) {a = b; return true;} return false;
}
template <typename T1, typename T2> bool maxi(T1 &a, T2 b) {
if (a < b) {a = b; return true;} return false;
}
mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r) {
return l + rd() % (r - l + 1);
}
const int N = 1e5 + 5;
const int oo = 1e9;
const long long ooo = 1e18;
const int mod = 1e9 + 7; // 998244353;
const long double pi = acos(-1);
#include "roads.h"
long long dp[N][2];
int fr[N];
int to[N];
int w[N];
int n;
vector <long long> sub1() {
sort(w, w + (n - 1), greater <int>());
long long tot = accumulate(w, w + (n - 1), 0LL);
vector <long long> res;
res.push_back(tot);
for (int i = 0; i < n - 1; i++)
tot -= w[i], res.push_back(tot);
return res;
}
vector <long long> sub2() {
vector <long long> res;
res.push_back(accumulate(w, w + (n - 1), 0LL));
for (int i = 0; i < n; i++)
for (int j = 0; j < 2; j++)
dp[i][j] = ooo;
dp[0][0] = 0;
for (int i = 1; i < n; i++) {
dp[i][0] = min(dp[i - 1][0], dp[i - 1][1]) + w[i - 1];
dp[i][1] = dp[i - 1][0];
}
res.push_back(min(dp[n - 1][0], dp[n - 1][1]));
for (int i = 2; i < n; i++)
res.push_back(0);
return res;
}
vector<long long> minimum_closure_costs(int N, vector<int> U,
vector<int> V,
vector<int> W) {
bool cond2 = true;
n = N;
for (int i = 0; i < n - 1; i++) {
fr[i] = U[i];
to[i] = V[i];
w[i] = W[i];
cond2 &= fr[i] == i && to[i] == i + 1;
}
if (*max_element(ALL(U)) == 0)
return sub1();
if (cond2)
return sub2();
return vector<long long>(N, 0);
}
#include "grader.cpp"
Compilation message
/usr/bin/ld: /tmp/ccr8mpHp.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccDODDsp.o:roads.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status