Submission #251359

# Submission time Handle Problem Language Result Execution time Memory
251359 2020-07-21T02:09:48 Z cjoa Job Scheduling (IOI19_job) C++14
24 / 100
189 ms 19812 KB
#include "job.h"

#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long llong;

struct Temple {
   int id;
   llong days, cost;
   bool operator<(const Temple& t) const {
      return days * t.cost > t.days * cost;
   }
};

long long scheduling_cost(vector<int> p, vector<int> u, vector<int> d) {
   int N = p.size();
   VVI tree(N);

   for (int i = 1; i < N; ++i)
      tree[ p[i] ].push_back(i);

   llong T = 0;
   llong res = 0;

   priority_queue<Temple> pq;
   pq.push({0, d[0], u[0]});
   while (!pq.empty()) {
      Temple t = pq.top();
      pq.pop();
      T += d[t.id];
      res += T * u[t.id];
      for (int y : tree[t.id]) {
         pq.push({y, d[y], u[y]});
      }
   }

   return res;
}
# 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 28 ms 4992 KB Output is correct
6 Correct 57 ms 9720 KB Output is correct
7 Correct 82 ms 14464 KB Output is correct
8 Correct 112 ms 19320 KB Output is correct
9 Correct 117 ms 19320 KB Output is correct
10 Correct 116 ms 19312 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 116 ms 19192 KB Output is correct
13 Correct 110 ms 19192 KB Output is correct
14 Correct 115 ms 19192 KB Output is correct
15 Correct 113 ms 19204 KB Output is correct
16 Correct 112 ms 19192 KB Output is correct
17 Correct 117 ms 19196 KB Output is correct
18 Correct 125 ms 19316 KB Output is correct
19 Correct 124 ms 19192 KB Output is correct
20 Correct 109 ms 19216 KB Output is correct
# 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 384 KB Output is correct
4 Correct 180 ms 19172 KB Output is correct
5 Correct 154 ms 19192 KB Output is correct
6 Correct 158 ms 19172 KB Output is correct
7 Correct 157 ms 19192 KB Output is correct
8 Correct 158 ms 19188 KB Output is correct
9 Correct 156 ms 19172 KB Output is correct
10 Correct 168 ms 19172 KB Output is correct
11 Correct 158 ms 19172 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 7 ms 1520 KB Output is correct
6 Correct 180 ms 19684 KB Output is correct
7 Correct 164 ms 19812 KB Output is correct
8 Correct 168 ms 19684 KB Output is correct
9 Correct 164 ms 19684 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 512 KB Output is correct
12 Correct 6 ms 1392 KB Output is correct
13 Correct 7 ms 1520 KB Output is correct
14 Correct 160 ms 19720 KB Output is correct
15 Correct 160 ms 19684 KB Output is correct
16 Correct 171 ms 19684 KB Output is correct
17 Correct 161 ms 19684 KB Output is correct
18 Correct 162 ms 19808 KB Output is correct
19 Correct 172 ms 19688 KB Output is correct
20 Correct 161 ms 19684 KB Output is correct
21 Correct 171 ms 19684 KB Output is correct
22 Correct 173 ms 19812 KB Output is correct
23 Correct 177 ms 19812 KB Output is correct
24 Correct 189 ms 19684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 111 ms 19196 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 Incorrect 0 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 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 28 ms 4992 KB Output is correct
6 Correct 57 ms 9720 KB Output is correct
7 Correct 82 ms 14464 KB Output is correct
8 Correct 112 ms 19320 KB Output is correct
9 Correct 117 ms 19320 KB Output is correct
10 Correct 116 ms 19312 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 116 ms 19192 KB Output is correct
13 Correct 110 ms 19192 KB Output is correct
14 Correct 115 ms 19192 KB Output is correct
15 Correct 113 ms 19204 KB Output is correct
16 Correct 112 ms 19192 KB Output is correct
17 Correct 117 ms 19196 KB Output is correct
18 Correct 125 ms 19316 KB Output is correct
19 Correct 124 ms 19192 KB Output is correct
20 Correct 109 ms 19216 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 180 ms 19172 KB Output is correct
25 Correct 154 ms 19192 KB Output is correct
26 Correct 158 ms 19172 KB Output is correct
27 Correct 157 ms 19192 KB Output is correct
28 Correct 158 ms 19188 KB Output is correct
29 Correct 156 ms 19172 KB Output is correct
30 Correct 168 ms 19172 KB Output is correct
31 Correct 158 ms 19172 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 7 ms 1520 KB Output is correct
37 Correct 180 ms 19684 KB Output is correct
38 Correct 164 ms 19812 KB Output is correct
39 Correct 168 ms 19684 KB Output is correct
40 Correct 164 ms 19684 KB Output is correct
41 Correct 1 ms 256 KB Output is correct
42 Correct 1 ms 512 KB Output is correct
43 Correct 6 ms 1392 KB Output is correct
44 Correct 7 ms 1520 KB Output is correct
45 Correct 160 ms 19720 KB Output is correct
46 Correct 160 ms 19684 KB Output is correct
47 Correct 171 ms 19684 KB Output is correct
48 Correct 161 ms 19684 KB Output is correct
49 Correct 162 ms 19808 KB Output is correct
50 Correct 172 ms 19688 KB Output is correct
51 Correct 161 ms 19684 KB Output is correct
52 Correct 171 ms 19684 KB Output is correct
53 Correct 173 ms 19812 KB Output is correct
54 Correct 177 ms 19812 KB Output is correct
55 Correct 189 ms 19684 KB Output is correct
56 Correct 1 ms 256 KB Output is correct
57 Incorrect 111 ms 19196 KB Output isn't correct
58 Halted 0 ms 0 KB -