답안 #211343

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
211343 2020-03-20T06:42:07 Z eric_xiao Job Scheduling (IOI19_job) C++14
100 / 100
668 ms 24128 KB
#include<bits/stdc++.h>
#define ll long long

using namespace std;
ll N,t = 0,ans = 0;
ll DSU[300009],fin[300009];
vector<ll> tim,cost;
ll Find(ll a)
{
    if(a == DSU[a]) return a;
    DSU[a] = Find(DSU[a]);
    return DSU[a];
}
struct cmp{
    bool operator()(ll a, ll b)const {
        if(cost[a]*tim[b] != cost[b]*tim[a]) return cost[a]*tim[b] > cost[b]*tim[a];
        return a < b;
    }
};
set<ll,cmp> st;
ll scheduling_cost(vector<int> P,vector<int> U,vector<int> D)
{
    N = P.size();
    tim.resize(N);
    cost.resize(N);
    ll i;
    for(i = 0;i < N;i++)
    {
        tim[i] = D[i];
        cost[i] = U[i];
    }
    for(i = 0;i < N;i++)
    {
         DSU[i] = i;
         fin[i] = 0;
         st.insert(i);
    }
    for(i = 0;i < N;i++)
    {
         ll now = *st.begin();
         st.erase(now);
         if(P[now] == -1 || fin[Find(P[now])] == 1)
         {
             t += tim[now];
             ans += cost[now]*t;
             fin[now] = 1;
             continue;
         }
         ll top = Find(P[now]);
         st.erase(top);
         ans -= cost[top]*tim[now];
         cost[top] += cost[now];
         tim[top] += tim[now];
         st.insert(top);
         DSU[now] = top;
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 88 ms 6136 KB Output is correct
6 Correct 230 ms 12152 KB Output is correct
7 Correct 401 ms 18040 KB Output is correct
8 Correct 634 ms 23928 KB Output is correct
9 Correct 631 ms 24056 KB Output is correct
10 Correct 617 ms 24056 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 623 ms 24128 KB Output is correct
13 Correct 377 ms 24056 KB Output is correct
14 Correct 375 ms 23944 KB Output is correct
15 Correct 242 ms 24056 KB Output is correct
16 Correct 279 ms 23928 KB Output is correct
17 Correct 645 ms 24056 KB Output is correct
18 Correct 618 ms 23928 KB Output is correct
19 Correct 187 ms 23928 KB Output is correct
20 Correct 169 ms 23928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 259 ms 21324 KB Output is correct
5 Correct 273 ms 21240 KB Output is correct
6 Correct 263 ms 21148 KB Output is correct
7 Correct 269 ms 21240 KB Output is correct
8 Correct 255 ms 21240 KB Output is correct
9 Correct 278 ms 21240 KB Output is correct
10 Correct 255 ms 21240 KB Output is correct
11 Correct 257 ms 21240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 12 ms 1404 KB Output is correct
6 Correct 265 ms 21240 KB Output is correct
7 Correct 259 ms 23048 KB Output is correct
8 Correct 260 ms 23032 KB Output is correct
9 Correct 272 ms 23140 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 6 ms 512 KB Output is correct
12 Correct 11 ms 1280 KB Output is correct
13 Correct 12 ms 1408 KB Output is correct
14 Correct 259 ms 23036 KB Output is correct
15 Correct 262 ms 23032 KB Output is correct
16 Correct 259 ms 23032 KB Output is correct
17 Correct 270 ms 23160 KB Output is correct
18 Correct 260 ms 23032 KB Output is correct
19 Correct 258 ms 23032 KB Output is correct
20 Correct 263 ms 23160 KB Output is correct
21 Correct 255 ms 23032 KB Output is correct
22 Correct 262 ms 23036 KB Output is correct
23 Correct 257 ms 23152 KB Output is correct
24 Correct 260 ms 23036 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 668 ms 21180 KB Output is correct
3 Correct 624 ms 24056 KB Output is correct
4 Correct 639 ms 23928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 88 ms 6136 KB Output is correct
6 Correct 230 ms 12152 KB Output is correct
7 Correct 401 ms 18040 KB Output is correct
8 Correct 634 ms 23928 KB Output is correct
9 Correct 631 ms 24056 KB Output is correct
10 Correct 617 ms 24056 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 623 ms 24128 KB Output is correct
13 Correct 377 ms 24056 KB Output is correct
14 Correct 375 ms 23944 KB Output is correct
15 Correct 242 ms 24056 KB Output is correct
16 Correct 279 ms 23928 KB Output is correct
17 Correct 645 ms 24056 KB Output is correct
18 Correct 618 ms 23928 KB Output is correct
19 Correct 187 ms 23928 KB Output is correct
20 Correct 169 ms 23928 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 4 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 259 ms 21324 KB Output is correct
25 Correct 273 ms 21240 KB Output is correct
26 Correct 263 ms 21148 KB Output is correct
27 Correct 269 ms 21240 KB Output is correct
28 Correct 255 ms 21240 KB Output is correct
29 Correct 278 ms 21240 KB Output is correct
30 Correct 255 ms 21240 KB Output is correct
31 Correct 257 ms 21240 KB Output is correct
32 Correct 5 ms 512 KB Output is correct
33 Correct 4 ms 384 KB Output is correct
34 Correct 5 ms 384 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
36 Correct 12 ms 1404 KB Output is correct
37 Correct 265 ms 21240 KB Output is correct
38 Correct 259 ms 23048 KB Output is correct
39 Correct 260 ms 23032 KB Output is correct
40 Correct 272 ms 23140 KB Output is correct
41 Correct 5 ms 384 KB Output is correct
42 Correct 6 ms 512 KB Output is correct
43 Correct 11 ms 1280 KB Output is correct
44 Correct 12 ms 1408 KB Output is correct
45 Correct 259 ms 23036 KB Output is correct
46 Correct 262 ms 23032 KB Output is correct
47 Correct 259 ms 23032 KB Output is correct
48 Correct 270 ms 23160 KB Output is correct
49 Correct 260 ms 23032 KB Output is correct
50 Correct 258 ms 23032 KB Output is correct
51 Correct 263 ms 23160 KB Output is correct
52 Correct 255 ms 23032 KB Output is correct
53 Correct 262 ms 23036 KB Output is correct
54 Correct 257 ms 23152 KB Output is correct
55 Correct 260 ms 23036 KB Output is correct
56 Correct 5 ms 384 KB Output is correct
57 Correct 668 ms 21180 KB Output is correct
58 Correct 624 ms 24056 KB Output is correct
59 Correct 639 ms 23928 KB Output is correct
60 Correct 5 ms 384 KB Output is correct
61 Correct 4 ms 384 KB Output is correct
62 Correct 5 ms 384 KB Output is correct
63 Correct 5 ms 384 KB Output is correct
64 Correct 5 ms 384 KB Output is correct
65 Correct 4 ms 384 KB Output is correct
66 Correct 5 ms 384 KB Output is correct
67 Correct 5 ms 384 KB Output is correct
68 Correct 5 ms 376 KB Output is correct
69 Correct 5 ms 384 KB Output is correct
70 Correct 5 ms 384 KB Output is correct
71 Correct 5 ms 384 KB Output is correct
72 Correct 5 ms 384 KB Output is correct
73 Correct 5 ms 384 KB Output is correct
74 Correct 5 ms 384 KB Output is correct
75 Correct 5 ms 384 KB Output is correct
76 Correct 5 ms 384 KB Output is correct
77 Correct 4 ms 384 KB Output is correct
78 Correct 4 ms 384 KB Output is correct
79 Correct 5 ms 384 KB Output is correct
80 Correct 5 ms 384 KB Output is correct
81 Correct 4 ms 384 KB Output is correct
82 Correct 4 ms 384 KB Output is correct
83 Correct 4 ms 384 KB Output is correct
84 Correct 4 ms 384 KB Output is correct
85 Correct 5 ms 384 KB Output is correct
86 Correct 4 ms 384 KB Output is correct
87 Correct 5 ms 384 KB Output is correct
88 Correct 10 ms 896 KB Output is correct
89 Correct 13 ms 1280 KB Output is correct
90 Correct 16 ms 1536 KB Output is correct
91 Correct 75 ms 6136 KB Output is correct
92 Correct 177 ms 12040 KB Output is correct
93 Correct 521 ms 23928 KB Output is correct
94 Correct 503 ms 23800 KB Output is correct
95 Correct 506 ms 23940 KB Output is correct
96 Correct 518 ms 23800 KB Output is correct
97 Correct 464 ms 23672 KB Output is correct
98 Correct 428 ms 23928 KB Output is correct
99 Correct 381 ms 23672 KB Output is correct
100 Correct 501 ms 23800 KB Output is correct
101 Correct 568 ms 23952 KB Output is correct
102 Correct 288 ms 23800 KB Output is correct
103 Correct 525 ms 23800 KB Output is correct
104 Correct 511 ms 23928 KB Output is correct
105 Correct 250 ms 23928 KB Output is correct
106 Correct 260 ms 23288 KB Output is correct