Submission #367371

# Submission time Handle Problem Language Result Execution time Memory
367371 2021-02-17T01:50:58 Z PurpleCrayon Job Scheduling (IOI19_job) C++17
24 / 100
196 ms 19180 KB
#include "job.h"
#include <bits/stdc++.h>
using namespace std;

#define sz(v) int(v.size())
#define ar array
typedef long long ll;

ll scheduling_cost(vector<int> p, vector<int> u, vector<int> d) {
    int n=sz(p);
    vector<vector<int>> ch(n);
    for (int i = 1; i < n; i++) ch[p[i]].push_back(i);

    auto cmp = [&](int i, int j) -> bool {
        return ll(d[j])*ll(u[i]) < ll(d[i])*ll(u[j]);
    };
    priority_queue<int, vector<int>, decltype(cmp)> roots(cmp);

    ll ans=0, t=0;
    roots.push(0);

    while (sz(roots)){
        int c=roots.top(); roots.pop();
        t += d[c], ans += t*u[c];
        for (auto nxt : ch[c]) roots.push(nxt);
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 24 ms 4972 KB Output is correct
6 Correct 48 ms 9708 KB Output is correct
7 Correct 72 ms 14444 KB Output is correct
8 Correct 100 ms 19180 KB Output is correct
9 Correct 120 ms 19180 KB Output is correct
10 Correct 95 ms 19180 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 96 ms 19180 KB Output is correct
13 Correct 96 ms 19180 KB Output is correct
14 Correct 103 ms 19180 KB Output is correct
15 Correct 96 ms 19180 KB Output is correct
16 Correct 94 ms 19180 KB Output is correct
17 Correct 94 ms 19180 KB Output is correct
18 Correct 96 ms 19180 KB Output is correct
19 Correct 93 ms 19180 KB Output is correct
20 Correct 98 ms 19180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 179 ms 13792 KB Output is correct
5 Correct 170 ms 13920 KB Output is correct
6 Correct 190 ms 13792 KB Output is correct
7 Correct 169 ms 13740 KB Output is correct
8 Correct 175 ms 13812 KB Output is correct
9 Correct 174 ms 13792 KB Output is correct
10 Correct 196 ms 13792 KB Output is correct
11 Correct 176 ms 13792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 6 ms 1004 KB Output is correct
6 Correct 195 ms 14304 KB Output is correct
7 Correct 179 ms 14304 KB Output is correct
8 Correct 176 ms 14304 KB Output is correct
9 Correct 181 ms 14304 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 6 ms 1004 KB Output is correct
13 Correct 6 ms 1004 KB Output is correct
14 Correct 176 ms 14304 KB Output is correct
15 Correct 183 ms 14432 KB Output is correct
16 Correct 178 ms 14304 KB Output is correct
17 Correct 179 ms 14304 KB Output is correct
18 Correct 181 ms 14304 KB Output is correct
19 Correct 174 ms 14560 KB Output is correct
20 Correct 176 ms 14304 KB Output is correct
21 Correct 192 ms 14304 KB Output is correct
22 Correct 178 ms 14432 KB Output is correct
23 Correct 177 ms 14304 KB Output is correct
24 Correct 180 ms 14304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Incorrect 96 ms 19180 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 24 ms 4972 KB Output is correct
6 Correct 48 ms 9708 KB Output is correct
7 Correct 72 ms 14444 KB Output is correct
8 Correct 100 ms 19180 KB Output is correct
9 Correct 120 ms 19180 KB Output is correct
10 Correct 95 ms 19180 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 96 ms 19180 KB Output is correct
13 Correct 96 ms 19180 KB Output is correct
14 Correct 103 ms 19180 KB Output is correct
15 Correct 96 ms 19180 KB Output is correct
16 Correct 94 ms 19180 KB Output is correct
17 Correct 94 ms 19180 KB Output is correct
18 Correct 96 ms 19180 KB Output is correct
19 Correct 93 ms 19180 KB Output is correct
20 Correct 98 ms 19180 KB Output is correct
21 Correct 0 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 179 ms 13792 KB Output is correct
25 Correct 170 ms 13920 KB Output is correct
26 Correct 190 ms 13792 KB Output is correct
27 Correct 169 ms 13740 KB Output is correct
28 Correct 175 ms 13812 KB Output is correct
29 Correct 174 ms 13792 KB Output is correct
30 Correct 196 ms 13792 KB Output is correct
31 Correct 176 ms 13792 KB Output is correct
32 Correct 0 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 1 ms 364 KB Output is correct
35 Correct 1 ms 364 KB Output is correct
36 Correct 6 ms 1004 KB Output is correct
37 Correct 195 ms 14304 KB Output is correct
38 Correct 179 ms 14304 KB Output is correct
39 Correct 176 ms 14304 KB Output is correct
40 Correct 181 ms 14304 KB Output is correct
41 Correct 1 ms 364 KB Output is correct
42 Correct 1 ms 364 KB Output is correct
43 Correct 6 ms 1004 KB Output is correct
44 Correct 6 ms 1004 KB Output is correct
45 Correct 176 ms 14304 KB Output is correct
46 Correct 183 ms 14432 KB Output is correct
47 Correct 178 ms 14304 KB Output is correct
48 Correct 179 ms 14304 KB Output is correct
49 Correct 181 ms 14304 KB Output is correct
50 Correct 174 ms 14560 KB Output is correct
51 Correct 176 ms 14304 KB Output is correct
52 Correct 192 ms 14304 KB Output is correct
53 Correct 178 ms 14432 KB Output is correct
54 Correct 177 ms 14304 KB Output is correct
55 Correct 180 ms 14304 KB Output is correct
56 Correct 0 ms 364 KB Output is correct
57 Incorrect 96 ms 19180 KB Output isn't correct
58 Halted 0 ms 0 KB -