#include "job.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//24 3
long long scheduling_cost(vector<int> p, vector<int> u, vector<int> d) {
int n = p.size();
ll t = 0;
for (int i : d)
t += i;
int out[n];
memset(out, 0, sizeof out);
for (int i = 0; i < n; i++)
if (p[i] != -1)
out[p[i]]++;
ll ans = 0;
priority_queue<pair<int, int>> cur;
for (int i = 0; i < n; i++)
if (out[i] == 0)
cur.push({-u[i], i});
while (!cur.empty()) {
int ind = cur.top().second;
//cout << ind << " " << t << endl;
cur.pop();
ans += u[ind] * t;
t -= d[ind];
out[p[ind]]--;
if (out[p[ind]] == 0)
cur.push({-u[p[ind]], p[ind]});
}
return ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
24 ms |
1656 KB |
Output is correct |
6 |
Correct |
44 ms |
3064 KB |
Output is correct |
7 |
Correct |
67 ms |
4484 KB |
Output is correct |
8 |
Correct |
90 ms |
5752 KB |
Output is correct |
9 |
Correct |
90 ms |
5956 KB |
Output is correct |
10 |
Correct |
91 ms |
5752 KB |
Output is correct |
11 |
Correct |
3 ms |
256 KB |
Output is correct |
12 |
Correct |
94 ms |
5912 KB |
Output is correct |
13 |
Correct |
90 ms |
5816 KB |
Output is correct |
14 |
Correct |
89 ms |
5780 KB |
Output is correct |
15 |
Correct |
86 ms |
5852 KB |
Output is correct |
16 |
Correct |
85 ms |
5852 KB |
Output is correct |
17 |
Correct |
86 ms |
5816 KB |
Output is correct |
18 |
Correct |
88 ms |
5852 KB |
Output is correct |
19 |
Correct |
85 ms |
5880 KB |
Output is correct |
20 |
Correct |
86 ms |
5880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
117 ms |
7944 KB |
Output is correct |
5 |
Correct |
130 ms |
8000 KB |
Output is correct |
6 |
Correct |
139 ms |
8172 KB |
Output is correct |
7 |
Correct |
117 ms |
8044 KB |
Output is correct |
8 |
Correct |
119 ms |
8044 KB |
Output is correct |
9 |
Correct |
117 ms |
8044 KB |
Output is correct |
10 |
Correct |
117 ms |
8048 KB |
Output is correct |
11 |
Correct |
126 ms |
7940 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
24 ms |
1656 KB |
Output is correct |
6 |
Correct |
44 ms |
3064 KB |
Output is correct |
7 |
Correct |
67 ms |
4484 KB |
Output is correct |
8 |
Correct |
90 ms |
5752 KB |
Output is correct |
9 |
Correct |
90 ms |
5956 KB |
Output is correct |
10 |
Correct |
91 ms |
5752 KB |
Output is correct |
11 |
Correct |
3 ms |
256 KB |
Output is correct |
12 |
Correct |
94 ms |
5912 KB |
Output is correct |
13 |
Correct |
90 ms |
5816 KB |
Output is correct |
14 |
Correct |
89 ms |
5780 KB |
Output is correct |
15 |
Correct |
86 ms |
5852 KB |
Output is correct |
16 |
Correct |
85 ms |
5852 KB |
Output is correct |
17 |
Correct |
86 ms |
5816 KB |
Output is correct |
18 |
Correct |
88 ms |
5852 KB |
Output is correct |
19 |
Correct |
85 ms |
5880 KB |
Output is correct |
20 |
Correct |
86 ms |
5880 KB |
Output is correct |
21 |
Correct |
2 ms |
256 KB |
Output is correct |
22 |
Correct |
2 ms |
256 KB |
Output is correct |
23 |
Correct |
2 ms |
256 KB |
Output is correct |
24 |
Correct |
117 ms |
7944 KB |
Output is correct |
25 |
Correct |
130 ms |
8000 KB |
Output is correct |
26 |
Correct |
139 ms |
8172 KB |
Output is correct |
27 |
Correct |
117 ms |
8044 KB |
Output is correct |
28 |
Correct |
119 ms |
8044 KB |
Output is correct |
29 |
Correct |
117 ms |
8044 KB |
Output is correct |
30 |
Correct |
117 ms |
8048 KB |
Output is correct |
31 |
Correct |
126 ms |
7940 KB |
Output is correct |
32 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
33 |
Halted |
0 ms |
0 KB |
- |