이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |