이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "job.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//24 3
long long scheduling_cost(vector<int> p, vector<int> u, vector<int> d) {
int n = p.size();
ll t = 0;
for (int i : d)
t += i;
int out[n];
memset(out, 0, sizeof out);
for (int i = 0; i < n; i++)
if (p[i] != -1)
out[p[i]]++;
ll ans = 0;
priority_queue<pair<long double, int>> cur;
for (int i = 0; i < n; i++)
if (out[i] == 0)
cur.push({-(long double) u[i] / (long double) d[i], i});
while (!cur.empty()) {
int ind = cur.top().second;
//cout << ind << " " << t << endl;
cur.pop();
ans += u[ind] * t;
t -= d[ind];
out[p[ind]]--;
if (out[p[ind]] == 0)
cur.push({-(long double) u[p[ind]] / (long double) d[p[ind]], p[ind]});
}
return ans;
return 0;
}
# | 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... |