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 "job.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct Temple {
ll i, cost, time;
bool operator <(const Temple& other) const {
return time * other.cost - other.time * cost > 0;
}
};
ll scheduling_cost (vector<int> p, vector<int> u, vector<int> d) {
int n = p.size();
vector<int> fils[n];
for(int i = 1; i < n; i++)
fils[p[i]].push_back(i);
ll time = 0, totCost = 0;
priority_queue<Temple> pq;
pq.push({0, u[0], d[0]});
for(int i = 0; i < n; i++) {
int id = pq.top().i;
pq.pop();
time += d[id];
totCost += time * u[id];
for(int j : fils[id])
pq.push({j, u[j], d[j]});
}
return totCost;
}
# | 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... |