# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
724938 | yeyso | Road Closures (APIO21_roads) | C++14 | 50 ms | 8476 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "roads.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<long long> minimum_closure_costs(int N, vector<int> U, vector<int> V, vector<int> W) {
int n = N;
vector<int> u = U;
vector<int> v = V;
vector<ll> w;
for(int i = 0; i < W.size(); i ++){
w.push_back(W[i]);
}
vector<ll> res(n, 0);
// k = 0
for(int i = 0; i < w.size(); i ++){
res[0] += w[i];
}
// else
sort(w.begin(), w.end());
vector<ll> prefix(w.size(), 0);
for(int i = 0; i < w.size(); i ++){
if(i >= 1){
prefix[i] = prefix[i-1] + w[i];
} else{
prefix[0] = w[0];
}
}
reverse(prefix.begin(), prefix.end());
prefix.push_back(0);
return prefix;
}
/*
g++ -std=gnu++17 -O2 -pipe -o roads grader.cpp roads.cpp
6
0 1 3
0 2 2
0 3 1
0 4 4
0 5 1
*/
/*
// k = 1;
vector<ll> dp(n-1, 0);
for(int i = 0; i < w.size(); i ++){
if(i >= 1){
if(i >= 2){
dp[i] = max(dp[i-1], dp[i-2]+w[i]);
} else {
dp[i] = max(dp[i-1], w[i]);
}
} else {
dp[i] = w[i];
}
}
res[1] = res[0] - dp[dp.size() - 1];*/
Compilation message (stderr)
# | 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... |