Submission #1060833

# Submission time Handle Problem Language Result Execution time Memory
1060833 2024-08-16T02:03:05 Z boyliguanhan Job Scheduling (IOI19_job) C++17
100 / 100
291 ms 21700 KB
#include "job.h"
#include <bits/stdc++.h>
using namespace std;
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{
    long long timetaken,value,i;
    DATA(long long u,long long d,int ind){
        value=u,timetaken=d,i=ind;
    }
    DATA(){
        timetaken=1e9;
        value=1;
        i=-1;
    }
    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;
long long scheduling_cost(std::vector<int> p, std::vector<int> _u, std::vector<int> _d) {
    vector<long long>u,d;
    int N=p.size();
    long long 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;
}
# Verdict Execution time Memory 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 50 ms 5576 KB Output is correct
6 Correct 107 ms 11020 KB Output is correct
7 Correct 189 ms 16052 KB Output is correct
8 Correct 291 ms 21700 KB Output is correct
9 Correct 272 ms 21428 KB Output is correct
10 Correct 276 ms 21552 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 265 ms 21428 KB Output is correct
13 Correct 178 ms 21576 KB Output is correct
14 Correct 214 ms 21332 KB Output is correct
15 Correct 116 ms 21536 KB Output is correct
16 Correct 145 ms 21388 KB Output is correct
17 Correct 268 ms 21424 KB Output is correct
18 Correct 270 ms 21568 KB Output is correct
19 Correct 91 ms 21432 KB Output is correct
20 Correct 87 ms 21432 KB Output is correct
# Verdict Execution time Memory 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 133 ms 21576 KB Output is correct
5 Correct 131 ms 21428 KB Output is correct
6 Correct 132 ms 21424 KB Output is correct
7 Correct 124 ms 21428 KB Output is correct
8 Correct 133 ms 21568 KB Output is correct
9 Correct 129 ms 21568 KB Output is correct
10 Correct 127 ms 21328 KB Output is correct
11 Correct 127 ms 21424 KB Output is correct
# Verdict Execution time Memory 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 1 ms 348 KB Output is correct
5 Correct 5 ms 1372 KB Output is correct
6 Correct 127 ms 21516 KB Output is correct
7 Correct 123 ms 21548 KB Output is correct
8 Correct 129 ms 21564 KB Output is correct
9 Correct 125 ms 21588 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 4 ms 1372 KB Output is correct
13 Correct 5 ms 1368 KB Output is correct
14 Correct 129 ms 21496 KB Output is correct
15 Correct 127 ms 21564 KB Output is correct
16 Correct 126 ms 21424 KB Output is correct
17 Correct 130 ms 21424 KB Output is correct
18 Correct 122 ms 21576 KB Output is correct
19 Correct 122 ms 21392 KB Output is correct
20 Correct 121 ms 21432 KB Output is correct
21 Correct 124 ms 21432 KB Output is correct
22 Correct 123 ms 21528 KB Output is correct
23 Correct 127 ms 21428 KB Output is correct
24 Correct 124 ms 21532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 269 ms 21344 KB Output is correct
3 Correct 271 ms 21428 KB Output is correct
4 Correct 271 ms 21432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 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 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory 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 50 ms 5576 KB Output is correct
6 Correct 107 ms 11020 KB Output is correct
7 Correct 189 ms 16052 KB Output is correct
8 Correct 291 ms 21700 KB Output is correct
9 Correct 272 ms 21428 KB Output is correct
10 Correct 276 ms 21552 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 265 ms 21428 KB Output is correct
13 Correct 178 ms 21576 KB Output is correct
14 Correct 214 ms 21332 KB Output is correct
15 Correct 116 ms 21536 KB Output is correct
16 Correct 145 ms 21388 KB Output is correct
17 Correct 268 ms 21424 KB Output is correct
18 Correct 270 ms 21568 KB Output is correct
19 Correct 91 ms 21432 KB Output is correct
20 Correct 87 ms 21432 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 133 ms 21576 KB Output is correct
25 Correct 131 ms 21428 KB Output is correct
26 Correct 132 ms 21424 KB Output is correct
27 Correct 124 ms 21428 KB Output is correct
28 Correct 133 ms 21568 KB Output is correct
29 Correct 129 ms 21568 KB Output is correct
30 Correct 127 ms 21328 KB Output is correct
31 Correct 127 ms 21424 KB Output is correct
32 Correct 0 ms 344 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 127 ms 21516 KB Output is correct
38 Correct 123 ms 21548 KB Output is correct
39 Correct 129 ms 21564 KB Output is correct
40 Correct 125 ms 21588 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 4 ms 1372 KB Output is correct
44 Correct 5 ms 1368 KB Output is correct
45 Correct 129 ms 21496 KB Output is correct
46 Correct 127 ms 21564 KB Output is correct
47 Correct 126 ms 21424 KB Output is correct
48 Correct 130 ms 21424 KB Output is correct
49 Correct 122 ms 21576 KB Output is correct
50 Correct 122 ms 21392 KB Output is correct
51 Correct 121 ms 21432 KB Output is correct
52 Correct 124 ms 21432 KB Output is correct
53 Correct 123 ms 21528 KB Output is correct
54 Correct 127 ms 21428 KB Output is correct
55 Correct 124 ms 21532 KB Output is correct
56 Correct 0 ms 348 KB Output is correct
57 Correct 269 ms 21344 KB Output is correct
58 Correct 271 ms 21428 KB Output is correct
59 Correct 271 ms 21432 KB Output is correct
60 Correct 0 ms 348 KB Output is correct
61 Correct 1 ms 348 KB Output is correct
62 Correct 0 ms 348 KB Output is correct
63 Correct 0 ms 348 KB Output is correct
64 Correct 0 ms 344 KB Output is correct
65 Correct 0 ms 348 KB Output is correct
66 Correct 0 ms 348 KB Output is correct
67 Correct 0 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 0 ms 348 KB Output is correct
71 Correct 1 ms 348 KB Output is correct
72 Correct 1 ms 348 KB Output is correct
73 Correct 0 ms 348 KB Output is correct
74 Correct 0 ms 348 KB Output is correct
75 Correct 0 ms 348 KB Output is correct
76 Correct 1 ms 348 KB Output is correct
77 Correct 0 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 348 KB Output is correct
81 Correct 0 ms 348 KB Output is correct
82 Correct 0 ms 344 KB Output is correct
83 Correct 0 ms 344 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 5 ms 1044 KB Output is correct
90 Correct 9 ms 1480 KB Output is correct
91 Correct 43 ms 5580 KB Output is correct
92 Correct 90 ms 10836 KB Output is correct
93 Correct 237 ms 21432 KB Output is correct
94 Correct 228 ms 21428 KB Output is correct
95 Correct 230 ms 21424 KB Output is correct
96 Correct 218 ms 21432 KB Output is correct
97 Correct 209 ms 21560 KB Output is correct
98 Correct 194 ms 21428 KB Output is correct
99 Correct 171 ms 21432 KB Output is correct
100 Correct 219 ms 21428 KB Output is correct
101 Correct 236 ms 21572 KB Output is correct
102 Correct 131 ms 21432 KB Output is correct
103 Correct 234 ms 21424 KB Output is correct
104 Correct 224 ms 21424 KB Output is correct
105 Correct 141 ms 21424 KB Output is correct
106 Correct 162 ms 21428 KB Output is correct