Submission #417356

# Submission time Handle Problem Language Result Execution time Memory
417356 2021-06-03T15:19:27 Z rama_pang Job Scheduling (IOI19_job) C++17
19 / 100
91 ms 8112 KB
#include "job.h"

#include <bits/stdc++.h>
using namespace std;

using lint = long long;

lint scheduling_cost(vector<int> p, vector<int> u, vector<int> d) {
  // Solution:
  // Assume there is no p[]. Let's ignore u[i] * d[i].
  //
  // Let's observe i and j. If i < j is optimal:
  // u[j] * d[i] < u[i] * d[j]
  // u[j] / d[j] < u[i] / d[i]
  // So, we sort by u[x] / d[x]

  int n = p.size();
  lint ans = 0;
  vector<int> ord(n);
  iota(begin(ord), end(ord), 0);
  sort(begin(ord) + 1, end(ord), [&](int i, int j) {
    return u[i] * d[j] > u[j] * d[i];
  });

  int t = 0;
  for (auto i : ord) {
    t += d[i];
    ans += 1ll * t * u[i];
  }

	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 83 ms 7448 KB Output is correct
5 Correct 84 ms 7480 KB Output is correct
6 Correct 81 ms 7496 KB Output is correct
7 Correct 83 ms 7492 KB Output is correct
8 Correct 83 ms 7484 KB Output is correct
9 Correct 82 ms 7492 KB Output is correct
10 Correct 84 ms 7468 KB Output is correct
11 Correct 83 ms 7476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 5 ms 588 KB Output is correct
6 Correct 91 ms 8000 KB Output is correct
7 Correct 89 ms 7980 KB Output is correct
8 Correct 89 ms 8004 KB Output is correct
9 Correct 88 ms 7980 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 4 ms 560 KB Output is correct
13 Correct 5 ms 588 KB Output is correct
14 Correct 91 ms 8004 KB Output is correct
15 Correct 88 ms 8000 KB Output is correct
16 Correct 89 ms 7996 KB Output is correct
17 Correct 88 ms 8004 KB Output is correct
18 Correct 89 ms 7980 KB Output is correct
19 Correct 91 ms 7992 KB Output is correct
20 Correct 91 ms 8004 KB Output is correct
21 Correct 90 ms 7992 KB Output is correct
22 Correct 89 ms 7996 KB Output is correct
23 Correct 88 ms 8088 KB Output is correct
24 Correct 89 ms 8112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -