#include "job.h"
#include <bits/stdc++.h>
using namespace std;
#define maxn 200100
#define loop(i, a, b ) for(int i=a;i<b;i++)
typedef long long ll;
struct temp{
ll a, t, sa;vector<ll> chs;
bool operator<(const temp &dr) const {
return sa* dr.t<dr.sa* t;
}
};
temp ts[maxn];
ll scheduling_cost(vector<int> p, vector<int> a, vector<int> t) {
ll n=p.size();
loop(i,0, n) ts[i].a=a[i], ts[i].t=t[i], ts[i].sa=ts[i].a;
loop(i, 0, n) if(p[i]!=-1) ts[p[i]].sa+=ts[i].sa, ts[p[i]].chs.push_back(i);
priority_queue<temp> pq;pq.push(ts[0]);
ll ct=0, ans=0;
while(pq.size()){
auto v=pq.top();pq.pop();
ct+=v.t;
ans+=ct * v.a;
for(auto&& i: v.chs) pq.push(ts[i]);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
9720 KB |
Output is correct |
2 |
Correct |
10 ms |
9720 KB |
Output is correct |
3 |
Correct |
10 ms |
9720 KB |
Output is correct |
4 |
Correct |
10 ms |
9720 KB |
Output is correct |
5 |
Correct |
38 ms |
12508 KB |
Output is correct |
6 |
Correct |
65 ms |
15224 KB |
Output is correct |
7 |
Correct |
94 ms |
17916 KB |
Output is correct |
8 |
Correct |
121 ms |
20728 KB |
Output is correct |
9 |
Correct |
121 ms |
20728 KB |
Output is correct |
10 |
Correct |
122 ms |
20728 KB |
Output is correct |
11 |
Correct |
9 ms |
9720 KB |
Output is correct |
12 |
Correct |
122 ms |
20676 KB |
Output is correct |
13 |
Correct |
121 ms |
20816 KB |
Output is correct |
14 |
Correct |
122 ms |
20728 KB |
Output is correct |
15 |
Correct |
121 ms |
20728 KB |
Output is correct |
16 |
Correct |
122 ms |
20728 KB |
Output is correct |
17 |
Correct |
127 ms |
20684 KB |
Output is correct |
18 |
Correct |
130 ms |
20700 KB |
Output is correct |
19 |
Correct |
122 ms |
20696 KB |
Output is correct |
20 |
Correct |
121 ms |
20828 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
9692 KB |
Output is correct |
2 |
Correct |
10 ms |
9720 KB |
Output is correct |
3 |
Correct |
10 ms |
9720 KB |
Output is correct |
4 |
Correct |
186 ms |
30080 KB |
Output is correct |
5 |
Correct |
213 ms |
30012 KB |
Output is correct |
6 |
Correct |
217 ms |
29992 KB |
Output is correct |
7 |
Correct |
207 ms |
30016 KB |
Output is correct |
8 |
Correct |
187 ms |
30016 KB |
Output is correct |
9 |
Correct |
190 ms |
30016 KB |
Output is correct |
10 |
Correct |
191 ms |
29992 KB |
Output is correct |
11 |
Correct |
197 ms |
30000 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
9720 KB |
Output is correct |
2 |
Correct |
10 ms |
9720 KB |
Output is correct |
3 |
Correct |
10 ms |
9720 KB |
Output is correct |
4 |
Correct |
10 ms |
9976 KB |
Output is correct |
5 |
Correct |
18 ms |
11044 KB |
Output is correct |
6 |
Correct |
199 ms |
29964 KB |
Output is correct |
7 |
Correct |
196 ms |
30056 KB |
Output is correct |
8 |
Correct |
189 ms |
29992 KB |
Output is correct |
9 |
Correct |
192 ms |
30020 KB |
Output is correct |
10 |
Correct |
10 ms |
9720 KB |
Output is correct |
11 |
Correct |
11 ms |
9976 KB |
Output is correct |
12 |
Correct |
16 ms |
11044 KB |
Output is correct |
13 |
Correct |
17 ms |
11044 KB |
Output is correct |
14 |
Correct |
202 ms |
29988 KB |
Output is correct |
15 |
Correct |
190 ms |
29996 KB |
Output is correct |
16 |
Correct |
205 ms |
30144 KB |
Output is correct |
17 |
Correct |
207 ms |
30016 KB |
Output is correct |
18 |
Correct |
205 ms |
30020 KB |
Output is correct |
19 |
Correct |
200 ms |
30004 KB |
Output is correct |
20 |
Correct |
197 ms |
30056 KB |
Output is correct |
21 |
Correct |
201 ms |
29988 KB |
Output is correct |
22 |
Correct |
219 ms |
30060 KB |
Output is correct |
23 |
Correct |
202 ms |
30028 KB |
Output is correct |
24 |
Correct |
202 ms |
29976 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
9720 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
9720 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
9720 KB |
Output is correct |
2 |
Correct |
10 ms |
9720 KB |
Output is correct |
3 |
Correct |
10 ms |
9720 KB |
Output is correct |
4 |
Correct |
10 ms |
9720 KB |
Output is correct |
5 |
Correct |
38 ms |
12508 KB |
Output is correct |
6 |
Correct |
65 ms |
15224 KB |
Output is correct |
7 |
Correct |
94 ms |
17916 KB |
Output is correct |
8 |
Correct |
121 ms |
20728 KB |
Output is correct |
9 |
Correct |
121 ms |
20728 KB |
Output is correct |
10 |
Correct |
122 ms |
20728 KB |
Output is correct |
11 |
Correct |
9 ms |
9720 KB |
Output is correct |
12 |
Correct |
122 ms |
20676 KB |
Output is correct |
13 |
Correct |
121 ms |
20816 KB |
Output is correct |
14 |
Correct |
122 ms |
20728 KB |
Output is correct |
15 |
Correct |
121 ms |
20728 KB |
Output is correct |
16 |
Correct |
122 ms |
20728 KB |
Output is correct |
17 |
Correct |
127 ms |
20684 KB |
Output is correct |
18 |
Correct |
130 ms |
20700 KB |
Output is correct |
19 |
Correct |
122 ms |
20696 KB |
Output is correct |
20 |
Correct |
121 ms |
20828 KB |
Output is correct |
21 |
Correct |
9 ms |
9692 KB |
Output is correct |
22 |
Correct |
10 ms |
9720 KB |
Output is correct |
23 |
Correct |
10 ms |
9720 KB |
Output is correct |
24 |
Correct |
186 ms |
30080 KB |
Output is correct |
25 |
Correct |
213 ms |
30012 KB |
Output is correct |
26 |
Correct |
217 ms |
29992 KB |
Output is correct |
27 |
Correct |
207 ms |
30016 KB |
Output is correct |
28 |
Correct |
187 ms |
30016 KB |
Output is correct |
29 |
Correct |
190 ms |
30016 KB |
Output is correct |
30 |
Correct |
191 ms |
29992 KB |
Output is correct |
31 |
Correct |
197 ms |
30000 KB |
Output is correct |
32 |
Correct |
10 ms |
9720 KB |
Output is correct |
33 |
Correct |
10 ms |
9720 KB |
Output is correct |
34 |
Correct |
10 ms |
9720 KB |
Output is correct |
35 |
Correct |
10 ms |
9976 KB |
Output is correct |
36 |
Correct |
18 ms |
11044 KB |
Output is correct |
37 |
Correct |
199 ms |
29964 KB |
Output is correct |
38 |
Correct |
196 ms |
30056 KB |
Output is correct |
39 |
Correct |
189 ms |
29992 KB |
Output is correct |
40 |
Correct |
192 ms |
30020 KB |
Output is correct |
41 |
Correct |
10 ms |
9720 KB |
Output is correct |
42 |
Correct |
11 ms |
9976 KB |
Output is correct |
43 |
Correct |
16 ms |
11044 KB |
Output is correct |
44 |
Correct |
17 ms |
11044 KB |
Output is correct |
45 |
Correct |
202 ms |
29988 KB |
Output is correct |
46 |
Correct |
190 ms |
29996 KB |
Output is correct |
47 |
Correct |
205 ms |
30144 KB |
Output is correct |
48 |
Correct |
207 ms |
30016 KB |
Output is correct |
49 |
Correct |
205 ms |
30020 KB |
Output is correct |
50 |
Correct |
200 ms |
30004 KB |
Output is correct |
51 |
Correct |
197 ms |
30056 KB |
Output is correct |
52 |
Correct |
201 ms |
29988 KB |
Output is correct |
53 |
Correct |
219 ms |
30060 KB |
Output is correct |
54 |
Correct |
202 ms |
30028 KB |
Output is correct |
55 |
Correct |
202 ms |
29976 KB |
Output is correct |
56 |
Incorrect |
10 ms |
9720 KB |
Output isn't correct |
57 |
Halted |
0 ms |
0 KB |
- |