#include "job.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define F first
#define S second
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
long long scheduling_cost(std::vector<int> p, std::vector<int> u, std::vector<int> d) {
int n = sz(p);
bool g1=true;
bool g2=true;
rep(i,1,n){
if(p[i]!=i-1)g1=false;
if(p[i]!=0)g2=false;
}
ll score = 0;
if(g1){
ll time = 0;
rep(i,0,n){
time += d[i];
score += time*u[i];
}
}else if(g2){
ll time = 0;
time += d[0];
score += time*u[0];
vi inds(n-1);iota(all(inds),1);
sort(all(inds), [&](int a, int b){
return (-u[a]*d[b])<(-u[b]*d[a]);
});
// cout<<score<<endl;
for(int j : inds){
time += d[j];
score += u[j] * time;
// cout<<score<<endl;
}
}else{
assert(false);
}
return score;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
11 ms |
1372 KB |
Output is correct |
6 |
Correct |
21 ms |
2652 KB |
Output is correct |
7 |
Correct |
31 ms |
3788 KB |
Output is correct |
8 |
Correct |
41 ms |
4948 KB |
Output is correct |
9 |
Correct |
45 ms |
4948 KB |
Output is correct |
10 |
Correct |
42 ms |
5080 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
41 ms |
4948 KB |
Output is correct |
13 |
Correct |
42 ms |
5100 KB |
Output is correct |
14 |
Correct |
41 ms |
5100 KB |
Output is correct |
15 |
Correct |
43 ms |
4948 KB |
Output is correct |
16 |
Correct |
43 ms |
4944 KB |
Output is correct |
17 |
Correct |
42 ms |
4944 KB |
Output is correct |
18 |
Correct |
42 ms |
5080 KB |
Output is correct |
19 |
Correct |
41 ms |
4948 KB |
Output is correct |
20 |
Correct |
42 ms |
5096 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
65 ms |
5852 KB |
Output is correct |
5 |
Correct |
61 ms |
5712 KB |
Output is correct |
6 |
Correct |
57 ms |
5864 KB |
Output is correct |
7 |
Correct |
58 ms |
5912 KB |
Output is correct |
8 |
Correct |
58 ms |
5720 KB |
Output is correct |
9 |
Correct |
59 ms |
5716 KB |
Output is correct |
10 |
Correct |
58 ms |
5724 KB |
Output is correct |
11 |
Correct |
58 ms |
5848 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
4 ms |
508 KB |
Output is correct |
6 |
Correct |
61 ms |
5844 KB |
Output is correct |
7 |
Correct |
70 ms |
5844 KB |
Output is correct |
8 |
Correct |
62 ms |
5848 KB |
Output is correct |
9 |
Correct |
61 ms |
5844 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
3 ms |
604 KB |
Output is correct |
13 |
Correct |
3 ms |
604 KB |
Output is correct |
14 |
Correct |
61 ms |
5916 KB |
Output is correct |
15 |
Correct |
68 ms |
5916 KB |
Output is correct |
16 |
Correct |
61 ms |
5680 KB |
Output is correct |
17 |
Correct |
63 ms |
5828 KB |
Output is correct |
18 |
Correct |
62 ms |
5848 KB |
Output is correct |
19 |
Correct |
61 ms |
5852 KB |
Output is correct |
20 |
Correct |
62 ms |
5712 KB |
Output is correct |
21 |
Correct |
66 ms |
5712 KB |
Output is correct |
22 |
Correct |
62 ms |
5724 KB |
Output is correct |
23 |
Correct |
63 ms |
5712 KB |
Output is correct |
24 |
Correct |
61 ms |
5848 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
11 ms |
1372 KB |
Output is correct |
6 |
Correct |
21 ms |
2652 KB |
Output is correct |
7 |
Correct |
31 ms |
3788 KB |
Output is correct |
8 |
Correct |
41 ms |
4948 KB |
Output is correct |
9 |
Correct |
45 ms |
4948 KB |
Output is correct |
10 |
Correct |
42 ms |
5080 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
41 ms |
4948 KB |
Output is correct |
13 |
Correct |
42 ms |
5100 KB |
Output is correct |
14 |
Correct |
41 ms |
5100 KB |
Output is correct |
15 |
Correct |
43 ms |
4948 KB |
Output is correct |
16 |
Correct |
43 ms |
4944 KB |
Output is correct |
17 |
Correct |
42 ms |
4944 KB |
Output is correct |
18 |
Correct |
42 ms |
5080 KB |
Output is correct |
19 |
Correct |
41 ms |
4948 KB |
Output is correct |
20 |
Correct |
42 ms |
5096 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
65 ms |
5852 KB |
Output is correct |
25 |
Correct |
61 ms |
5712 KB |
Output is correct |
26 |
Correct |
57 ms |
5864 KB |
Output is correct |
27 |
Correct |
58 ms |
5912 KB |
Output is correct |
28 |
Correct |
58 ms |
5720 KB |
Output is correct |
29 |
Correct |
59 ms |
5716 KB |
Output is correct |
30 |
Correct |
58 ms |
5724 KB |
Output is correct |
31 |
Correct |
58 ms |
5848 KB |
Output is correct |
32 |
Correct |
0 ms |
348 KB |
Output is correct |
33 |
Correct |
1 ms |
348 KB |
Output is correct |
34 |
Correct |
1 ms |
348 KB |
Output is correct |
35 |
Correct |
1 ms |
348 KB |
Output is correct |
36 |
Correct |
4 ms |
508 KB |
Output is correct |
37 |
Correct |
61 ms |
5844 KB |
Output is correct |
38 |
Correct |
70 ms |
5844 KB |
Output is correct |
39 |
Correct |
62 ms |
5848 KB |
Output is correct |
40 |
Correct |
61 ms |
5844 KB |
Output is correct |
41 |
Correct |
0 ms |
344 KB |
Output is correct |
42 |
Correct |
1 ms |
348 KB |
Output is correct |
43 |
Correct |
3 ms |
604 KB |
Output is correct |
44 |
Correct |
3 ms |
604 KB |
Output is correct |
45 |
Correct |
61 ms |
5916 KB |
Output is correct |
46 |
Correct |
68 ms |
5916 KB |
Output is correct |
47 |
Correct |
61 ms |
5680 KB |
Output is correct |
48 |
Correct |
63 ms |
5828 KB |
Output is correct |
49 |
Correct |
62 ms |
5848 KB |
Output is correct |
50 |
Correct |
61 ms |
5852 KB |
Output is correct |
51 |
Correct |
62 ms |
5712 KB |
Output is correct |
52 |
Correct |
66 ms |
5712 KB |
Output is correct |
53 |
Correct |
62 ms |
5724 KB |
Output is correct |
54 |
Correct |
63 ms |
5712 KB |
Output is correct |
55 |
Correct |
61 ms |
5848 KB |
Output is correct |
56 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
57 |
Halted |
0 ms |
0 KB |
- |