답안 #284568

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
284568 2020-08-27T16:22:55 Z Pyqe Job Scheduling (IOI19_job) C++14
100 / 100
468 ms 100728 KB
#include "job.h"
#include <bits/stdc++.h>

using namespace std;

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

long long n,z=0,a[200069],wg[200069],dsu[200069],cc[200069];
vector<long long> al[200069];

struct cmp
{
	bool operator()(pair<long long,long long> x,pair<long long,long long> y)
	{
		return x.fr*y.sc<y.fr*x.sc;
	}
};

multiset<pair<long long,long long>,cmp> ms[200069];
multiset<pair<long long,long long>,cmp>::iterator it;

long long fd(long long x)
{
	if(dsu[x]!=x)
	{
		dsu[x]=fd(dsu[x]);
	}
	return dsu[x];
}

void jo(long long x,long long y)
{
	x=fd(x);
	y=fd(y);
	if(cc[x]<cc[y])
	{
		swap(x,y);
	}
	for(it=ms[y].begin();it!=ms[y].end();it++)
	{
		ms[x].insert(*it);
	}
	dsu[y]=x;
	cc[x]+=cc[y];
}

void dfs(long long x)
{
	long long i,sz=al[x].size(),l;
	
	dsu[x]=x;
	cc[x]=1;
	for(i=0;i<sz;i++)
	{
		l=al[x][i];
		dfs(l);
		jo(x,l);
	}
	for(it=ms[fd(x)].begin();it!=ms[fd(x)].end();)
	{
		if(a[x]*it->sc<=it->fr*wg[x])
		{
			break;
		}
		z-=it->fr*wg[x];
		a[x]+=it->fr;
		wg[x]+=it->sc;
		it++;
		ms[fd(x)].erase(prev(it));
	}
	ms[fd(x)].insert({a[x],wg[x]});
}

