#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)u[i]/(double)d[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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
5024 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 |
37 ms |
8056 KB |
Output is correct |
6 |
Correct |
76 ms |
11116 KB |
Output is correct |
7 |
Correct |
112 ms |
15208 KB |
Output is correct |
8 |
Correct |
160 ms |
17764 KB |
Output is correct |
9 |
Correct |
144 ms |
17236 KB |
Output is correct |
10 |
Correct |
147 ms |
17128 KB |
Output is correct |
11 |
Correct |
4 ms |
4992 KB |
Output is correct |
12 |
Correct |
162 ms |
17252 KB |
Output is correct |
13 |
Correct |
148 ms |
18024 KB |
Output is correct |
14 |
Correct |
153 ms |
17128 KB |
Output is correct |
15 |
Correct |
143 ms |
18020 KB |
Output is correct |
16 |
Correct |
135 ms |
17128 KB |
Output is correct |
17 |
Correct |
153 ms |
17128 KB |
Output is correct |
18 |
Correct |
151 ms |
17376 KB |
Output is correct |
19 |
Correct |
137 ms |
18016 KB |
Output is correct |
20 |
Correct |
128 ms |
17128 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
145 ms |
15720 KB |
Output is correct |
5 |
Correct |
164 ms |
15720 KB |
Output is correct |
6 |
Correct |
162 ms |
15720 KB |
Output is correct |
7 |
Correct |
168 ms |
15720 KB |
Output is correct |
8 |
Correct |
145 ms |
15720 KB |
Output is correct |
9 |
Correct |
173 ms |
15720 KB |
Output is correct |
10 |
Correct |
150 ms |
15720 KB |
Output is correct |
11 |
Correct |
171 ms |
15712 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4992 KB |
Output is correct |
2 |
Correct |
4 ms |
4992 KB |
Output is correct |
3 |
Correct |
5 ms |
4992 KB |
Output is correct |
4 |
Correct |
5 ms |
5120 KB |
Output is correct |
5 |
Correct |
13 ms |
5760 KB |
Output is correct |
6 |
Correct |
158 ms |
16360 KB |
Output is correct |
7 |
Correct |
159 ms |
16272 KB |
Output is correct |
8 |
Correct |
190 ms |
16228 KB |
Output is correct |
9 |
Correct |
155 ms |
16232 KB |
Output is correct |
10 |
Correct |
3 ms |
4992 KB |
Output is correct |
11 |
Correct |
5 ms |
5120 KB |
Output is correct |
12 |
Correct |
11 ms |
5760 KB |
Output is correct |
13 |
Correct |
10 ms |
5760 KB |
Output is correct |
14 |
Correct |
161 ms |
16264 KB |
Output is correct |
15 |
Correct |
162 ms |
16232 KB |
Output is correct |
16 |
Correct |
163 ms |
16232 KB |
Output is correct |
17 |
Correct |
159 ms |
16324 KB |
Output is correct |
18 |
Correct |
166 ms |
16224 KB |
Output is correct |
19 |
Correct |
150 ms |
16320 KB |
Output is correct |
20 |
Correct |
150 ms |
16232 KB |
Output is correct |
21 |
Correct |
198 ms |
16232 KB |
Output is correct |
22 |
Correct |
153 ms |
16232 KB |
Output is correct |
23 |
Correct |
145 ms |
16232 KB |
Output is correct |
24 |
Correct |
142 ms |
16232 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
4992 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
4992 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
5024 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 |
37 ms |
8056 KB |
Output is correct |
6 |
Correct |
76 ms |
11116 KB |
Output is correct |
7 |
Correct |
112 ms |
15208 KB |
Output is correct |
8 |
Correct |
160 ms |
17764 KB |
Output is correct |
9 |
Correct |
144 ms |
17236 KB |
Output is correct |
10 |
Correct |
147 ms |
17128 KB |
Output is correct |
11 |
Correct |
4 ms |
4992 KB |
Output is correct |
12 |
Correct |
162 ms |
17252 KB |
Output is correct |
13 |
Correct |
148 ms |
18024 KB |
Output is correct |
14 |
Correct |
153 ms |
17128 KB |
Output is correct |
15 |
Correct |
143 ms |
18020 KB |
Output is correct |
16 |
Correct |
135 ms |
17128 KB |
Output is correct |
17 |
Correct |
153 ms |
17128 KB |
Output is correct |
18 |
Correct |
151 ms |
17376 KB |
Output is correct |
19 |
Correct |
137 ms |
18016 KB |
Output is correct |
20 |
Correct |
128 ms |
17128 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 |
145 ms |
15720 KB |
Output is correct |
25 |
Correct |
164 ms |
15720 KB |
Output is correct |
26 |
Correct |
162 ms |
15720 KB |
Output is correct |
27 |
Correct |
168 ms |
15720 KB |
Output is correct |
28 |
Correct |
145 ms |
15720 KB |
Output is correct |
29 |
Correct |
173 ms |
15720 KB |
Output is correct |
30 |
Correct |
150 ms |
15720 KB |
Output is correct |
31 |
Correct |
171 ms |
15712 KB |
Output is correct |
32 |
Correct |
4 ms |
4992 KB |
Output is correct |
33 |
Correct |
4 ms |
4992 KB |
Output is correct |
34 |
Correct |
5 ms |
4992 KB |
Output is correct |
35 |
Correct |
5 ms |
5120 KB |
Output is correct |
36 |
Correct |
13 ms |
5760 KB |
Output is correct |
37 |
Correct |
158 ms |
16360 KB |
Output is correct |
38 |
Correct |
159 ms |
16272 KB |
Output is correct |
39 |
Correct |
190 ms |
16228 KB |
Output is correct |
40 |
Correct |
155 ms |
16232 KB |
Output is correct |
41 |
Correct |
3 ms |
4992 KB |
Output is correct |
42 |
Correct |
5 ms |
5120 KB |
Output is correct |
43 |
Correct |
11 ms |
5760 KB |
Output is correct |
44 |
Correct |
10 ms |
5760 KB |
Output is correct |
45 |
Correct |
161 ms |
16264 KB |
Output is correct |
46 |
Correct |
162 ms |
16232 KB |
Output is correct |
47 |
Correct |
163 ms |
16232 KB |
Output is correct |
48 |
Correct |
159 ms |
16324 KB |
Output is correct |
49 |
Correct |
166 ms |
16224 KB |
Output is correct |
50 |
Correct |
150 ms |
16320 KB |
Output is correct |
51 |
Correct |
150 ms |
16232 KB |
Output is correct |
52 |
Correct |
198 ms |
16232 KB |
Output is correct |
53 |
Correct |
153 ms |
16232 KB |
Output is correct |
54 |
Correct |
145 ms |
16232 KB |
Output is correct |
55 |
Correct |
142 ms |
16232 KB |
Output is correct |
56 |
Incorrect |
4 ms |
4992 KB |
Output isn't correct |
57 |
Halted |
0 ms |
0 KB |
- |