#include "job.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 1;
int n;
vector<int> adj[N],rev;
bool visited[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++) q.push({-(double)d[i]/(double)u[i],i});
while(!q.empty())
{
int x = q.top().second;
q.pop();
rev.clear();
while(x!=-1 and !visited[x]) rev.push_back(x),x = p[x];
reverse(rev.begin(),rev.end());
for(int x : rev) now+=d[x],ans+=now*u[x],visited[x] = true;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4992 KB |
Output is correct |
2 |
Correct |
3 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 |
38 ms |
7408 KB |
Output is correct |
6 |
Correct |
71 ms |
9580 KB |
Output is correct |
7 |
Correct |
115 ms |
12776 KB |
Output is correct |
8 |
Correct |
146 ms |
14564 KB |
Output is correct |
9 |
Correct |
145 ms |
14192 KB |
Output is correct |
10 |
Correct |
145 ms |
13928 KB |
Output is correct |
11 |
Correct |
4 ms |
4992 KB |
Output is correct |
12 |
Correct |
143 ms |
14044 KB |
Output is correct |
13 |
Correct |
158 ms |
15100 KB |
Output is correct |
14 |
Correct |
137 ms |
13928 KB |
Output is correct |
15 |
Correct |
136 ms |
14872 KB |
Output is correct |
16 |
Correct |
136 ms |
13928 KB |
Output is correct |
17 |
Correct |
141 ms |
13928 KB |
Output is correct |
18 |
Correct |
140 ms |
14056 KB |
Output is correct |
19 |
Correct |
130 ms |
14820 KB |
Output is correct |
20 |
Correct |
135 ms |
14040 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 |
140 ms |
14036 KB |
Output is correct |
5 |
Correct |
154 ms |
13928 KB |
Output is correct |
6 |
Correct |
141 ms |
13928 KB |
Output is correct |
7 |
Correct |
148 ms |
13928 KB |
Output is correct |
8 |
Correct |
145 ms |
13928 KB |
Output is correct |
9 |
Correct |
177 ms |
13932 KB |
Output is correct |
10 |
Correct |
149 ms |
13928 KB |
Output is correct |
11 |
Correct |
148 ms |
13928 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 |
10 ms |
5632 KB |
Output is correct |
6 |
Correct |
164 ms |
13936 KB |
Output is correct |
7 |
Correct |
149 ms |
13924 KB |
Output is correct |
8 |
Correct |
152 ms |
13928 KB |
Output is correct |
9 |
Correct |
142 ms |
13932 KB |
Output is correct |
10 |
Correct |
7 ms |
4992 KB |
Output is correct |
11 |
Correct |
5 ms |
5120 KB |
Output is correct |
12 |
Correct |
9 ms |
5632 KB |
Output is correct |
13 |
Correct |
10 ms |
5632 KB |
Output is correct |
14 |
Correct |
143 ms |
13928 KB |
Output is correct |
15 |
Correct |
156 ms |
13928 KB |
Output is correct |
16 |
Correct |
155 ms |
13924 KB |
Output is correct |
17 |
Correct |
176 ms |
13928 KB |
Output is correct |
18 |
Correct |
161 ms |
13908 KB |
Output is correct |
19 |
Correct |
150 ms |
14056 KB |
Output is correct |
20 |
Correct |
147 ms |
13928 KB |
Output is correct |
21 |
Correct |
150 ms |
13928 KB |
Output is correct |
22 |
Correct |
147 ms |
13928 KB |
Output is correct |
23 |
Correct |
152 ms |
13928 KB |
Output is correct |
24 |
Correct |
143 ms |
14056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
4992 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
4992 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4992 KB |
Output is correct |
2 |
Correct |
3 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 |
38 ms |
7408 KB |
Output is correct |
6 |
Correct |
71 ms |
9580 KB |
Output is correct |
7 |
Correct |
115 ms |
12776 KB |
Output is correct |
8 |
Correct |
146 ms |
14564 KB |
Output is correct |
9 |
Correct |
145 ms |
14192 KB |
Output is correct |
10 |
Correct |
145 ms |
13928 KB |
Output is correct |
11 |
Correct |
4 ms |
4992 KB |
Output is correct |
12 |
Correct |
143 ms |
14044 KB |
Output is correct |
13 |
Correct |
158 ms |
15100 KB |
Output is correct |
14 |
Correct |
137 ms |
13928 KB |
Output is correct |
15 |
Correct |
136 ms |
14872 KB |
Output is correct |
16 |
Correct |
136 ms |
13928 KB |
Output is correct |
17 |
Correct |
141 ms |
13928 KB |
Output is correct |
18 |
Correct |
140 ms |
14056 KB |
Output is correct |
19 |
Correct |
130 ms |
14820 KB |
Output is correct |
20 |
Correct |
135 ms |
14040 KB |
Output is correct |
21 |
Correct |
4 ms |
4992 KB |
Output is correct |
22 |
Correct |
4 ms |
4992 KB |
Output is correct |
23 |
Correct |
4 ms |
4992 KB |
Output is correct |
24 |
Correct |
140 ms |
14036 KB |
Output is correct |
25 |
Correct |
154 ms |
13928 KB |
Output is correct |
26 |
Correct |
141 ms |
13928 KB |
Output is correct |
27 |
Correct |
148 ms |
13928 KB |
Output is correct |
28 |
Correct |
145 ms |
13928 KB |
Output is correct |
29 |
Correct |
177 ms |
13932 KB |
Output is correct |
30 |
Correct |
149 ms |
13928 KB |
Output is correct |
31 |
Correct |
148 ms |
13928 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 |
10 ms |
5632 KB |
Output is correct |
37 |
Correct |
164 ms |
13936 KB |
Output is correct |
38 |
Correct |
149 ms |
13924 KB |
Output is correct |
39 |
Correct |
152 ms |
13928 KB |
Output is correct |
40 |
Correct |
142 ms |
13932 KB |
Output is correct |
41 |
Correct |
7 ms |
4992 KB |
Output is correct |
42 |
Correct |
5 ms |
5120 KB |
Output is correct |
43 |
Correct |
9 ms |
5632 KB |
Output is correct |
44 |
Correct |
10 ms |
5632 KB |
Output is correct |
45 |
Correct |
143 ms |
13928 KB |
Output is correct |
46 |
Correct |
156 ms |
13928 KB |
Output is correct |
47 |
Correct |
155 ms |
13924 KB |
Output is correct |
48 |
Correct |
176 ms |
13928 KB |
Output is correct |
49 |
Correct |
161 ms |
13908 KB |
Output is correct |
50 |
Correct |
150 ms |
14056 KB |
Output is correct |
51 |
Correct |
147 ms |
13928 KB |
Output is correct |
52 |
Correct |
150 ms |
13928 KB |
Output is correct |
53 |
Correct |
147 ms |
13928 KB |
Output is correct |
54 |
Correct |
152 ms |
13928 KB |
Output is correct |
55 |
Correct |
143 ms |
14056 KB |
Output is correct |
56 |
Incorrect |
4 ms |
4992 KB |
Output isn't correct |
57 |
Halted |
0 ms |
0 KB |
- |