# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
284332 |
2020-08-27T08:51:53 Z |
Pyqe |
Job Scheduling (IOI19_job) |
C++14 |
|
187 ms |
36476 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];
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])
{
bd(l);
dp[x]=min(dp[x],dp[l]);
}
}
}
bool cmp2(long long x,long long y)
{
return mp(dp[x],x)<mp(dp[y],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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4992 KB |
Output is correct |
2 |
Correct |
3 ms |
4992 KB |
Output is correct |
3 |
Correct |
3 ms |
4992 KB |
Output is correct |
4 |
Correct |
4 ms |
5248 KB |
Output is correct |
5 |
Correct |
40 ms |
12928 KB |
Output is correct |
6 |
Correct |
87 ms |
20728 KB |
Output is correct |
7 |
Correct |
123 ms |
28536 KB |
Output is correct |
8 |
Correct |
164 ms |
36472 KB |
Output is correct |
9 |
Correct |
166 ms |
36344 KB |
Output is correct |
10 |
Correct |
176 ms |
36472 KB |
Output is correct |
11 |
Correct |
4 ms |
4992 KB |
Output is correct |
12 |
Correct |
161 ms |
36364 KB |
Output is correct |
13 |
Correct |
158 ms |
36332 KB |
Output is correct |
14 |
Correct |
176 ms |
36344 KB |
Output is correct |
15 |
Correct |
169 ms |
36344 KB |
Output is correct |
16 |
Correct |
146 ms |
36364 KB |
Output is correct |
17 |
Correct |
162 ms |
36476 KB |
Output is correct |
18 |
Correct |
160 ms |
36364 KB |
Output is correct |
19 |
Correct |
137 ms |
36420 KB |
Output is correct |
20 |
Correct |
137 ms |
36344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4992 KB |
Output is correct |
2 |
Correct |
3 ms |
4992 KB |
Output is correct |
3 |
Correct |
4 ms |
4992 KB |
Output is correct |
4 |
Correct |
140 ms |
19332 KB |
Output is correct |
5 |
Correct |
140 ms |
19304 KB |
Output is correct |
6 |
Correct |
159 ms |
19264 KB |
Output is correct |
7 |
Correct |
142 ms |
19304 KB |
Output is correct |
8 |
Correct |
146 ms |
19304 KB |
Output is correct |
9 |
Correct |
141 ms |
19304 KB |
Output is correct |
10 |
Correct |
143 ms |
19304 KB |
Output is correct |
11 |
Correct |
146 ms |
19304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4992 KB |
Output is correct |
2 |
Correct |
3 ms |
4992 KB |
Output is correct |
3 |
Correct |
3 ms |
4992 KB |
Output is correct |
4 |
Correct |
4 ms |
5120 KB |
Output is correct |
5 |
Correct |
10 ms |
5888 KB |
Output is correct |
6 |
Correct |
152 ms |
19304 KB |
Output is correct |
7 |
Correct |
153 ms |
19304 KB |
Output is correct |
8 |
Correct |
157 ms |
19432 KB |
Output is correct |
9 |
Correct |
155 ms |
19304 KB |
Output is correct |
10 |
Correct |
3 ms |
4992 KB |
Output is correct |
11 |
Correct |
4 ms |
5120 KB |
Output is correct |
12 |
Correct |
9 ms |
5760 KB |
Output is correct |
13 |
Correct |
10 ms |
5888 KB |
Output is correct |
14 |
Correct |
179 ms |
19304 KB |
Output is correct |
15 |
Correct |
162 ms |
19304 KB |
Output is correct |
16 |
Correct |
173 ms |
19304 KB |
Output is correct |
17 |
Correct |
170 ms |
19292 KB |
Output is correct |
18 |
Correct |
165 ms |
19432 KB |
Output is correct |
19 |
Correct |
187 ms |
19304 KB |
Output is correct |
20 |
Correct |
167 ms |
19304 KB |
Output is correct |
21 |
Correct |
164 ms |
19304 KB |
Output is correct |
22 |
Correct |
160 ms |
19304 KB |
Output is correct |
23 |
Correct |
159 ms |
19304 KB |
Output is correct |
24 |
Correct |
160 ms |
19304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
4992 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
4992 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4992 KB |
Output is correct |
2 |
Correct |
3 ms |
4992 KB |
Output is correct |
3 |
Correct |
3 ms |
4992 KB |
Output is correct |
4 |
Correct |
4 ms |
5248 KB |
Output is correct |
5 |
Correct |
40 ms |
12928 KB |
Output is correct |
6 |
Correct |
87 ms |
20728 KB |
Output is correct |
7 |
Correct |
123 ms |
28536 KB |
Output is correct |
8 |
Correct |
164 ms |
36472 KB |
Output is correct |
9 |
Correct |
166 ms |
36344 KB |
Output is correct |
10 |
Correct |
176 ms |
36472 KB |
Output is correct |
11 |
Correct |
4 ms |
4992 KB |
Output is correct |
12 |
Correct |
161 ms |
36364 KB |
Output is correct |
13 |
Correct |
158 ms |
36332 KB |
Output is correct |
14 |
Correct |
176 ms |
36344 KB |
Output is correct |
15 |
Correct |
169 ms |
36344 KB |
Output is correct |
16 |
Correct |
146 ms |
36364 KB |
Output is correct |
17 |
Correct |
162 ms |
36476 KB |
Output is correct |
18 |
Correct |
160 ms |
36364 KB |
Output is correct |
19 |
Correct |
137 ms |
36420 KB |
Output is correct |
20 |
Correct |
137 ms |
36344 KB |
Output is correct |
21 |
Correct |
3 ms |
4992 KB |
Output is correct |
22 |
Correct |
3 ms |
4992 KB |
Output is correct |
23 |
Correct |
4 ms |
4992 KB |
Output is correct |
24 |
Correct |
140 ms |
19332 KB |
Output is correct |
25 |
Correct |
140 ms |
19304 KB |
Output is correct |
26 |
Correct |
159 ms |
19264 KB |
Output is correct |
27 |
Correct |
142 ms |
19304 KB |
Output is correct |
28 |
Correct |
146 ms |
19304 KB |
Output is correct |
29 |
Correct |
141 ms |
19304 KB |
Output is correct |
30 |
Correct |
143 ms |
19304 KB |
Output is correct |
31 |
Correct |
146 ms |
19304 KB |
Output is correct |
32 |
Correct |
3 ms |
4992 KB |
Output is correct |
33 |
Correct |
3 ms |
4992 KB |
Output is correct |
34 |
Correct |
3 ms |
4992 KB |
Output is correct |
35 |
Correct |
4 ms |
5120 KB |
Output is correct |
36 |
Correct |
10 ms |
5888 KB |
Output is correct |
37 |
Correct |
152 ms |
19304 KB |
Output is correct |
38 |
Correct |
153 ms |
19304 KB |
Output is correct |
39 |
Correct |
157 ms |
19432 KB |
Output is correct |
40 |
Correct |
155 ms |
19304 KB |
Output is correct |
41 |
Correct |
3 ms |
4992 KB |
Output is correct |
42 |
Correct |
4 ms |
5120 KB |
Output is correct |
43 |
Correct |
9 ms |
5760 KB |
Output is correct |
44 |
Correct |
10 ms |
5888 KB |
Output is correct |
45 |
Correct |
179 ms |
19304 KB |
Output is correct |
46 |
Correct |
162 ms |
19304 KB |
Output is correct |
47 |
Correct |
173 ms |
19304 KB |
Output is correct |
48 |
Correct |
170 ms |
19292 KB |
Output is correct |
49 |
Correct |
165 ms |
19432 KB |
Output is correct |
50 |
Correct |
187 ms |
19304 KB |
Output is correct |
51 |
Correct |
167 ms |
19304 KB |
Output is correct |
52 |
Correct |
164 ms |
19304 KB |
Output is correct |
53 |
Correct |
160 ms |
19304 KB |
Output is correct |
54 |
Correct |
159 ms |
19304 KB |
Output is correct |
55 |
Correct |
160 ms |
19304 KB |
Output is correct |
56 |
Incorrect |
3 ms |
4992 KB |
Output isn't correct |
57 |
Halted |
0 ms |
0 KB |
- |