제출 #434475

#제출 시각아이디문제언어결과실행 시간메모리
434475egekabasJob Scheduling (IOI19_job)C++14
24 / 100
328 ms29324 KiB
#include "job.h"
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef pair<ll, ll> pll;
ll n;
vector<ll> g[200009];

long long scheduling_cost(std::vector<int> p, std::vector<int> u, std::vector<int> d) {
	n = p.size();
	set<pair<ld, ll>> s;
	for(ll i = 0; i < n; ++i){
		if(p[i] == -1)
			s.insert({0, i});
		else
			g[p[i]].pb(i);
	}
	ll ans = 0;
	ll curt = 0;
	while(s.size()){
		ll v = s.begin()->ss;
		s.erase(s.begin());
		curt += d[v];
		ans += curt*u[v];
		for(auto nxt : g[v])
			s.insert({ld(d[nxt])/ld(u[nxt]) , nxt});
	}
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...