Submission #202383

# Submission time Handle Problem Language Result Execution time Memory
202383 2020-02-16T00:20:48 Z blackbori Job Scheduling (IOI19_job) C++14
100 / 100
302 ms 46540 KB
#include "job.h"

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

struct job{
	ll s, d;
	job(ll s, ll d) : s(s), d(d) {}
	job() {}
	bool operator < (job t) const {
		return s * t.d < d * t.s; }
};

priority_queue <job> S[202020];
vector <int> T[202020];
ll ans;

void merge(int u, int v)
{
	auto &P = S[u], &Q = S[v];
	if(P.size() < Q.size()) swap(P, Q);
	for(; !Q.empty(); Q.pop()) P.push(Q.top());
}

void insert(int i, job x)
{
	auto &P = S[i];
	for(; !P.empty(); P.pop()){
		job t = P.top();
		if(t < x) break; 
		ans += t.s * x.d;
		x.s += t.s; x.d += t.d;
	}
	P.push(x);
}

ll scheduling_cost(vector <int> P, vector <int> U, vector<int> D)
{
	int n, i;

	n = P.size();
	for(i = 0; i < n; i ++){
		if(i) T[P[i]].push_back(i);
		ans += U[i] * D[i];
	}

	for(i = n - 1; i >= 0; i --){
		for(int &t: T[i]){
			merge(i, t);
		}
		insert(i, job(U[i], D[i]));
	}

	insert(0, job(-2e9, 0));

	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 12 ms 11384 KB Output is correct
2 Correct 11 ms 11384 KB Output is correct
3 Correct 11 ms 11384 KB Output is correct
4 Correct 12 ms 11384 KB Output is correct
5 Correct 40 ms 14840 KB Output is correct
6 Correct 72 ms 18424 KB Output is correct
7 Correct 95 ms 22008 KB Output is correct
8 Correct 132 ms 25464 KB Output is correct
9 Correct 124 ms 25520 KB Output is correct
10 Correct 123 ms 25464 KB Output is correct
11 Correct 12 ms 11384 KB Output is correct
12 Correct 124 ms 25464 KB Output is correct
13 Correct 122 ms 25592 KB Output is correct
14 Correct 139 ms 25592 KB Output is correct
15 Correct 117 ms 25464 KB Output is correct
16 Correct 143 ms 25720 KB Output is correct
17 Correct 125 ms 25464 KB Output is correct
18 Correct 122 ms 25592 KB Output is correct
19 Correct 122 ms 25592 KB Output is correct
20 Correct 143 ms 29800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 11384 KB Output is correct
2 Correct 12 ms 11384 KB Output is correct
3 Correct 11 ms 11388 KB Output is correct
4 Correct 158 ms 29240 KB Output is correct
5 Correct 144 ms 29156 KB Output is correct
6 Correct 147 ms 29156 KB Output is correct
7 Correct 146 ms 29176 KB Output is correct
8 Correct 142 ms 29284 KB Output is correct
9 Correct 152 ms 29092 KB Output is correct
10 Correct 145 ms 29160 KB Output is correct
11 Correct 147 ms 29288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 11384 KB Output is correct
2 Correct 11 ms 11384 KB Output is correct
3 Correct 12 ms 11384 KB Output is correct
4 Correct 12 ms 11444 KB Output is correct
5 Correct 18 ms 12536 KB Output is correct
6 Correct 154 ms 29796 KB Output is correct
7 Correct 160 ms 29664 KB Output is correct
8 Correct 157 ms 29672 KB Output is correct
9 Correct 161 ms 29668 KB Output is correct
10 Correct 11 ms 11384 KB Output is correct
11 Correct 12 ms 11544 KB Output is correct
12 Correct 17 ms 12408 KB Output is correct
13 Correct 18 ms 12412 KB Output is correct
14 Correct 152 ms 29668 KB Output is correct
15 Correct 156 ms 29776 KB Output is correct
16 Correct 149 ms 29796 KB Output is correct
17 Correct 151 ms 29672 KB Output is correct
18 Correct 152 ms 29668 KB Output is correct
19 Correct 151 ms 29736 KB Output is correct
20 Correct 154 ms 29676 KB Output is correct
21 Correct 153 ms 29672 KB Output is correct
22 Correct 152 ms 29672 KB Output is correct
23 Correct 151 ms 29668 KB Output is correct
24 Correct 157 ms 29672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 11384 KB Output is correct
2 Correct 122 ms 25464 KB Output is correct
3 Correct 133 ms 25560 KB Output is correct
4 Correct 128 ms 25592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 11384 KB Output is correct
2 Correct 11 ms 11384 KB Output is correct
3 Correct 12 ms 11384 KB Output is correct
4 Correct 12 ms 11384 KB Output is correct
5 Correct 11 ms 11384 KB Output is correct
6 Correct 11 ms 11384 KB Output is correct
7 Correct 12 ms 11384 KB Output is correct
8 Correct 12 ms 11384 KB Output is correct
9 Correct 11 ms 11384 KB Output is correct
10 Correct 11 ms 11384 KB Output is correct
11 Correct 11 ms 11384 KB Output is correct
12 Correct 12 ms 11384 KB Output is correct
13 Correct 12 ms 11388 KB Output is correct
14 Correct 11 ms 11384 KB Output is correct
15 Correct 11 ms 11384 KB Output is correct
16 Correct 11 ms 11512 KB Output is correct
17 Correct 11 ms 11384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 11384 KB Output is correct
2 Correct 11 ms 11384 KB Output is correct
3 Correct 11 ms 11384 KB Output is correct
4 Correct 12 ms 11384 KB Output is correct
5 Correct 40 ms 14840 KB Output is correct
6 Correct 72 ms 18424 KB Output is correct
7 Correct 95 ms 22008 KB Output is correct
8 Correct 132 ms 25464 KB Output is correct
9 Correct 124 ms 25520 KB Output is correct
10 Correct 123 ms 25464 KB Output is correct
11 Correct 12 ms 11384 KB Output is correct
12 Correct 124 ms 25464 KB Output is correct
13 Correct 122 ms 25592 KB Output is correct
14 Correct 139 ms 25592 KB Output is correct
15 Correct 117 ms 25464 KB Output is correct
16 Correct 143 ms 25720 KB Output is correct
17 Correct 125 ms 25464 KB Output is correct
18 Correct 122 ms 25592 KB Output is correct
19 Correct 122 ms 25592 KB Output is correct
20 Correct 143 ms 29800 KB Output is correct
21 Correct 12 ms 11384 KB Output is correct
22 Correct 12 ms 11384 KB Output is correct
23 Correct 11 ms 11388 KB Output is correct
24 Correct 158 ms 29240 KB Output is correct
25 Correct 144 ms 29156 KB Output is correct
26 Correct 147 ms 29156 KB Output is correct
27 Correct 146 ms 29176 KB Output is correct
28 Correct 142 ms 29284 KB Output is correct
29 Correct 152 ms 29092 KB Output is correct
30 Correct 145 ms 29160 KB Output is correct
31 Correct 147 ms 29288 KB Output is correct
32 Correct 11 ms 11384 KB Output is correct
33 Correct 11 ms 11384 KB Output is correct
34 Correct 12 ms 11384 KB Output is correct
35 Correct 12 ms 11444 KB Output is correct
36 Correct 18 ms 12536 KB Output is correct
37 Correct 154 ms 29796 KB Output is correct
38 Correct 160 ms 29664 KB Output is correct
39 Correct 157 ms 29672 KB Output is correct
40 Correct 161 ms 29668 KB Output is correct
41 Correct 11 ms 11384 KB Output is correct
42 Correct 12 ms 11544 KB Output is correct
43 Correct 17 ms 12408 KB Output is correct
44 Correct 18 ms 12412 KB Output is correct
45 Correct 152 ms 29668 KB Output is correct
46 Correct 156 ms 29776 KB Output is correct
47 Correct 149 ms 29796 KB Output is correct
48 Correct 151 ms 29672 KB Output is correct
49 Correct 152 ms 29668 KB Output is correct
50 Correct 151 ms 29736 KB Output is correct
51 Correct 154 ms 29676 KB Output is correct
52 Correct 153 ms 29672 KB Output is correct
53 Correct 152 ms 29672 KB Output is correct
54 Correct 151 ms 29668 KB Output is correct
55 Correct 157 ms 29672 KB Output is correct
56 Correct 11 ms 11384 KB Output is correct
57 Correct 122 ms 25464 KB Output is correct
58 Correct 133 ms 25560 KB Output is correct
59 Correct 128 ms 25592 KB Output is correct
60 Correct 11 ms 11384 KB Output is correct
61 Correct 11 ms 11384 KB Output is correct
62 Correct 12 ms 11384 KB Output is correct
63 Correct 12 ms 11384 KB Output is correct
64 Correct 11 ms 11384 KB Output is correct
65 Correct 11 ms 11384 KB Output is correct
66 Correct 12 ms 11384 KB Output is correct
67 Correct 12 ms 11384 KB Output is correct
68 Correct 11 ms 11384 KB Output is correct
69 Correct 11 ms 11384 KB Output is correct
70 Correct 11 ms 11384 KB Output is correct
71 Correct 12 ms 11384 KB Output is correct
72 Correct 12 ms 11388 KB Output is correct
73 Correct 11 ms 11384 KB Output is correct
74 Correct 11 ms 11384 KB Output is correct
75 Correct 11 ms 11512 KB Output is correct
76 Correct 11 ms 11384 KB Output is correct
77 Correct 11 ms 11384 KB Output is correct
78 Correct 10 ms 11512 KB Output is correct
79 Correct 11 ms 11384 KB Output is correct
80 Correct 11 ms 11384 KB Output is correct
81 Correct 11 ms 11384 KB Output is correct
82 Correct 11 ms 11384 KB Output is correct
83 Correct 11 ms 11384 KB Output is correct
84 Correct 11 ms 11384 KB Output is correct
85 Correct 11 ms 11384 KB Output is correct
86 Correct 11 ms 11384 KB Output is correct
87 Correct 11 ms 11328 KB Output is correct
88 Correct 17 ms 12024 KB Output is correct
89 Correct 18 ms 12280 KB Output is correct
90 Correct 19 ms 12536 KB Output is correct
91 Correct 54 ms 17656 KB Output is correct
92 Correct 114 ms 24048 KB Output is correct
93 Correct 237 ms 36448 KB Output is correct
94 Correct 234 ms 37488 KB Output is correct
95 Correct 234 ms 37096 KB Output is correct
96 Correct 234 ms 37096 KB Output is correct
97 Correct 238 ms 37864 KB Output is correct
98 Correct 228 ms 38460 KB Output is correct
99 Correct 262 ms 43368 KB Output is correct
100 Correct 253 ms 37220 KB Output is correct
101 Correct 192 ms 33092 KB Output is correct
102 Correct 302 ms 46540 KB Output is correct
103 Correct 214 ms 32748 KB Output is correct
104 Correct 183 ms 30700 KB Output is correct
105 Correct 169 ms 28616 KB Output is correct
106 Correct 189 ms 34024 KB Output is correct