답안 #284329

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
284329 2020-08-27T08:48:30 Z Pyqe Job Scheduling (IOI19_job) C++14
24 / 100
181 ms 41352 KB
#include "job.h"
#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define fr first
#define sc second

long long n,as[200069],pst[200069],dp[200069],dh[200069];
pair<long long,long long> a[200069];
vector<long long> al[200069];
bitset<200069> vtd;

bool cmp(long long x,long long y)
{
	return a[x].fr*a[y].sc<a[y].fr*a[x].sc;
}

void bd(long long x)
{
	long long i,sz=al[x].size(),l;
	
	vtd[x]=1;
	dp[x]=pst[x];
	for(i=0;i<sz;i++)
	{
		l=al[x][i];
		if(!vtd[l])
		{
			dh[l]=dh[x]+1;
			bd(l);
			dp[x]=min(dp[x],dp[l]);
		}
	}
}

bool cmp2(long long x,long long y)
{
	return mp(dp[x],dh[x])<mp(dp[y],dh[y]);
}

long long scheduling_cost(vector<int> p,vector<int> u,vector<int> d)
{
	long long i,sm=0,z=0;
	
	n=p.size();
	for(i=1;i<=n;i++)
	{
		as[i]=i;
		a[i]={d[i-1],u[i-1]};
		if(i-1)
		{
			al[p[i-1]+1].push_back(i);
		}
	}
	sort(as+1,as+n+1,cmp);
	for(i=1;i<=n;i++)
	{
		pst[as[i]]=i;
		as[i]=i;
	}
	bd(1);
	sort(as+1,as+n+1,cmp2);
	for(i=1;i<=n;i++)
	{
		sm+=a[as[i]].fr;
		z+=a[as[i]].sc*sm;
	}
	return z;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4992 KB Output is correct
2 Correct 3 ms 4992 KB Output is correct
3 Correct 4 ms 5120 KB Output is correct
4 Correct 4 ms 5248 KB Output is correct
5 Correct 40 ms 14072 KB Output is correct
6 Correct 76 ms 23032 KB Output is correct
7 Correct 111 ms 32124 KB Output is correct
8 Correct 158 ms 41208 KB Output is correct
9 Correct 158 ms 41080 KB Output is correct
10 Correct 154 ms 41208 KB Output is correct
11 Correct 4 ms 5120 KB Output is correct
12 Correct 154 ms 41232 KB Output is correct
13 Correct 149 ms 41080 KB Output is correct
14 Correct 148 ms 41080 KB Output is correct
15 Correct 140 ms 41080 KB Output is correct
16 Correct 141 ms 41080 KB Output is correct
17 Correct 151 ms 41080 KB Output is correct
18 Correct 159 ms 41080 KB Output is correct
19 Correct 133 ms 41352 KB Output is correct
20 Correct 141 ms 41080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4992 KB Output is correct
2 Correct 3 ms 4992 KB Output is correct
3 Correct 4 ms 5120 KB Output is correct
4 Correct 166 ms 22632 KB Output is correct
5 Correct 142 ms 22632 KB Output is correct
6 Correct 143 ms 22632 KB Output is correct
7 Correct 157 ms 22632 KB Output is correct
8 Correct 159 ms 22764 KB Output is correct
9 Correct 146 ms 22632 KB Output is correct
10 Correct 148 ms 22760 KB Output is correct
11 Correct 154 ms 22632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4992 KB Output is correct
2 Correct 4 ms 5120 KB Output is correct
3 Correct 4 ms 5120 KB Output is correct
4 Correct 4 ms 5120 KB Output is correct
5 Correct 10 ms 6144 KB Output is correct
6 Correct 159 ms 23168 KB Output is correct
7 Correct 161 ms 23144 KB Output is correct
8 Correct 154 ms 23116 KB Output is correct
9 Correct 159 ms 23284 KB Output is correct
10 Correct 4 ms 5120 KB Output is correct
11 Correct 6 ms 5248 KB Output is correct
12 Correct 9 ms 6016 KB Output is correct
13 Correct 10 ms 6144 KB Output is correct
14 Correct 181 ms 23144 KB Output is correct
15 Correct 159 ms 23272 KB Output is correct
16 Correct 158 ms 23124 KB Output is correct
17 Correct 163 ms 23144 KB Output is correct
18 Correct 169 ms 23276 KB Output is correct
19 Correct 152 ms 23144 KB Output is correct
20 Correct 154 ms 23272 KB Output is correct
21 Correct 157 ms 23144 KB Output is correct
22 Correct 162 ms 23272 KB Output is correct
23 Correct 153 ms 23144 KB Output is correct
24 Correct 156 ms 23144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 4992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 5120 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4992 KB Output is correct
2 Correct 3 ms 4992 KB Output is correct
3 Correct 4 ms 5120 KB Output is correct
4 Correct 4 ms 5248 KB Output is correct
5 Correct 40 ms 14072 KB Output is correct
6 Correct 76 ms 23032 KB Output is correct
7 Correct 111 ms 32124 KB Output is correct
8 Correct 158 ms 41208 KB Output is correct
9 Correct 158 ms 41080 KB Output is correct
10 Correct 154 ms 41208 KB Output is correct
11 Correct 4 ms 5120 KB Output is correct
12 Correct 154 ms 41232 KB Output is correct
13 Correct 149 ms 41080 KB Output is correct
14 Correct 148 ms 41080 KB Output is correct
15 Correct 140 ms 41080 KB Output is correct
16 Correct 141 ms 41080 KB Output is correct
17 Correct 151 ms 41080 KB Output is correct
18 Correct 159 ms 41080 KB Output is correct
19 Correct 133 ms 41352 KB Output is correct
20 Correct 141 ms 41080 KB Output is correct
21 Correct 4 ms 4992 KB Output is correct
22 Correct 3 ms 4992 KB Output is correct
23 Correct 4 ms 5120 KB Output is correct
24 Correct 166 ms 22632 KB Output is correct
25 Correct 142 ms 22632 KB Output is correct
26 Correct 143 ms 22632 KB Output is correct
27 Correct 157 ms 22632 KB Output is correct
28 Correct 159 ms 22764 KB Output is correct
29 Correct 146 ms 22632 KB Output is correct
30 Correct 148 ms 22760 KB Output is correct
31 Correct 154 ms 22632 KB Output is correct
32 Correct 3 ms 4992 KB Output is correct
33 Correct 4 ms 5120 KB Output is correct
34 Correct 4 ms 5120 KB Output is correct
35 Correct 4 ms 5120 KB Output is correct
36 Correct 10 ms 6144 KB Output is correct
37 Correct 159 ms 23168 KB Output is correct
38 Correct 161 ms 23144 KB Output is correct
39 Correct 154 ms 23116 KB Output is correct
40 Correct 159 ms 23284 KB Output is correct
41 Correct 4 ms 5120 KB Output is correct
42 Correct 6 ms 5248 KB Output is correct
43 Correct 9 ms 6016 KB Output is correct
44 Correct 10 ms 6144 KB Output is correct
45 Correct 181 ms 23144 KB Output is correct
46 Correct 159 ms 23272 KB Output is correct
47 Correct 158 ms 23124 KB Output is correct
48 Correct 163 ms 23144 KB Output is correct
49 Correct 169 ms 23276 KB Output is correct
50 Correct 152 ms 23144 KB Output is correct
51 Correct 154 ms 23272 KB Output is correct
52 Correct 157 ms 23144 KB Output is correct
53 Correct 162 ms 23272 KB Output is correct
54 Correct 153 ms 23144 KB Output is correct
55 Correct 156 ms 23144 KB Output is correct
56 Incorrect 3 ms 4992 KB Output isn't correct
57 Halted 0 ms 0 KB -