| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 722540 | minhnhatnoe | Worst Reporter 4 (JOI21_worst_reporter4) | C++14 | 2083 ms | 852 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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> h, c;
vector<vector<int>> g;
void get_input(){
int n; cin >> n;
g.resize(n), h.resize(n), c.resize(n);
for (int i=0; i<n; i++){
int p; cin >> p; p--;
if (i != 0) g[p].push_back(i);
cin >> h[i] >> c[i];
}
vector<int> l = h; sort(l.begin(), l.end()); l.resize(unique(l.begin(), l.end()) - l.begin());
for (int i=0; i<h.size(); i++){
h[i] = lower_bound(l.begin(), l.end(), h[i]) - l.begin();
}
}
vector<vector<ll>> dp;
ll get_cost(int v, int min_value){
if (min_value == g.size()) return 1e18;
ll result = (min_value == h[v] ? 0 : c[v]);
for (int u: g[v]){
result += get_cost(u, min_value);
}
return result = min(result, get_cost(v, min_value+1));
}
signed main(){
cin.tie(0)->sync_with_stdio(0);
get_input();
cout << get_cost(0, 0) << "\n";
}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... | ||||
