Submission #434450

# Submission time Handle Problem Language Result Execution time Memory
434450 2021-06-21T10:19:16 Z egekabas Job Scheduling (IOI19_job) C++14
7 / 100
94 ms 14392 KB
#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 pair<int, int> pii;
typedef pair<ll, ll> pll;
int n;
vector<int> g[200009];
int root;
ll ans = 0;
int sf(pii a, pii b){
	return a.ss*b.ff < a.ff*b.ss;
}
pii dfs(int v, int curt, vector<int> &c, vector<int> &t){
	curt += t[v];
	ans += c[v]*curt;
	//cout << v << ' ' << c[v] << ' ' << curt << '\n';
	vector<pii> vec;
	for(auto u : g[v])
		vec.pb(dfs(u, curt, c, t));
	sort(all(vec), sf);
	pii ret = {0, 0};
	for(auto u : vec){
		ans += u.ff*ret.ss;
		ret.ss += u.ss;
		ret.ff += u.ff;
	}
	ret.ss += t[v];
	ret.ff += c[v];
	return ret;
}
long long scheduling_cost(std::vector<int> p, std::vector<int> u, std::vector<int> d) {
	n = p.size();
	for(int i = 0; i < n; ++i){
		if(p[i] == -1)
			root = i;
		else
			g[p[i]].pb(i);
	}
	ans = 0;
	dfs(root, 0, u, d);
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4944 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Incorrect 3 ms 4988 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4992 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 90 ms 14356 KB Output is correct
5 Correct 90 ms 14392 KB Output is correct
6 Correct 93 ms 14328 KB Output is correct
7 Correct 91 ms 14392 KB Output is correct
8 Correct 94 ms 14392 KB Output is correct
9 Correct 90 ms 14336 KB Output is correct
10 Correct 91 ms 14348 KB Output is correct
11 Correct 90 ms 14392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4996 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 4 ms 4940 KB Output is correct
4 Incorrect 4 ms 4940 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 4940 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Incorrect 3 ms 4940 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4944 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Incorrect 3 ms 4988 KB Output isn't correct
4 Halted 0 ms 0 KB -