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 <vector>
#include <queue>
using namespace std;
vector < int > Next[200005];
struct A
{
long long u,t,where;
}all[200005];
bool operator > (A a,A b)
{
return a.u*b.t<b.u*a.t;
}
priority_queue < A , vector < A > , greater < A > > how;
long long scheduling_cost(std::vector<int> p, std::vector<int> u, std::vector<int> d)
{
long long N=(long long) u.size(),ans=0,t=0,i;
for(i=0;i<N;i++)
{
all[i].u=u[i];
all[i].t=d[i];
all[i].where=i;
}
for(i=1;i<N;i++) Next[p[i]].push_back(i);
how.push(all[0]);
while(!how.empty())
{
A a=how.top();
how.pop();
t+=a.t;
ans+=t*a.u;
for(auto i:Next[a.where]) how.push(all[i]);
}
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... |