Submission #621111

#TimeUsernameProblemLanguageResultExecution timeMemory
621111someoneJob Scheduling (IOI19_job)C++14
24 / 100
163 ms19712 KiB
#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 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...