답안 #464770

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
464770 2021-08-14T02:39:20 Z HappyPacMan Job Scheduling (IOI19_job) C++14
0 / 100
73 ms 18336 KB
#include "job.h"
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 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();
	vector<int> dsu(n);
	iota(dsu.begin(),dsu.end(),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(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;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Runtime error 73 ms 18336 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -