답안 #906316

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
906316 2024-01-14T00:58:52 Z vjudge1 Job Scheduling (IOI19_job) C++17
24 / 100
113 ms 19108 KB
#include "job.h"
#include <vector>

#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

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

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pl;
typedef vector<ll> vl;
#define FD(i, r, l) for(ll i = r; i > (l); --i)

#define K first
#define V second
#define G(x) ll x; cin >> x;
#define GD(x) ld x; cin >> x;
#define GS(s) string s; cin >> s;
#define EX(x) { cout << x << '\n'; exit(0); }
#define A(a) (a).begin(), (a).end()
#define F(i, l, r) for (ll i = l; i < (r); ++i)

#define NN
#define M 1000000007 // 998244353

vl adj[200010];

long long scheduling_cost(std::vector<int> p, std::vector<int> u, std::vector<int> d) {
    ll ans = 0;
    int n = (int)p.size();
    bool case1 = true,case2 = true;

    for(int i=1;i<n;i++){
        case1 &= p[i]==i-1;

        case2 &= p[i]==0;
        case2 &= d[i]==1;

        adj[p[i]].push_back(i);
    }

    if(case1){
        ll time = 0;
        for(int i=0;i<n;i++){
            time += d[i];
            ans += time*u[i];
        }
        return ans;
    }

    auto cmp = [&](int i,int j){
        return -u[i]*d[j] > -u[j]*d[i];
    };

    priority_queue<ll, vector<ll>, decltype(cmp)> pq(cmp);
    ans += d[0] * u[0];
    ll time = d[0];
    for (auto x: adj[0]) pq.push(x);
    while (pq.size()) {
        auto i = pq.top(); pq.pop();
        time += d[i];
        ans += time * u[i];
        for (auto y: adj[i]) pq.push(y); 
    }

    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 3 ms 4956 KB Output is correct
5 Correct 15 ms 7772 KB Output is correct
6 Correct 29 ms 10404 KB Output is correct
7 Correct 43 ms 13180 KB Output is correct
8 Correct 55 ms 15968 KB Output is correct
9 Correct 55 ms 15956 KB Output is correct
10 Correct 55 ms 15920 KB Output is correct
11 Correct 1 ms 4952 KB Output is correct
12 Correct 55 ms 15956 KB Output is correct
13 Correct 55 ms 15904 KB Output is correct
14 Correct 55 ms 16032 KB Output is correct
15 Correct 60 ms 15956 KB Output is correct
16 Correct 55 ms 15964 KB Output is correct
17 Correct 62 ms 15924 KB Output is correct
18 Correct 56 ms 15976 KB Output is correct
19 Correct 56 ms 15956 KB Output is correct
20 Correct 63 ms 15960 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 108 ms 14500 KB Output is correct
5 Correct 99 ms 14360 KB Output is correct
6 Correct 97 ms 14480 KB Output is correct
7 Correct 100 ms 14276 KB Output is correct
8 Correct 100 ms 14236 KB Output is correct
9 Correct 103 ms 14724 KB Output is correct
10 Correct 99 ms 14244 KB Output is correct
11 Correct 101 ms 14480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 5208 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 6 ms 5464 KB Output is correct
6 Correct 99 ms 14276 KB Output is correct
7 Correct 98 ms 14276 KB Output is correct
8 Correct 101 ms 14292 KB Output is correct
9 Correct 99 ms 14480 KB Output is correct
10 Correct 2 ms 4956 KB Output is correct
11 Correct 2 ms 5132 KB Output is correct
12 Correct 5 ms 5468 KB Output is correct
13 Correct 5 ms 5468 KB Output is correct
14 Correct 99 ms 14244 KB Output is correct
15 Correct 100 ms 14256 KB Output is correct
16 Correct 106 ms 14276 KB Output is correct
17 Correct 99 ms 14276 KB Output is correct
18 Correct 103 ms 14464 KB Output is correct
19 Correct 111 ms 14252 KB Output is correct
20 Correct 98 ms 14352 KB Output is correct
21 Correct 95 ms 14276 KB Output is correct
22 Correct 98 ms 14276 KB Output is correct
23 Correct 113 ms 14276 KB Output is correct
24 Correct 101 ms 14276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Incorrect 59 ms 19108 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Incorrect 2 ms 4956 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 3 ms 4956 KB Output is correct
5 Correct 15 ms 7772 KB Output is correct
6 Correct 29 ms 10404 KB Output is correct
7 Correct 43 ms 13180 KB Output is correct
8 Correct 55 ms 15968 KB Output is correct
9 Correct 55 ms 15956 KB Output is correct
10 Correct 55 ms 15920 KB Output is correct
11 Correct 1 ms 4952 KB Output is correct
12 Correct 55 ms 15956 KB Output is correct
13 Correct 55 ms 15904 KB Output is correct
14 Correct 55 ms 16032 KB Output is correct
15 Correct 60 ms 15956 KB Output is correct
16 Correct 55 ms 15964 KB Output is correct
17 Correct 62 ms 15924 KB Output is correct
18 Correct 56 ms 15976 KB Output is correct
19 Correct 56 ms 15956 KB Output is correct
20 Correct 63 ms 15960 KB Output is correct
21 Correct 2 ms 4952 KB Output is correct
22 Correct 2 ms 4956 KB Output is correct
23 Correct 2 ms 4956 KB Output is correct
24 Correct 108 ms 14500 KB Output is correct
25 Correct 99 ms 14360 KB Output is correct
26 Correct 97 ms 14480 KB Output is correct
27 Correct 100 ms 14276 KB Output is correct
28 Correct 100 ms 14236 KB Output is correct
29 Correct 103 ms 14724 KB Output is correct
30 Correct 99 ms 14244 KB Output is correct
31 Correct 101 ms 14480 KB Output is correct
32 Correct 2 ms 4952 KB Output is correct
33 Correct 2 ms 5208 KB Output is correct
34 Correct 2 ms 4956 KB Output is correct
35 Correct 2 ms 4956 KB Output is correct
36 Correct 6 ms 5464 KB Output is correct
37 Correct 99 ms 14276 KB Output is correct
38 Correct 98 ms 14276 KB Output is correct
39 Correct 101 ms 14292 KB Output is correct
40 Correct 99 ms 14480 KB Output is correct
41 Correct 2 ms 4956 KB Output is correct
42 Correct 2 ms 5132 KB Output is correct
43 Correct 5 ms 5468 KB Output is correct
44 Correct 5 ms 5468 KB Output is correct
45 Correct 99 ms 14244 KB Output is correct
46 Correct 100 ms 14256 KB Output is correct
47 Correct 106 ms 14276 KB Output is correct
48 Correct 99 ms 14276 KB Output is correct
49 Correct 103 ms 14464 KB Output is correct
50 Correct 111 ms 14252 KB Output is correct
51 Correct 98 ms 14352 KB Output is correct
52 Correct 95 ms 14276 KB Output is correct
53 Correct 98 ms 14276 KB Output is correct
54 Correct 113 ms 14276 KB Output is correct
55 Correct 101 ms 14276 KB Output is correct
56 Correct 2 ms 4956 KB Output is correct
57 Incorrect 59 ms 19108 KB Output isn't correct
58 Halted 0 ms 0 KB -