This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
std::vector<long long> calculate_costs(
std::vector<int> W, std::vector<int> A,
std::vector<int> B, std::vector<int> E) {
int N = (int)W.size();
vector<long long>answers;
vector<pair<int,int>>v;
for (int i = 0; i < N;++i)
v.push_back({-A[i] + B[i],i});
sort(v.begin(),v.end());
for (auto q : E) {
long long ans = 0;
vector<bool>used(N);
for (int i = 0; i < N;++i) {
if (!used[v[i].second]) {
for (int j = i + 1; j < N;++j)
if (!used[v[j].second] && abs(W[v[i].second] - W[v[j].second]) <= q) {
used[v[j].second] = used[v[i].second] = true;
ans += B[v[i].second] + B[v[j].second];
}
}
if (!used[v[i].second])
ans += A[v[i].second];
}
answers.push_back(ans);
}
return answers;
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |