답안 #313676

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
313676 2020-10-16T14:50:31 Z MiricaMatei Job Scheduling (IOI19_job) C++14
24 / 100
174 ms 12644 KB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 200005;

bool vis[MAXN];

struct Obj {
  long long i, u, d;
  bool operator <(const Obj& other) const {
    bool ans;
    if (u == 0) {
      ans = 0;
    } else {
      if (other.u == 0) {
        ans = 1;
      } else {
        if (1LL * d * other.u < 1LL * other.d * u)
          ans = 1;
        else
          ans = 0;
      }
    }
    return !ans;
  }
};

long long scheduling_cost(vector<int>p, vector<int>u, vector<int>d) {
  int n = p.size();
  priority_queue<Obj>pq;
  for (int i = 1; i < n; ++i)
    pq.push({i, u[i], d[i]});
  vector<int>v;
  v.push_back(0);
  vis[0] = 1;
  while (!pq.empty()) {
    Obj aux = pq.top();
    pq.pop();
    vector<int>a;
    int x = aux.i;
    while (!vis[x]) {
      a.push_back(x);
      vis[x] = 1;
      x = p[x];
    }
    reverse(a.begin(), a.end());
    for (auto it:a)
      v.push_back(it);
  }
  long long ans = 0;
  long long t = 0;
  for (auto it:v) {
    t += d[it];
    ans += t * u[it];
  }
  return ans;
}

/*int main() {
  freopen("date.in", "r", stdin);
  freopen("date.out", "w", stdout);

  int n;
  scanf("%d", &n);
  vector<int>p(n), u(n), d(n);
  for (int i = 0; i < n; ++i)
    scanf("%d", &p[i]);
  for (int i = 0; i < n; ++i)
    scanf("%d", &u[i]);
  for (int i = 0; i < n; ++i)
    scanf("%d", &d[i]);

  printf("%lld\n", scheduling_cost(p, u, d));

  return 0;
}*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 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 35 ms 3316 KB Output is correct
6 Correct 78 ms 6120 KB Output is correct
7 Correct 115 ms 10088 KB Output is correct
8 Correct 149 ms 12260 KB Output is correct
9 Correct 149 ms 12260 KB Output is correct
10 Correct 150 ms 11760 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 152 ms 12388 KB Output is correct
13 Correct 148 ms 12516 KB Output is correct
14 Correct 147 ms 12124 KB Output is correct
15 Correct 138 ms 12644 KB Output is correct
16 Correct 142 ms 11740 KB Output is correct
17 Correct 150 ms 12004 KB Output is correct
18 Correct 152 ms 12260 KB Output is correct
19 Correct 134 ms 12516 KB Output is correct
20 Correct 138 ms 11716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 162 ms 11740 KB Output is correct
5 Correct 156 ms 11780 KB Output is correct
6 Correct 151 ms 11744 KB Output is correct
7 Correct 159 ms 11796 KB Output is correct
8 Correct 160 ms 11740 KB Output is correct
9 Correct 152 ms 11868 KB Output is correct
10 Correct 159 ms 11740 KB Output is correct
11 Correct 162 ms 11768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 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 7 ms 1092 KB Output is correct
6 Correct 164 ms 11740 KB Output is correct
7 Correct 165 ms 11740 KB Output is correct
8 Correct 166 ms 11740 KB Output is correct
9 Correct 166 ms 11868 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 6 ms 1092 KB Output is correct
13 Correct 7 ms 1092 KB Output is correct
14 Correct 163 ms 11744 KB Output is correct
15 Correct 174 ms 11740 KB Output is correct
16 Correct 168 ms 11740 KB Output is correct
17 Correct 162 ms 11740 KB Output is correct
18 Correct 167 ms 11744 KB Output is correct
19 Correct 164 ms 11736 KB Output is correct
20 Correct 161 ms 11740 KB Output is correct
21 Correct 166 ms 11872 KB Output is correct
22 Correct 164 ms 11740 KB Output is correct
23 Correct 167 ms 11740 KB Output is correct
24 Correct 165 ms 11872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 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 35 ms 3316 KB Output is correct
6 Correct 78 ms 6120 KB Output is correct
7 Correct 115 ms 10088 KB Output is correct
8 Correct 149 ms 12260 KB Output is correct
9 Correct 149 ms 12260 KB Output is correct
10 Correct 150 ms 11760 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 152 ms 12388 KB Output is correct
13 Correct 148 ms 12516 KB Output is correct
14 Correct 147 ms 12124 KB Output is correct
15 Correct 138 ms 12644 KB Output is correct
16 Correct 142 ms 11740 KB Output is correct
17 Correct 150 ms 12004 KB Output is correct
18 Correct 152 ms 12260 KB Output is correct
19 Correct 134 ms 12516 KB Output is correct
20 Correct 138 ms 11716 KB Output is correct
21 Correct 0 ms 256 KB Output is correct
22 Correct 0 ms 256 KB Output is correct
23 Correct 1 ms 256 KB Output is correct
24 Correct 162 ms 11740 KB Output is correct
25 Correct 156 ms 11780 KB Output is correct
26 Correct 151 ms 11744 KB Output is correct
27 Correct 159 ms 11796 KB Output is correct
28 Correct 160 ms 11740 KB Output is correct
29 Correct 152 ms 11868 KB Output is correct
30 Correct 159 ms 11740 KB Output is correct
31 Correct 162 ms 11768 KB Output is correct
32 Correct 1 ms 256 KB Output is correct
33 Correct 0 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 7 ms 1092 KB Output is correct
37 Correct 164 ms 11740 KB Output is correct
38 Correct 165 ms 11740 KB Output is correct
39 Correct 166 ms 11740 KB Output is correct
40 Correct 166 ms 11868 KB Output is correct
41 Correct 1 ms 256 KB Output is correct
42 Correct 1 ms 384 KB Output is correct
43 Correct 6 ms 1092 KB Output is correct
44 Correct 7 ms 1092 KB Output is correct
45 Correct 163 ms 11744 KB Output is correct
46 Correct 174 ms 11740 KB Output is correct
47 Correct 168 ms 11740 KB Output is correct
48 Correct 162 ms 11740 KB Output is correct
49 Correct 167 ms 11744 KB Output is correct
50 Correct 164 ms 11736 KB Output is correct
51 Correct 161 ms 11740 KB Output is correct
52 Correct 166 ms 11872 KB Output is correct
53 Correct 164 ms 11740 KB Output is correct
54 Correct 167 ms 11740 KB Output is correct
55 Correct 165 ms 11872 KB Output is correct
56 Incorrect 0 ms 256 KB Output isn't correct
57 Halted 0 ms 0 KB -