Submission #145736

# Submission time Handle Problem Language Result Execution time Memory
145736 2019-08-21T04:13:57 Z qkxwsm Job Scheduling (IOI19_job) C++14
0 / 100
3000 ms 262148 KB
#include "job.h"
#include <bits/stdc++.h>

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
	if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
	if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define MAXN 200013

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

int N;
int parent[MAXN];
pll arr[MAXN];
vi edge[MAXN];
vi ord[MAXN];
ll ans = 0;

vi comb(vi a, vi b)
{
	vi res;
	int iter = 0;
	FOR(i, 0, SZ(a))
	{
		while(iter < SZ(b) && arr[b[iter]].fi * arr[a[i]].se < arr[b[iter]].se * arr[a[i]].fi)
		{
			res.PB(b[iter]);
			iter++;
		}
		res.PB(a[i]);
	}
	while(iter < SZ(b))
	{
		res.PB(b[iter]); iter++;
	}
	return res;
}

void solve(int u)
{
	for (int v : edge[u])
	{
		solve(v);
		ord[u] = comb(ord[u], ord[v]);
	}
	ord[u].PB(u);
}

ll scheduling_cost(vi p, vi u, vi d)
{
	N = SZ(p);
	// cerr << "HI\n";
	FOR(i, 0, N)
	{
		parent[i] = p[i];
		if (i == 0)
		{
			parent[i] = N;
		}
		else
		{
			edge[parent[i]].PB(i);
		}
		arr[i] = {u[i], d[i]};
		// cerr << "parent " << parent[i] << endl;
	}
	solve(0);
	reverse(ALL(ord[0]));
	ll t = 0;
	// cerr << "ORD\n";
	for (int u : ord[0])
	{
		// cerr << u << endl;
		t += arr[u].se;
		ans += t * arr[u].fi;
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 10 ms 9720 KB Output is correct
2 Correct 10 ms 9720 KB Output is correct
3 Correct 10 ms 9720 KB Output is correct
4 Correct 16 ms 13048 KB Output is correct
5 Runtime error 441 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 9720 KB Output is correct
2 Correct 10 ms 9720 KB Output is correct
3 Correct 10 ms 9720 KB Output is correct
4 Execution timed out 3026 ms 20804 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 9720 KB Output is correct
2 Correct 10 ms 9724 KB Output is correct
3 Correct 10 ms 9720 KB Output is correct
4 Correct 14 ms 9848 KB Output is correct
5 Correct 338 ms 10808 KB Output is correct
6 Execution timed out 3054 ms 20956 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 9720 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 9720 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 9720 KB Output is correct
2 Correct 10 ms 9720 KB Output is correct
3 Correct 10 ms 9720 KB Output is correct
4 Correct 16 ms 13048 KB Output is correct
5 Runtime error 441 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -