답안 #145732

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
145732 2019-08-21T04:04:32 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 1000013

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; pii rec = {0, 0};
	FOR(i, 0, SZ(a))
	{
		while(iter < SZ(b) && (rec.fi + arr[b[iter]].fi) * arr[a[i]].se < (rec.se + arr[b[iter]].se) * arr[a[i]].fi)
		{
			res.PB(b[iter]);
			rec.fi += arr[b[iter]].fi;
			rec.se += arr[b[iter]].se;
			iter++;
		}
		rec = {0, 0};
		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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 47224 KB Output is correct
2 Correct 44 ms 47352 KB Output is correct
3 Correct 44 ms 47352 KB Output is correct
4 Correct 51 ms 50724 KB Output is correct
5 Runtime error 397 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 47352 KB Output is correct
2 Correct 44 ms 47452 KB Output is correct
3 Correct 44 ms 47352 KB Output is correct
4 Execution timed out 3015 ms 60168 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 47352 KB Output is correct
2 Correct 44 ms 47224 KB Output is correct
3 Correct 44 ms 47352 KB Output is correct
4 Correct 49 ms 47356 KB Output is correct
5 Correct 408 ms 48524 KB Output is correct
6 Execution timed out 3015 ms 60760 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 44 ms 47352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 44 ms 47336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 47224 KB Output is correct
2 Correct 44 ms 47352 KB Output is correct
3 Correct 44 ms 47352 KB Output is correct
4 Correct 51 ms 50724 KB Output is correct
5 Runtime error 397 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -