# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
251010 |
2020-07-19T22:41:59 Z |
cjoa |
Job Scheduling (IOI19_job) |
C++14 |
|
121 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);
}
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 T = 0;
llong res = dfs2(0, T);
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
512 KB |
Output is correct |
5 |
Correct |
29 ms |
9336 KB |
Output is correct |
6 |
Correct |
58 ms |
18296 KB |
Output is correct |
7 |
Correct |
85 ms |
27256 KB |
Output is correct |
8 |
Correct |
121 ms |
36344 KB |
Output is correct |
9 |
Correct |
120 ms |
36392 KB |
Output is correct |
10 |
Correct |
118 ms |
36360 KB |
Output is correct |
11 |
Correct |
0 ms |
256 KB |
Output is correct |
12 |
Correct |
110 ms |
36344 KB |
Output is correct |
13 |
Correct |
113 ms |
36344 KB |
Output is correct |
14 |
Correct |
115 ms |
36272 KB |
Output is correct |
15 |
Correct |
110 ms |
36344 KB |
Output is correct |
16 |
Correct |
116 ms |
36344 KB |
Output is correct |
17 |
Correct |
119 ms |
36348 KB |
Output is correct |
18 |
Correct |
119 ms |
36472 KB |
Output is correct |
19 |
Correct |
113 ms |
36344 KB |
Output is correct |
20 |
Correct |
112 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 |
104 ms |
15340 KB |
Output is correct |
5 |
Correct |
112 ms |
15596 KB |
Output is correct |
6 |
Correct |
102 ms |
15340 KB |
Output is correct |
7 |
Correct |
104 ms |
15340 KB |
Output is correct |
8 |
Correct |
103 ms |
15340 KB |
Output is correct |
9 |
Correct |
104 ms |
15364 KB |
Output is correct |
10 |
Correct |
106 ms |
15340 KB |
Output is correct |
11 |
Correct |
106 ms |
15340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
1056 KB |
Output is correct |
6 |
Correct |
116 ms |
15340 KB |
Output is correct |
7 |
Correct |
115 ms |
15340 KB |
Output is correct |
8 |
Correct |
112 ms |
15340 KB |
Output is correct |
9 |
Correct |
113 ms |
15376 KB |
Output is correct |
10 |
Correct |
0 ms |
256 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
1024 KB |
Output is correct |
13 |
Correct |
5 ms |
1152 KB |
Output is correct |
14 |
Correct |
113 ms |
15360 KB |
Output is correct |
15 |
Correct |
112 ms |
15340 KB |
Output is correct |
16 |
Correct |
112 ms |
15340 KB |
Output is correct |
17 |
Correct |
113 ms |
15340 KB |
Output is correct |
18 |
Correct |
112 ms |
15340 KB |
Output is correct |
19 |
Correct |
112 ms |
15340 KB |
Output is correct |
20 |
Correct |
115 ms |
15340 KB |
Output is correct |
21 |
Correct |
112 ms |
15340 KB |
Output is correct |
22 |
Correct |
112 ms |
15340 KB |
Output is correct |
23 |
Correct |
114 ms |
15340 KB |
Output is correct |
24 |
Correct |
113 ms |
15340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 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 |
1 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 |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
512 KB |
Output is correct |
5 |
Correct |
29 ms |
9336 KB |
Output is correct |
6 |
Correct |
58 ms |
18296 KB |
Output is correct |
7 |
Correct |
85 ms |
27256 KB |
Output is correct |
8 |
Correct |
121 ms |
36344 KB |
Output is correct |
9 |
Correct |
120 ms |
36392 KB |
Output is correct |
10 |
Correct |
118 ms |
36360 KB |
Output is correct |
11 |
Correct |
0 ms |
256 KB |
Output is correct |
12 |
Correct |
110 ms |
36344 KB |
Output is correct |
13 |
Correct |
113 ms |
36344 KB |
Output is correct |
14 |
Correct |
115 ms |
36272 KB |
Output is correct |
15 |
Correct |
110 ms |
36344 KB |
Output is correct |
16 |
Correct |
116 ms |
36344 KB |
Output is correct |
17 |
Correct |
119 ms |
36348 KB |
Output is correct |
18 |
Correct |
119 ms |
36472 KB |
Output is correct |
19 |
Correct |
113 ms |
36344 KB |
Output is correct |
20 |
Correct |
112 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 |
104 ms |
15340 KB |
Output is correct |
25 |
Correct |
112 ms |
15596 KB |
Output is correct |
26 |
Correct |
102 ms |
15340 KB |
Output is correct |
27 |
Correct |
104 ms |
15340 KB |
Output is correct |
28 |
Correct |
103 ms |
15340 KB |
Output is correct |
29 |
Correct |
104 ms |
15364 KB |
Output is correct |
30 |
Correct |
106 ms |
15340 KB |
Output is correct |
31 |
Correct |
106 ms |
15340 KB |
Output is correct |
32 |
Correct |
0 ms |
256 KB |
Output is correct |
33 |
Correct |
1 ms |
256 KB |
Output is correct |
34 |
Correct |
1 ms |
256 KB |
Output is correct |
35 |
Correct |
1 ms |
384 KB |
Output is correct |
36 |
Correct |
6 ms |
1056 KB |
Output is correct |
37 |
Correct |
116 ms |
15340 KB |
Output is correct |
38 |
Correct |
115 ms |
15340 KB |
Output is correct |
39 |
Correct |
112 ms |
15340 KB |
Output is correct |
40 |
Correct |
113 ms |
15376 KB |
Output is correct |
41 |
Correct |
0 ms |
256 KB |
Output is correct |
42 |
Correct |
1 ms |
384 KB |
Output is correct |
43 |
Correct |
5 ms |
1024 KB |
Output is correct |
44 |
Correct |
5 ms |
1152 KB |
Output is correct |
45 |
Correct |
113 ms |
15360 KB |
Output is correct |
46 |
Correct |
112 ms |
15340 KB |
Output is correct |
47 |
Correct |
112 ms |
15340 KB |
Output is correct |
48 |
Correct |
113 ms |
15340 KB |
Output is correct |
49 |
Correct |
112 ms |
15340 KB |
Output is correct |
50 |
Correct |
112 ms |
15340 KB |
Output is correct |
51 |
Correct |
115 ms |
15340 KB |
Output is correct |
52 |
Correct |
112 ms |
15340 KB |
Output is correct |
53 |
Correct |
112 ms |
15340 KB |
Output is correct |
54 |
Correct |
114 ms |
15340 KB |
Output is correct |
55 |
Correct |
113 ms |
15340 KB |
Output is correct |
56 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
57 |
Halted |
0 ms |
0 KB |
- |