long long scheduling_cost(vector<int> pr,vector<int> wgg,vector<int> aa)
{
	long long i,sm=0;
	
	n=pr.size();
	for(i=1;i<=n;i++)
	{
		a[i]=aa[i-1];
		wg[i]=wgg[i-1];
		if(i-1)
		{
			al[pr[i-1]+1].push_back(i);
		}
	}
	dfs(1);
	for(it=ms[fd(1)].begin();it!=ms[fd(1)].end();it++)
	{
		sm+=it->fr;
		z+=it->sc*sm;
	}
	return z;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 14464 KB Output is correct
2 Correct 10 ms 14464 KB Output is correct
3 Correct 10 ms 14464 KB Output is correct
4 Correct 11 ms 14592 KB Output is correct
5 Correct 46 ms 23416 KB Output is correct
6 Correct 80 ms 32504 KB Output is correct
7 Correct 119 ms 41592 KB Output is correct
8 Correct 171 ms 50424 KB Output is correct
9 Correct 153 ms 50424 KB Output is correct
10 Correct 150 ms 50552 KB Output is correct
11 Correct 10 ms 14464 KB Output is correct
12 Correct 151 ms 50512 KB Output is correct
13 Correct 151 ms 50552 KB Output is correct
14 Correct 161 ms 50680 KB Output is correct
15 Correct 151 ms 50636 KB Output is correct
16 Correct 162 ms 50680 KB Output is correct
17 Correct 148 ms 50428 KB Output is correct
18 Correct 150 ms 50552 KB Output is correct
19 Correct 145 ms 50428 KB Output is correct
20 Correct 179 ms 59128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 14464 KB Output is correct
2 Correct 10 ms 14464 KB Output is correct
3 Correct 11 ms 14464 KB Output is correct
4 Correct 317 ms 53736 KB Output is correct
5 Correct 316 ms 53736 KB Output is correct
6 Correct 314 ms 53692 KB Output is correct
7 Correct 322 ms 53788 KB Output is correct
8 Correct 332 ms 53864 KB Output is correct
9 Correct 340 ms 53736 KB Output is correct
10 Correct 338 ms 53736 KB Output is correct
11 Correct 332 ms 53712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 14464 KB Output is correct
2 Correct 10 ms 14464 KB Output is correct
3 Correct 9 ms 14464 KB Output is correct
4 Correct 10 ms 14592 KB Output is correct
5 Correct 18 ms 16384 KB Output is correct
6 Correct 304 ms 54376 KB Output is correct
7 Correct 305 ms 54248 KB Output is correct
8 Correct 306 ms 54376 KB Output is correct
9 Correct 300 ms 54388 KB Output is correct
10 Correct 10 ms 14464 KB Output is correct
11 Correct 11 ms 14720 KB Output is correct
12 Correct 17 ms 16128 KB Output is correct
13 Correct 19 ms 16384 KB Output is correct
14 Correct 313 ms 54432 KB Output is correct
15 Correct 303 ms 54248 KB Output is correct
16 Correct 307 ms 54380 KB Output is correct
17 Correct 314 ms 54248 KB Output is correct
18 Correct 316 ms 54248 KB Output is correct
19 Correct 306 ms 54248 KB Output is correct
20 Correct 316 ms 54248 KB Output is correct
21 Correct 305 ms 54376 KB Output is correct
22 Correct 303 ms 54336 KB Output is correct
23 Correct 340 ms 54400 KB Output is correct
24 Correct 316 ms 54376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 14496 KB Output is correct
2 Correct 157 ms 42796 KB Output is correct
3 Correct 169 ms 42616 KB Output is correct
4 Correct 150 ms 42616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 14464 KB Output is correct
2 Correct 10 ms 14488 KB Output is correct
3 Correct 11 ms 14464 KB Output is correct
4 Correct 11 ms 14464 KB Output is correct
5 Correct 10 ms 14464 KB Output is correct
6 Correct 11 ms 14464 KB Output is correct
7 Correct 10 ms 14464 KB Output is correct
8 Correct 11 ms 14464 KB Output is correct
9 Correct 10 ms 14464 KB Output is correct
10 Correct 10 ms 14464 KB Output is correct
11 Correct 10 ms 14464 KB Output is correct
12 Correct 10 ms 14464 KB Output is correct
13 Correct 10 ms 14464 KB Output is correct
14 Correct 10 ms 14464 KB Output is correct
15 Correct 10 ms 14464 KB Output is correct
16 Correct 10 ms 14464 KB Output is correct
17 Correct 10 ms 14464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 14464 KB Output is correct
2 Correct 10 ms 14464 KB Output is correct
3 Correct 10 ms 14464 KB Output is correct
4 Correct 11 ms 14592 KB Output is correct
5 Correct 46 ms 23416 KB Output is correct
6 Correct 80 ms 32504 KB Output is correct
7 Correct 119 ms 41592 KB Output is correct
8 Correct 171 ms 50424 KB Output is correct
9 Correct 153 ms 50424 KB Output is correct
10 Correct 150 ms 50552 KB Output is correct
11 Correct 10 ms 14464 KB Output is correct
12 Correct 151 ms 50512 KB Output is correct
13 Correct 151 ms 50552 KB Output is correct
14 Correct 161 ms 50680 KB Output is correct
15 Correct 151 ms 50636 KB Output is correct
16 Correct 162 ms 50680 KB Output is correct
17 Correct 148 ms 50428 KB Output is correct
18 Correct 150 ms 50552 KB Output is correct
19 Correct 145 ms 50428 KB Output is correct
20 Correct 179 ms 59128 KB Output is correct
21 Correct 9 ms 14464 KB Output is correct
22 Correct 10 ms 14464 KB Output is correct
23 Correct 11 ms 14464 KB Output is correct
24 Correct 317 ms 53736 KB Output is correct
25 Correct 316 ms 53736 KB Output is correct
26 Correct 314 ms 53692 KB Output is correct
27 Correct 322 ms 53788 KB Output is correct
28 Correct 332 ms 53864 KB Output is correct
29 Correct 340 ms 53736 KB Output is correct
30 Correct 338 ms 53736 KB Output is correct
31 Correct 332 ms 53712 KB Output is correct
32 Correct 9 ms 14464 KB Output is correct
33 Correct 10 ms 14464 KB Output is correct
34 Correct 9 ms 14464 KB Output is correct
35 Correct 10 ms 14592 KB Output is correct
36 Correct 18 ms 16384 KB Output is correct
37 Correct 304 ms 54376 KB Output is correct
38 Correct 305 ms 54248 KB Output is correct
39 Correct 306 ms 54376 KB Output is correct
40 Correct 300 ms 54388 KB Output is correct
41 Correct 10 ms 14464 KB Output is correct
42 Correct 11 ms 14720 KB Output is correct
43 Correct 17 ms 16128 KB Output is correct
44 Correct 19 ms 16384 KB Output is correct
45 Correct 313 ms 54432 KB Output is correct
46 Correct 303 ms 54248 KB Output is correct
47 Correct 307 ms 54380 KB Output is correct
48 Correct 314 ms 54248 KB Output is correct
49 Correct 316 ms 54248 KB Output is correct
50 Correct 306 ms 54248 KB Output is correct
51 Correct 316 ms 54248 KB Output is correct
52 Correct 305 ms 54376 KB Output is correct
53 Correct 303 ms 54336 KB Output is correct
54 Correct 340 ms 54400 KB Output is correct
55 Correct 316 ms 54376 KB Output is correct
56 Correct 11 ms 14496 KB Output is correct
57 Correct 157 ms 42796 KB Output is correct
58 Correct 169 ms 42616 KB Output is correct
59 Correct 150 ms 42616 KB Output is correct
60 Correct 10 ms 14464 KB Output is correct
61 Correct 10 ms 14488 KB Output is correct
62 Correct 11 ms 14464 KB Output is correct
63 Correct 11 ms 14464 KB Output is correct
64 Correct 10 ms 14464 KB Output is correct
65 Correct 11 ms 14464 KB Output is correct
66 Correct 10 ms 14464 KB Output is correct
67 Correct 11 ms 14464 KB Output is correct
68 Correct 10 ms 14464 KB Output is correct
69 Correct 10 ms 14464 KB Output is correct
70 Correct 10 ms 14464 KB Output is correct
71 Correct 10 ms 14464 KB Output is correct
72 Correct 10 ms 14464 KB Output is correct
73 Correct 10 ms 14464 KB Output is correct
74 Correct 10 ms 14464 KB Output is correct
75 Correct 10 ms 14464 KB Output is correct
76 Correct 10 ms 14464 KB Output is correct
77 Correct 9 ms 14464 KB Output is correct
78 Correct 9 ms 14464 KB Output is correct
79 Correct 10 ms 14464 KB Output is correct
80 Correct 12 ms 14464 KB Output is correct
81 Correct 10 ms 14464 KB Output is correct
82 Correct 10 ms 14464 KB Output is correct
83 Correct 9 ms 14496 KB Output is correct
84 Correct 12 ms 14464 KB Output is correct
85 Correct 10 ms 14464 KB Output is correct
86 Correct 10 ms 14464 KB Output is correct
87 Correct 10 ms 14464 KB Output is correct
88 Correct 16 ms 15616 KB Output is correct
89 Correct 19 ms 16384 KB Output is correct
90 Correct 24 ms 16888 KB Output is correct
91 Correct 87 ms 28344 KB Output is correct
92 Correct 185 ms 43060 KB Output is correct
93 Correct 347 ms 72184 KB Output is correct
94 Correct 369 ms 73208 KB Output is correct
95 Correct 380 ms 73208 KB Output is correct
96 Correct 358 ms 72696 KB Output is correct
97 Correct 356 ms 73124 KB Output is correct
98 Correct 368 ms 77560 KB Output is correct
99 Correct 397 ms 82936 KB Output is correct
100 Correct 379 ms 72568 KB Output is correct
101 Correct 296 ms 61724 KB Output is correct
102 Correct 468 ms 100728 KB Output is correct
103 Correct 316 ms 61304 KB Output is correct
104 Correct 281 ms 53880 KB Output is correct
105 Correct 209 ms 49144 KB Output is correct
106 Correct 378 ms 66936 KB Output is correct