#include "job.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 1;
int n;
vector<int> adj[N];
priority_queue<pair<double,int> > q;
long long now,ans;
long long scheduling_cost(vector<int> p,vector<int> u,vector<int> d)
{
n = p.size();
for(int i = 0;i < n;i++) if(i) adj[p[i]].push_back(i);
q.push({(double)u[0]/(double)d[0],0});
while(!q.empty())
{
int x = q.top().second;
q.pop();
now+=d[x];
ans+=now*u[x];
for(int v : adj[x]) q.push({(double)u[v]/(double)d[v],v});
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4992 KB |
Output is correct |
2 |
Correct |
7 ms |
4992 KB |
Output is correct |
3 |
Correct |
3 ms |
4992 KB |
Output is correct |
4 |
Correct |
5 ms |
5120 KB |
Output is correct |
5 |
Correct |
27 ms |
8448 KB |
Output is correct |
6 |
Correct |
50 ms |
12024 KB |
Output is correct |
7 |
Correct |
75 ms |
15608 KB |
Output is correct |
8 |
Correct |
105 ms |
19192 KB |
Output is correct |
9 |
Correct |
103 ms |
19192 KB |
Output is correct |
10 |
Correct |
102 ms |
19192 KB |
Output is correct |
11 |
Correct |
3 ms |
4992 KB |
Output is correct |
12 |
Correct |
96 ms |
19160 KB |
Output is correct |
13 |
Correct |
104 ms |
19192 KB |
Output is correct |
14 |
Correct |
96 ms |
19192 KB |
Output is correct |
15 |
Correct |
151 ms |
19192 KB |
Output is correct |
16 |
Correct |
100 ms |
19192 KB |
Output is correct |
17 |
Correct |
134 ms |
19196 KB |
Output is correct |
18 |
Correct |
101 ms |
19192 KB |
Output is correct |
19 |
Correct |
96 ms |
19192 KB |
Output is correct |
20 |
Correct |
103 ms |
19192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4992 KB |
Output is correct |
2 |
Correct |
5 ms |
4992 KB |
Output is correct |
3 |
Correct |
4 ms |
4992 KB |
Output is correct |
4 |
Correct |
143 ms |
16488 KB |
Output is correct |
5 |
Correct |
137 ms |
16488 KB |
Output is correct |
6 |
Correct |
176 ms |
16588 KB |
Output is correct |
7 |
Correct |
135 ms |
16488 KB |
Output is correct |
8 |
Correct |
228 ms |
16480 KB |
Output is correct |
9 |
Correct |
139 ms |
16480 KB |
Output is correct |
10 |
Correct |
141 ms |
16488 KB |
Output is correct |
11 |
Correct |
142 ms |
16484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4992 KB |
Output is correct |
2 |
Correct |
4 ms |
4992 KB |
Output is correct |
3 |
Correct |
4 ms |
4992 KB |
Output is correct |
4 |
Correct |
4 ms |
5120 KB |
Output is correct |
5 |
Correct |
11 ms |
5760 KB |
Output is correct |
6 |
Correct |
156 ms |
17104 KB |
Output is correct |
7 |
Correct |
250 ms |
17104 KB |
Output is correct |
8 |
Correct |
146 ms |
17128 KB |
Output is correct |
9 |
Correct |
161 ms |
17128 KB |
Output is correct |
10 |
Correct |
4 ms |
4992 KB |
Output is correct |
11 |
Correct |
5 ms |
5120 KB |
Output is correct |
12 |
Correct |
8 ms |
5760 KB |
Output is correct |
13 |
Correct |
10 ms |
5760 KB |
Output is correct |
14 |
Correct |
144 ms |
17004 KB |
Output is correct |
15 |
Correct |
143 ms |
17128 KB |
Output is correct |
16 |
Correct |
146 ms |
17128 KB |
Output is correct |
17 |
Correct |
151 ms |
17128 KB |
Output is correct |
18 |
Correct |
142 ms |
17184 KB |
Output is correct |
19 |
Correct |
143 ms |
17128 KB |
Output is correct |
20 |
Correct |
147 ms |
17128 KB |
Output is correct |
21 |
Correct |
153 ms |
17128 KB |
Output is correct |
22 |
Correct |
143 ms |
17128 KB |
Output is correct |
23 |
Correct |
141 ms |
17128 KB |
Output is correct |
24 |
Correct |
151 ms |
17144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4992 KB |
Output is correct |
2 |
Incorrect |
98 ms |
19192 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
4992 KB |
Output is correct |
2 |
Incorrect |
4 ms |
4992 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4992 KB |
Output is correct |
2 |
Correct |
7 ms |
4992 KB |
Output is correct |
3 |
Correct |
3 ms |
4992 KB |
Output is correct |
4 |
Correct |
5 ms |
5120 KB |
Output is correct |
5 |
Correct |
27 ms |
8448 KB |
Output is correct |
6 |
Correct |
50 ms |
12024 KB |
Output is correct |
7 |
Correct |
75 ms |
15608 KB |
Output is correct |
8 |
Correct |
105 ms |
19192 KB |
Output is correct |
9 |
Correct |
103 ms |
19192 KB |
Output is correct |
10 |
Correct |
102 ms |
19192 KB |
Output is correct |
11 |
Correct |
3 ms |
4992 KB |
Output is correct |
12 |
Correct |
96 ms |
19160 KB |
Output is correct |
13 |
Correct |
104 ms |
19192 KB |
Output is correct |
14 |
Correct |
96 ms |
19192 KB |
Output is correct |
15 |
Correct |
151 ms |
19192 KB |
Output is correct |
16 |
Correct |
100 ms |
19192 KB |
Output is correct |
17 |
Correct |
134 ms |
19196 KB |
Output is correct |
18 |
Correct |
101 ms |
19192 KB |
Output is correct |
19 |
Correct |
96 ms |
19192 KB |
Output is correct |
20 |
Correct |
103 ms |
19192 KB |
Output is correct |
21 |
Correct |
4 ms |
4992 KB |
Output is correct |
22 |
Correct |
5 ms |
4992 KB |
Output is correct |
23 |
Correct |
4 ms |
4992 KB |
Output is correct |
24 |
Correct |
143 ms |
16488 KB |
Output is correct |
25 |
Correct |
137 ms |
16488 KB |
Output is correct |
26 |
Correct |
176 ms |
16588 KB |
Output is correct |
27 |
Correct |
135 ms |
16488 KB |
Output is correct |
28 |
Correct |
228 ms |
16480 KB |
Output is correct |
29 |
Correct |
139 ms |
16480 KB |
Output is correct |
30 |
Correct |
141 ms |
16488 KB |
Output is correct |
31 |
Correct |
142 ms |
16484 KB |
Output is correct |
32 |
Correct |
4 ms |
4992 KB |
Output is correct |
33 |
Correct |
4 ms |
4992 KB |
Output is correct |
34 |
Correct |
4 ms |
4992 KB |
Output is correct |
35 |
Correct |
4 ms |
5120 KB |
Output is correct |
36 |
Correct |
11 ms |
5760 KB |
Output is correct |
37 |
Correct |
156 ms |
17104 KB |
Output is correct |
38 |
Correct |
250 ms |
17104 KB |
Output is correct |
39 |
Correct |
146 ms |
17128 KB |
Output is correct |
40 |
Correct |
161 ms |
17128 KB |
Output is correct |
41 |
Correct |
4 ms |
4992 KB |
Output is correct |
42 |
Correct |
5 ms |
5120 KB |
Output is correct |
43 |
Correct |
8 ms |
5760 KB |
Output is correct |
44 |
Correct |
10 ms |
5760 KB |
Output is correct |
45 |
Correct |
144 ms |
17004 KB |
Output is correct |
46 |
Correct |
143 ms |
17128 KB |
Output is correct |
47 |
Correct |
146 ms |
17128 KB |
Output is correct |
48 |
Correct |
151 ms |
17128 KB |
Output is correct |
49 |
Correct |
142 ms |
17184 KB |
Output is correct |
50 |
Correct |
143 ms |
17128 KB |
Output is correct |
51 |
Correct |
147 ms |
17128 KB |
Output is correct |
52 |
Correct |
153 ms |
17128 KB |
Output is correct |
53 |
Correct |
143 ms |
17128 KB |
Output is correct |
54 |
Correct |
141 ms |
17128 KB |
Output is correct |
55 |
Correct |
151 ms |
17144 KB |
Output is correct |
56 |
Correct |
4 ms |
4992 KB |
Output is correct |
57 |
Incorrect |
98 ms |
19192 KB |
Output isn't correct |
58 |
Halted |
0 ms |
0 KB |
- |