Submission #434490

# Submission time Handle Problem Language Result Execution time Memory
434490 2021-06-21T11:08:12 Z egekabas Job Scheduling (IOI19_job) C++14
12 / 100
318 ms 37944 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 long double ld;
typedef pair<ll, ll> pii;
typedef pair<ll, ll> pll;
vector<vector<ll>> g;
void calcval(int v, int curc, int curt, vector<int> &c, vector<int> &t, vector<ld> &val){
	curc += c[v];
	curt += t[v];
	val[v] = ld(curt)/ld(curc);
	for(auto u : g[v]){
		calcval(u, curc, curt, c, t, val);
		val[v] = min(val[v], val[u]);
	}
}
long long scheduling_cost(std::vector<int> p, std::vector<int> u, std::vector<int> d) {
	ll n = p.size();
	g = vector<vector<ll>>(n);
	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);
	}
	vector<ld> val(n);
	calcval(s.begin()->ss, 0, 0, u, d, val);
	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({val[nxt] , nxt});
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 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 460 KB Output is correct
5 Correct 28 ms 9640 KB Output is correct
6 Correct 55 ms 18984 KB Output is correct
7 Correct 82 ms 28424 KB Output is correct
8 Correct 112 ms 37828 KB Output is correct
9 Correct 134 ms 37816 KB Output is correct
10 Correct 110 ms 37808 KB Output is correct
11 Correct 1 ms 260 KB Output is correct
12 Correct 111 ms 37816 KB Output is correct
13 Correct 123 ms 37808 KB Output is correct
14 Correct 129 ms 37944 KB Output is correct
15 Correct 114 ms 37800 KB Output is correct
16 Correct 111 ms 37816 KB Output is correct
17 Correct 111 ms 37836 KB Output is correct
18 Correct 107 ms 37864 KB Output is correct
19 Correct 134 ms 37820 KB Output is correct
20 Correct 112 ms 37936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 283 ms 29996 KB Output is correct
5 Correct 318 ms 29980 KB Output is correct
6 Correct 283 ms 30048 KB Output is correct
7 Correct 292 ms 30016 KB Output is correct
8 Correct 274 ms 30260 KB Output is correct
9 Correct 294 ms 29976 KB Output is correct
10 Correct 268 ms 29992 KB Output is correct
11 Correct 275 ms 29992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 105 ms 28344 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 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 460 KB Output is correct
5 Correct 28 ms 9640 KB Output is correct
6 Correct 55 ms 18984 KB Output is correct
7 Correct 82 ms 28424 KB Output is correct
8 Correct 112 ms 37828 KB Output is correct
9 Correct 134 ms 37816 KB Output is correct
10 Correct 110 ms 37808 KB Output is correct
11 Correct 1 ms 260 KB Output is correct
12 Correct 111 ms 37816 KB Output is correct
13 Correct 123 ms 37808 KB Output is correct
14 Correct 129 ms 37944 KB Output is correct
15 Correct 114 ms 37800 KB Output is correct
16 Correct 111 ms 37816 KB Output is correct
17 Correct 111 ms 37836 KB Output is correct
18 Correct 107 ms 37864 KB Output is correct
19 Correct 134 ms 37820 KB Output is correct
20 Correct 112 ms 37936 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 283 ms 29996 KB Output is correct
25 Correct 318 ms 29980 KB Output is correct
26 Correct 283 ms 30048 KB Output is correct
27 Correct 292 ms 30016 KB Output is correct
28 Correct 274 ms 30260 KB Output is correct
29 Correct 294 ms 29976 KB Output is correct
30 Correct 268 ms 29992 KB Output is correct
31 Correct 275 ms 29992 KB Output is correct
32 Incorrect 1 ms 204 KB Output isn't correct
33 Halted 0 ms 0 KB -