#include "job.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct Temple {
ll i, cost, time;
bool operator <(const Temple& other) const {
return time * other.cost - other.time * cost > 0;
}
};
ll scheduling_cost (vector<int> p, vector<int> u, vector<int> d) {
int n = p.size();
vector<int> fils[n];
for(int i = 1; i < n; i++)
fils[p[i]].push_back(i);
ll time = 0, totCost = 0;
priority_queue<Temple> pq;
pq.push({0, u[0], d[0]});
for(int i = 0; i < n; i++) {
int id = pq.top().i;
pq.pop();
time += d[id];
totCost += time * u[id];
for(int j : fils[id])
pq.push({j, u[j], d[j]});
}
return totCost;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
19 ms |
4856 KB |
Output is correct |
6 |
Correct |
49 ms |
9524 KB |
Output is correct |
7 |
Correct |
61 ms |
14388 KB |
Output is correct |
8 |
Correct |
75 ms |
19028 KB |
Output is correct |
9 |
Correct |
84 ms |
19128 KB |
Output is correct |
10 |
Correct |
79 ms |
19024 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
78 ms |
19132 KB |
Output is correct |
13 |
Correct |
77 ms |
19112 KB |
Output is correct |
14 |
Correct |
81 ms |
19028 KB |
Output is correct |
15 |
Correct |
89 ms |
19128 KB |
Output is correct |
16 |
Correct |
80 ms |
19016 KB |
Output is correct |
17 |
Correct |
76 ms |
19252 KB |
Output is correct |
18 |
Correct |
84 ms |
19116 KB |
Output is correct |
19 |
Correct |
79 ms |
19132 KB |
Output is correct |
20 |
Correct |
79 ms |
19128 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
123 ms |
19128 KB |
Output is correct |
5 |
Correct |
134 ms |
19100 KB |
Output is correct |
6 |
Correct |
120 ms |
19128 KB |
Output is correct |
7 |
Correct |
160 ms |
19048 KB |
Output is correct |
8 |
Correct |
163 ms |
19088 KB |
Output is correct |
9 |
Correct |
123 ms |
19188 KB |
Output is correct |
10 |
Correct |
141 ms |
19104 KB |
Output is correct |
11 |
Correct |
132 ms |
19064 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
7 ms |
1604 KB |
Output is correct |
6 |
Correct |
153 ms |
19644 KB |
Output is correct |
7 |
Correct |
153 ms |
19612 KB |
Output is correct |
8 |
Correct |
148 ms |
19712 KB |
Output is correct |
9 |
Correct |
127 ms |
19616 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
444 KB |
Output is correct |
12 |
Correct |
5 ms |
1348 KB |
Output is correct |
13 |
Correct |
6 ms |
1452 KB |
Output is correct |
14 |
Correct |
119 ms |
19620 KB |
Output is correct |
15 |
Correct |
134 ms |
19636 KB |
Output is correct |
16 |
Correct |
129 ms |
19600 KB |
Output is correct |
17 |
Correct |
135 ms |
19608 KB |
Output is correct |
18 |
Correct |
143 ms |
19620 KB |
Output is correct |
19 |
Correct |
122 ms |
19612 KB |
Output is correct |
20 |
Correct |
138 ms |
19620 KB |
Output is correct |
21 |
Correct |
159 ms |
19608 KB |
Output is correct |
22 |
Correct |
126 ms |
19608 KB |
Output is correct |
23 |
Correct |
151 ms |
19624 KB |
Output is correct |
24 |
Correct |
127 ms |
19608 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
80 ms |
19048 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
304 KB |
Output is correct |
2 |
Incorrect |
1 ms |
300 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
19 ms |
4856 KB |
Output is correct |
6 |
Correct |
49 ms |
9524 KB |
Output is correct |
7 |
Correct |
61 ms |
14388 KB |
Output is correct |
8 |
Correct |
75 ms |
19028 KB |
Output is correct |
9 |
Correct |
84 ms |
19128 KB |
Output is correct |
10 |
Correct |
79 ms |
19024 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
78 ms |
19132 KB |
Output is correct |
13 |
Correct |
77 ms |
19112 KB |
Output is correct |
14 |
Correct |
81 ms |
19028 KB |
Output is correct |
15 |
Correct |
89 ms |
19128 KB |
Output is correct |
16 |
Correct |
80 ms |
19016 KB |
Output is correct |
17 |
Correct |
76 ms |
19252 KB |
Output is correct |
18 |
Correct |
84 ms |
19116 KB |
Output is correct |
19 |
Correct |
79 ms |
19132 KB |
Output is correct |
20 |
Correct |
79 ms |
19128 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
308 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
123 ms |
19128 KB |
Output is correct |
25 |
Correct |
134 ms |
19100 KB |
Output is correct |
26 |
Correct |
120 ms |
19128 KB |
Output is correct |
27 |
Correct |
160 ms |
19048 KB |
Output is correct |
28 |
Correct |
163 ms |
19088 KB |
Output is correct |
29 |
Correct |
123 ms |
19188 KB |
Output is correct |
30 |
Correct |
141 ms |
19104 KB |
Output is correct |
31 |
Correct |
132 ms |
19064 KB |
Output is correct |
32 |
Correct |
0 ms |
212 KB |
Output is correct |
33 |
Correct |
0 ms |
212 KB |
Output is correct |
34 |
Correct |
1 ms |
212 KB |
Output is correct |
35 |
Correct |
1 ms |
340 KB |
Output is correct |
36 |
Correct |
7 ms |
1604 KB |
Output is correct |
37 |
Correct |
153 ms |
19644 KB |
Output is correct |
38 |
Correct |
153 ms |
19612 KB |
Output is correct |
39 |
Correct |
148 ms |
19712 KB |
Output is correct |
40 |
Correct |
127 ms |
19616 KB |
Output is correct |
41 |
Correct |
0 ms |
212 KB |
Output is correct |
42 |
Correct |
1 ms |
444 KB |
Output is correct |
43 |
Correct |
5 ms |
1348 KB |
Output is correct |
44 |
Correct |
6 ms |
1452 KB |
Output is correct |
45 |
Correct |
119 ms |
19620 KB |
Output is correct |
46 |
Correct |
134 ms |
19636 KB |
Output is correct |
47 |
Correct |
129 ms |
19600 KB |
Output is correct |
48 |
Correct |
135 ms |
19608 KB |
Output is correct |
49 |
Correct |
143 ms |
19620 KB |
Output is correct |
50 |
Correct |
122 ms |
19612 KB |
Output is correct |
51 |
Correct |
138 ms |
19620 KB |
Output is correct |
52 |
Correct |
159 ms |
19608 KB |
Output is correct |
53 |
Correct |
126 ms |
19608 KB |
Output is correct |
54 |
Correct |
151 ms |
19624 KB |
Output is correct |
55 |
Correct |
127 ms |
19608 KB |
Output is correct |
56 |
Correct |
0 ms |
212 KB |
Output is correct |
57 |
Incorrect |
80 ms |
19048 KB |
Output isn't correct |
58 |
Halted |
0 ms |
0 KB |
- |