Submission #434457

# Submission time Handle Problem Language Result Execution time Memory
434457 2021-06-21T10:27:00 Z egekabas Job Scheduling (IOI19_job) C++14
5 / 100
3000 ms 44288 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<ll, ll> pii;
typedef pair<ll, ll> pll;
ll n;
vector<ll> g[200009];
ll root;
ll ans = 0;
void spsort(vector<pii> &vec){
	ll cnt = vec.size();
	while(cnt--){
		for(ll i = 0; i < vec.size()-1; ++i){
			if(vec[i+1].ff*vec[i].ss > vec[i].ff*vec[i+1].ss)
				swap(vec[i], vec[i+1]);
		}
	}
}
pii dfs(ll v, ll 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));
	spsort(vec);
	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(ll 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;
}

Compilation message

job.cpp: In function 'void spsort(std::vector<std::pair<long long int, long long int> >&)':
job.cpp:19:19: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |   for(ll i = 0; i < vec.size()-1; ++i){
      |                 ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 4 ms 5068 KB Output is correct
5 Correct 30 ms 14672 KB Output is correct
6 Correct 61 ms 24448 KB Output is correct
7 Correct 81 ms 34252 KB Output is correct
8 Correct 107 ms 44064 KB Output is correct
9 Correct 104 ms 44168 KB Output is correct
10 Correct 106 ms 44228 KB Output is correct
11 Correct 3 ms 4940 KB Output is correct
12 Correct 108 ms 44164 KB Output is correct
13 Correct 118 ms 44160 KB Output is correct
14 Correct 137 ms 44048 KB Output is correct
15 Correct 104 ms 44052 KB Output is correct
16 Correct 106 ms 44052 KB Output is correct
17 Correct 105 ms 44288 KB Output is correct
18 Correct 111 ms 44160 KB Output is correct
19 Correct 103 ms 44152 KB Output is correct
20 Correct 102 ms 44100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Execution timed out 3066 ms 15448 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 6 ms 5048 KB Output is correct
5 Correct 275 ms 5708 KB Output is correct
6 Execution timed out 3081 ms 17784 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 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 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 4 ms 5068 KB Output is correct
5 Correct 30 ms 14672 KB Output is correct
6 Correct 61 ms 24448 KB Output is correct
7 Correct 81 ms 34252 KB Output is correct
8 Correct 107 ms 44064 KB Output is correct
9 Correct 104 ms 44168 KB Output is correct
10 Correct 106 ms 44228 KB Output is correct
11 Correct 3 ms 4940 KB Output is correct
12 Correct 108 ms 44164 KB Output is correct
13 Correct 118 ms 44160 KB Output is correct
14 Correct 137 ms 44048 KB Output is correct
15 Correct 104 ms 44052 KB Output is correct
16 Correct 106 ms 44052 KB Output is correct
17 Correct 105 ms 44288 KB Output is correct
18 Correct 111 ms 44160 KB Output is correct
19 Correct 103 ms 44152 KB Output is correct
20 Correct 102 ms 44100 KB Output is correct
21 Correct 3 ms 4940 KB Output is correct
22 Correct 3 ms 4940 KB Output is correct
23 Correct 3 ms 4940 KB Output is correct
24 Execution timed out 3066 ms 15448 KB Time limit exceeded
25 Halted 0 ms 0 KB -