답안 #1060831

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1060831 2024-08-16T02:00:26 Z vjudge1 Job Scheduling (IOI19_job) C++17
100 / 100
283 ms 24760 KB
#include "job.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct dsu{
    int par[1<<18];
    int abp(int n){
        return par[n]?par[n]=abp(par[n]):n;
    }
    void merge(int a,int b){
        a=abp(a+2),b=abp(b+2);
        par[b]=a;
    }
    int comp(int n){
        return abp(n+2)-2;
    }
} DDT;
struct DATA{
    ll timetaken,value,i;
    DATA(ll u,ll d,int ind){
        value=u,timetaken=d,i=ind;
    }
    friend bool operator<(const DATA &a,const DATA&b){
        return make_pair(a.timetaken*b.value,a.i)<
                make_pair(b.timetaken*a.value,b.i);
    }
};
set<DATA>pq;
ll scheduling_cost(std::vector<int> p, std::vector<int> _u, std::vector<int> _d) {
    vector<ll>u,d;
    int N=p.size();
    ll curtime=0,ans=0;
    for(int i=0;i<N;i++)
        u.push_back(_u[i]),
        d.push_back(_d[i]),
        ans+=u[i]*d[i];
    for(int i=0;i<N;i++)
        pq.insert(DATA(u[i],d[i],i));
    while(pq.size()){
        int i=pq.begin()->i;
        pq.erase(DATA(u[i],d[i],i));
        if(DDT.comp(p[i])==-1){
            ans+=curtime*u[i];
            curtime+=d[i];
            DDT.merge(-1,i);
        } else {
            int mer=DDT.comp(p[i]);
            pq.erase(DATA(u[mer],d[mer],mer));
            DDT.merge(mer,i);
            ans+=d[mer]*u[i];
            u[mer]+=u[i];d[mer]+=d[i];
            pq.insert(DATA(u[mer],d[mer],mer));
        }
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 48 ms 5540 KB Output is correct
6 Correct 113 ms 10936 KB Output is correct
7 Correct 186 ms 16056 KB Output is correct
8 Correct 271 ms 21576 KB Output is correct
9 Correct 272 ms 21432 KB Output is correct
10 Correct 269 ms 21772 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 276 ms 21548 KB Output is correct
13 Correct 175 ms 21432 KB Output is correct
14 Correct 207 ms 21328 KB Output is correct
15 Correct 118 ms 21428 KB Output is correct
16 Correct 186 ms 21432 KB Output is correct
17 Correct 276 ms 21584 KB Output is correct
18 Correct 260 ms 21528 KB Output is correct
19 Correct 90 ms 21424 KB Output is correct
20 Correct 90 ms 21428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 128 ms 21564 KB Output is correct
5 Correct 131 ms 21484 KB Output is correct
6 Correct 131 ms 21444 KB Output is correct
7 Correct 126 ms 21428 KB Output is correct
8 Correct 129 ms 21428 KB Output is correct
9 Correct 124 ms 21424 KB Output is correct
10 Correct 134 ms 21520 KB Output is correct
11 Correct 132 ms 21532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 5 ms 1372 KB Output is correct
6 Correct 126 ms 21840 KB Output is correct
7 Correct 126 ms 21436 KB Output is correct
8 Correct 125 ms 21588 KB Output is correct
9 Correct 126 ms 21428 KB Output is correct
10 Correct 0 ms 600 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 4 ms 1372 KB Output is correct
13 Correct 5 ms 1372 KB Output is correct
14 Correct 124 ms 21332 KB Output is correct
15 Correct 150 ms 21568 KB Output is correct
16 Correct 127 ms 21428 KB Output is correct
17 Correct 142 ms 21428 KB Output is correct
18 Correct 127 ms 21428 KB Output is correct
19 Correct 126 ms 21424 KB Output is correct
20 Correct 126 ms 21428 KB Output is correct
21 Correct 133 ms 21428 KB Output is correct
22 Correct 127 ms 21432 KB Output is correct
23 Correct 128 ms 21576 KB Output is correct
24 Correct 128 ms 21688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 283 ms 24628 KB Output is correct
3 Correct 277 ms 24760 KB Output is correct
4 Correct 273 ms 24576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 48 ms 5540 KB Output is correct
6 Correct 113 ms 10936 KB Output is correct
7 Correct 186 ms 16056 KB Output is correct
8 Correct 271 ms 21576 KB Output is correct
9 Correct 272 ms 21432 KB Output is correct
10 Correct 269 ms 21772 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 276 ms 21548 KB Output is correct
13 Correct 175 ms 21432 KB Output is correct
14 Correct 207 ms 21328 KB Output is correct
15 Correct 118 ms 21428 KB Output is correct
16 Correct 186 ms 21432 KB Output is correct
17 Correct 276 ms 21584 KB Output is correct
18 Correct 260 ms 21528 KB Output is correct
19 Correct 90 ms 21424 KB Output is correct
20 Correct 90 ms 21428 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 128 ms 21564 KB Output is correct
25 Correct 131 ms 21484 KB Output is correct
26 Correct 131 ms 21444 KB Output is correct
27 Correct 126 ms 21428 KB Output is correct
28 Correct 129 ms 21428 KB Output is correct
29 Correct 124 ms 21424 KB Output is correct
30 Correct 134 ms 21520 KB Output is correct
31 Correct 132 ms 21532 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 5 ms 1372 KB Output is correct
37 Correct 126 ms 21840 KB Output is correct
38 Correct 126 ms 21436 KB Output is correct
39 Correct 125 ms 21588 KB Output is correct
40 Correct 126 ms 21428 KB Output is correct
41 Correct 0 ms 600 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 4 ms 1372 KB Output is correct
44 Correct 5 ms 1372 KB Output is correct
45 Correct 124 ms 21332 KB Output is correct
46 Correct 150 ms 21568 KB Output is correct
47 Correct 127 ms 21428 KB Output is correct
48 Correct 142 ms 21428 KB Output is correct
49 Correct 127 ms 21428 KB Output is correct
50 Correct 126 ms 21424 KB Output is correct
51 Correct 126 ms 21428 KB Output is correct
52 Correct 133 ms 21428 KB Output is correct
53 Correct 127 ms 21432 KB Output is correct
54 Correct 128 ms 21576 KB Output is correct
55 Correct 128 ms 21688 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 283 ms 24628 KB Output is correct
58 Correct 277 ms 24760 KB Output is correct
59 Correct 273 ms 24576 KB Output is correct
60 Correct 0 ms 344 KB Output is correct
61 Correct 0 ms 348 KB Output is correct
62 Correct 1 ms 348 KB Output is correct
63 Correct 1 ms 348 KB Output is correct
64 Correct 1 ms 348 KB Output is correct
65 Correct 0 ms 348 KB Output is correct
66 Correct 0 ms 348 KB Output is correct
67 Correct 1 ms 348 KB Output is correct
68 Correct 0 ms 348 KB Output is correct
69 Correct 0 ms 348 KB Output is correct
70 Correct 1 ms 348 KB Output is correct
71 Correct 1 ms 348 KB Output is correct
72 Correct 0 ms 348 KB Output is correct
73 Correct 0 ms 348 KB Output is correct
74 Correct 1 ms 348 KB Output is correct
75 Correct 1 ms 348 KB Output is correct
76 Correct 1 ms 348 KB Output is correct
77 Correct 1 ms 348 KB Output is correct
78 Correct 0 ms 348 KB Output is correct
79 Correct 0 ms 348 KB Output is correct
80 Correct 0 ms 364 KB Output is correct
81 Correct 0 ms 348 KB Output is correct
82 Correct 0 ms 348 KB Output is correct
83 Correct 0 ms 600 KB Output is correct
84 Correct 0 ms 348 KB Output is correct
85 Correct 0 ms 348 KB Output is correct
86 Correct 0 ms 348 KB Output is correct
87 Correct 0 ms 348 KB Output is correct
88 Correct 3 ms 860 KB Output is correct
89 Correct 6 ms 1372 KB Output is correct
90 Correct 7 ms 1464 KB Output is correct
91 Correct 40 ms 6352 KB Output is correct
92 Correct 92 ms 12480 KB Output is correct
93 Correct 218 ms 24504 KB Output is correct
94 Correct 231 ms 24500 KB Output is correct
95 Correct 235 ms 24760 KB Output is correct
96 Correct 222 ms 24500 KB Output is correct
97 Correct 209 ms 24504 KB Output is correct
98 Correct 205 ms 24748 KB Output is correct
99 Correct 167 ms 24412 KB Output is correct
100 Correct 226 ms 24504 KB Output is correct
101 Correct 238 ms 24760 KB Output is correct
102 Correct 137 ms 24504 KB Output is correct
103 Correct 230 ms 24504 KB Output is correct
104 Correct 255 ms 24504 KB Output is correct
105 Correct 143 ms 24756 KB Output is correct
106 Correct 125 ms 23996 KB Output is correct