| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 314836 | blue | Job Scheduling (IOI19_job) | C++17 | 0 ms | 0 KiB |
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 <algorithm>
using namespace std;
struct job
{
int u;
int d;
}
bool operator < (job A, job B)
{
return A.d*B.u < B.d*A.u;
}
long long scheduling_cost(vector<int> p, vector<int> u, vector<int> d) {
long long res = 0;
int n = p.size();
res += u[0] * d[0];
job J[n-1];
for(int i = 1; i < n; i++) J[i-1] = job{u[i], d[i]};
sort(J, J+n-1);
long long t = 0;
for(int i = 0; i < n; i++)
{
t += J[i].d;
res += t * J[i].u;
}
return res;
}
