# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
251009 |
2020-07-19T22:38:58 Z |
cjoa |
Job Scheduling (IOI19_job) |
C++14 |
|
113 ms |
36472 KB |
#include "job.h"
#include <vector>
#include <algorithm>
//#include <iostream>
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long llong;
int N;
VVI tree;
VI D, U;
vector<llong> sumD, sumU;
void dfs(int x) {
sumD[x] = D[x];
sumU[x] = U[x];
for (int y : tree[x]) {
dfs(y);
sumD[x] += sumD[y];
sumU[x] += sumU[y];
}
}
llong dfs2(int x, llong T) {
T += D[x];
llong res = U[x] * T;
sort(tree[x].begin(), tree[x].end(),
[&] (int i, int j) -> bool {
return sumD[i] * sumU[j] < sumD[j] * sumU[i];
});
for (int y : tree[x]) {
res += dfs2(y, T);
T += sumD[y];
}
return res;
}
long long scheduling_cost(vector<int> p, vector<int> u, vector<int> d) {
N = p.size();
tree = VVI(N);
::D = d;
::U = u;
for (int i = 1; i < N; ++i)
tree[ p[i] ].push_back(i);
sumD.assign(N, 0);
sumU.assign(N, 0);
dfs(0);
// for (int x = 0; x < N; ++x)
// cerr << x << ": " << sumD[x] << ' ' << sumU[x] << endl;
llong res = dfs2(0, 0);
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
512 KB |
Output is correct |
5 |
Correct |
27 ms |
9336 KB |
Output is correct |
6 |
Correct |
54 ms |
18300 KB |
Output is correct |
7 |
Correct |
81 ms |
27256 KB |
Output is correct |
8 |
Correct |
112 ms |
36472 KB |
Output is correct |
9 |
Correct |
110 ms |
36344 KB |
Output is correct |
10 |
Correct |
106 ms |
36344 KB |
Output is correct |
11 |
Correct |
0 ms |
256 KB |
Output is correct |
12 |
Correct |
101 ms |
36344 KB |
Output is correct |
13 |
Correct |
105 ms |
36352 KB |
Output is correct |
14 |
Correct |
106 ms |
36344 KB |
Output is correct |
15 |
Correct |
108 ms |
36360 KB |
Output is correct |
16 |
Correct |
104 ms |
36344 KB |
Output is correct |
17 |
Correct |
104 ms |
36344 KB |
Output is correct |
18 |
Correct |
103 ms |
36344 KB |
Output is correct |
19 |
Correct |
113 ms |
36384 KB |
Output is correct |
20 |
Correct |
107 ms |
36472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
94 ms |
15340 KB |
Output is correct |
5 |
Correct |
96 ms |
15340 KB |
Output is correct |
6 |
Correct |
95 ms |
15388 KB |
Output is correct |
7 |
Correct |
95 ms |
15372 KB |
Output is correct |
8 |
Correct |
96 ms |
15340 KB |
Output is correct |
9 |
Correct |
93 ms |
15340 KB |
Output is correct |
10 |
Correct |
99 ms |
15468 KB |
Output is correct |
11 |
Correct |
100 ms |
15340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
1152 KB |
Output is correct |
6 |
Correct |
106 ms |
15340 KB |
Output is correct |
7 |
Correct |
103 ms |
15360 KB |
Output is correct |
8 |
Correct |
110 ms |
15468 KB |
Output is correct |
9 |
Correct |
103 ms |
15356 KB |
Output is correct |
10 |
Correct |
0 ms |
256 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
1024 KB |
Output is correct |
13 |
Correct |
5 ms |
1152 KB |
Output is correct |
14 |
Correct |
113 ms |
15340 KB |
Output is correct |
15 |
Correct |
110 ms |
15340 KB |
Output is correct |
16 |
Correct |
105 ms |
15468 KB |
Output is correct |
17 |
Correct |
105 ms |
15340 KB |
Output is correct |
18 |
Correct |
105 ms |
15340 KB |
Output is correct |
19 |
Correct |
111 ms |
15340 KB |
Output is correct |
20 |
Correct |
108 ms |
15468 KB |
Output is correct |
21 |
Correct |
112 ms |
15344 KB |
Output is correct |
22 |
Correct |
105 ms |
15340 KB |
Output is correct |
23 |
Correct |
105 ms |
15340 KB |
Output is correct |
24 |
Correct |
109 ms |
15468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
512 KB |
Output is correct |
5 |
Correct |
27 ms |
9336 KB |
Output is correct |
6 |
Correct |
54 ms |
18300 KB |
Output is correct |
7 |
Correct |
81 ms |
27256 KB |
Output is correct |
8 |
Correct |
112 ms |
36472 KB |
Output is correct |
9 |
Correct |
110 ms |
36344 KB |
Output is correct |
10 |
Correct |
106 ms |
36344 KB |
Output is correct |
11 |
Correct |
0 ms |
256 KB |
Output is correct |
12 |
Correct |
101 ms |
36344 KB |
Output is correct |
13 |
Correct |
105 ms |
36352 KB |
Output is correct |
14 |
Correct |
106 ms |
36344 KB |
Output is correct |
15 |
Correct |
108 ms |
36360 KB |
Output is correct |
16 |
Correct |
104 ms |
36344 KB |
Output is correct |
17 |
Correct |
104 ms |
36344 KB |
Output is correct |
18 |
Correct |
103 ms |
36344 KB |
Output is correct |
19 |
Correct |
113 ms |
36384 KB |
Output is correct |
20 |
Correct |
107 ms |
36472 KB |
Output is correct |
21 |
Correct |
0 ms |
256 KB |
Output is correct |
22 |
Correct |
0 ms |
256 KB |
Output is correct |
23 |
Correct |
0 ms |
256 KB |
Output is correct |
24 |
Correct |
94 ms |
15340 KB |
Output is correct |
25 |
Correct |
96 ms |
15340 KB |
Output is correct |
26 |
Correct |
95 ms |
15388 KB |
Output is correct |
27 |
Correct |
95 ms |
15372 KB |
Output is correct |
28 |
Correct |
96 ms |
15340 KB |
Output is correct |
29 |
Correct |
93 ms |
15340 KB |
Output is correct |
30 |
Correct |
99 ms |
15468 KB |
Output is correct |
31 |
Correct |
100 ms |
15340 KB |
Output is correct |
32 |
Correct |
0 ms |
256 KB |
Output is correct |
33 |
Correct |
0 ms |
256 KB |
Output is correct |
34 |
Correct |
0 ms |
256 KB |
Output is correct |
35 |
Correct |
1 ms |
384 KB |
Output is correct |
36 |
Correct |
5 ms |
1152 KB |
Output is correct |
37 |
Correct |
106 ms |
15340 KB |
Output is correct |
38 |
Correct |
103 ms |
15360 KB |
Output is correct |
39 |
Correct |
110 ms |
15468 KB |
Output is correct |
40 |
Correct |
103 ms |
15356 KB |
Output is correct |
41 |
Correct |
0 ms |
256 KB |
Output is correct |
42 |
Correct |
1 ms |
384 KB |
Output is correct |
43 |
Correct |
4 ms |
1024 KB |
Output is correct |
44 |
Correct |
5 ms |
1152 KB |
Output is correct |
45 |
Correct |
113 ms |
15340 KB |
Output is correct |
46 |
Correct |
110 ms |
15340 KB |
Output is correct |
47 |
Correct |
105 ms |
15468 KB |
Output is correct |
48 |
Correct |
105 ms |
15340 KB |
Output is correct |
49 |
Correct |
105 ms |
15340 KB |
Output is correct |
50 |
Correct |
111 ms |
15340 KB |
Output is correct |
51 |
Correct |
108 ms |
15468 KB |
Output is correct |
52 |
Correct |
112 ms |
15344 KB |
Output is correct |
53 |
Correct |
105 ms |
15340 KB |
Output is correct |
54 |
Correct |
105 ms |
15340 KB |
Output is correct |
55 |
Correct |
109 ms |
15468 KB |
Output is correct |
56 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
57 |
Halted |
0 ms |
0 KB |
- |