이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 total = 0;
rep(i,0,n) total += u[i];
score += d[0]*total;
total -= u[0];
vi inds(n-1);iota(all(inds),1);
sort(all(inds), [&](int a, int b){
return (d[a]*u[a])<(d[b]*u[b]);
});
// cout<<score<<endl;
rep(i,0,n-1){
int j = inds[i];
score += total * d[j];
// cout<<score<<endl;
total -= u[j];
}
}else{
assert(false);
}
return score;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |