Submission #145187

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
1451872019-08-19 08:37:16ecnerwalaJob Scheduling (IOI19_job)C++14
100 / 100
324 ms18036 KiB
#include "job.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll scheduling_cost(vector<int> P, vector<int> U_, vector<int> D_) {
vector<ll> U(U_.begin(), U_.end());
vector<ll> D(D_.begin(), D_.end());
int N = int(P.size());
ll ans = 0;
for (int i = 0; i < N; i++) {
ans += U[i] * D[i];
}
// build things earlier with high U[i] / D[i]
auto cmp = [](pair<pair<ll, ll>, int> i, pair<pair<ll, ll>, int> j) {
// returns true if j comes first
return j.first.second * i.first.first < i.first.second * j.first.first;
};
priority_queue<pair<pair<ll, ll>, int>, vector<pair<pair<ll, ll>, int>>, decltype(cmp)> pq(cmp);
vector<char> dead(N);
for (int i = 1; i < N; i++) {
if (U[i] == 0 && D[i] == 0) {
dead[i] = true;
} else {
pq.emplace(pair<ll, ll>(U[i], D[i]), i);
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...