Submission #464772

# Submission time Handle Problem Language Result Execution time Memory
464772 2021-08-14T02:48:11 Z HappyPacMan Job Scheduling (IOI19_job) C++14
12 / 100
223 ms 12104 KB
#include "job.h"
#include <bits/stdc++.h>
using namespace std;

const int N = 2e5 + 13;
int dsu[N];

int ufds(int u){
	return dsu[u] = u == dsu[u] ? u : ufds(dsu[u]);
}

struct Comp{
	const bool operator() (tuple<int,int,int> a,tuple<int,int,int> b){
		return get<0>(a)*get<1>(b) < get<1>(a)*get<0>(b);
	}
};

long long scheduling_cost(vector<int> p,vector<int> u,vector<int> d){
	int n = p.size();
	iota(dsu,dsu+n,0);
	long long cost = 0;
	for(int i=0;i<n;i++) cost += u[i] * 1LL * d[i];
	priority_queue<tuple<int,int,int>,vector<tuple<int,int,int> >,Comp> pq;
	for(int i=0;i<n;i++) pq.emplace(u[i],d[i],i);
	while(!pq.empty()){
		auto curr = pq.top();
		int ux = get<0>(curr);
		int id = get<2>(curr);
		pq.pop();
		if(ux != u[id]) continue;
		if(id){
			int pr = ufds(p[id]);
			cost += u[id] * 1LL * d[pr];
			dsu[id] = pr;
			u[pr] += u[id];
			d[pr] += d[id];
			pq.emplace(u[pr],d[pr],pr);
		}
	}
	return cost;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 40 ms 2480 KB Output is correct
6 Correct 87 ms 4644 KB Output is correct
7 Correct 136 ms 7612 KB Output is correct
8 Correct 186 ms 12092 KB Output is correct
9 Correct 200 ms 12068 KB Output is correct
10 Correct 198 ms 12076 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 197 ms 12072 KB Output is correct
13 Correct 191 ms 12092 KB Output is correct
14 Correct 207 ms 12060 KB Output is correct
15 Correct 162 ms 12080 KB Output is correct
16 Correct 162 ms 12064 KB Output is correct
17 Correct 223 ms 12076 KB Output is correct
18 Correct 198 ms 12088 KB Output is correct
19 Correct 152 ms 12104 KB Output is correct
20 Correct 150 ms 12092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 161 ms 8888 KB Output is correct
5 Correct 158 ms 10680 KB Output is correct
6 Correct 155 ms 10676 KB Output is correct
7 Correct 158 ms 10724 KB Output is correct
8 Correct 159 ms 10684 KB Output is correct
9 Correct 169 ms 10692 KB Output is correct
10 Correct 167 ms 10660 KB Output is correct
11 Correct 166 ms 10672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 211 ms 8916 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 40 ms 2480 KB Output is correct
6 Correct 87 ms 4644 KB Output is correct
7 Correct 136 ms 7612 KB Output is correct
8 Correct 186 ms 12092 KB Output is correct
9 Correct 200 ms 12068 KB Output is correct
10 Correct 198 ms 12076 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 197 ms 12072 KB Output is correct
13 Correct 191 ms 12092 KB Output is correct
14 Correct 207 ms 12060 KB Output is correct
15 Correct 162 ms 12080 KB Output is correct
16 Correct 162 ms 12064 KB Output is correct
17 Correct 223 ms 12076 KB Output is correct
18 Correct 198 ms 12088 KB Output is correct
19 Correct 152 ms 12104 KB Output is correct
20 Correct 150 ms 12092 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 161 ms 8888 KB Output is correct
25 Correct 158 ms 10680 KB Output is correct
26 Correct 155 ms 10676 KB Output is correct
27 Correct 158 ms 10724 KB Output is correct
28 Correct 159 ms 10684 KB Output is correct
29 Correct 169 ms 10692 KB Output is correct
30 Correct 167 ms 10660 KB Output is correct
31 Correct 166 ms 10672 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 0 ms 204 KB Output is correct
34 Incorrect 0 ms 204 KB Output isn't correct
35 Halted 0 ms 0 KB -