#include "job.h"
#include <bits/stdc++.h>
using namespace std;
struct DATA{
int timetaken,value,i;
DATA(int u,int d,int ind){
value=u,timetaken=d,i=ind;
}
DATA(){
timetaken=1e9;
value=1;
}
friend bool operator<(const DATA &a,const DATA&b){
return a.timetaken*b.value<
b.timetaken*a.value;
}
};
long long scheduling_cost(std::vector<int> p, std::vector<int> u, std::vector<int> d) {
int N=p.size();
vector<int>ord,deg(N);
priority_queue<DATA>pq;
for(int i=1;i<N;i++)
deg[p[i]]++;
for(int i=0;i<N;i++) if(!deg[i])
pq.push(DATA(u[i],d[i],i));
while(pq.size()){
int K=pq.top().i;
pq.pop();
if(!--deg[p[K]])
pq.push(DATA(u[p[K]],d[p[K]],p[K]));
ord.push_back(K);
}
reverse(ord.begin(),ord.end());
long long curtime=0,ans=0;
for(auto i:ord)
ans+=u[i]*(curtime+=d[i]);
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
348 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
348 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |