#include "job.h"
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
int64 scheduling_cost(vector<int> p, vector<int> u, vector<int> d) {
int N = p.size();
vector<int> alive(N, 1);
int64 tim = 0, ans = 0;
for (int _round = 0; _round < N; ++_round) {
int id = -1;
for (int i = 0; i < N; ++i) {
if (alive[i] and (id == -1 or d[i] * u[id] < d[id] * u[i])) id = i;
}
if (p[id] == -1) {
tim += d[id];
ans += u[id] * tim;
}
else {
ans -= d[id] * u[p[id]];
d[p[id]] += d[id];
u[p[id]] += u[id];
}
alive[id] = 0;
for (int i = 0; i < N; ++i) {
if (p[i] == id) p[i] = p[id];
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Execution timed out |
3086 ms |
7632 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
4 ms |
756 KB |
Output is correct |
5 |
Incorrect |
305 ms |
792 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Execution timed out |
3073 ms |
9008 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |