Submission #314853

#TimeUsernameProblemLanguageResultExecution timeMemory
314853blueJob Scheduling (IOI19_job)C++17
24 / 100
314 ms36572 KiB
#include "job.h" #include <vector> #include <algorithm> #include <set> using namespace std; struct job { long long u; long long d; int i; vector<int> children; }; bool operator < (job A, job B) { if(A.u*B.d == B.u*A.d) return A.i < B.i; return A.u*B.d > B.u*A.d; } long long scheduling_cost(vector<int> p, vector<int> u, vector<int> d) { long long res = 0; int n = p.size(); job J[n]; vector<int> v; for(int i = 0; i < n; i++) { J[i] = job{u[i], d[i], i, v}; if(i > 0) J[p[i]].children.push_back(i); } long long t = 0; set<job> S; S.insert(J[0]); job j; while(!S.empty()) { j = *S.begin(); S.erase(S.begin()); for(int k: j.children) S.insert(J[k]); t += j.d; res += t * j.u; } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...