#include<bits/stdc++.h>
using namespace std;
vector<long long> calculate_costs(vector<int> W, vector<int> A, vector<int> B, vector<int> E)
{
int N = W.size();
long long ansBase = 0;
vector<pair<int, int>> art;
for (int i = 0; i < N; i++)
{
art.push_back(make_pair(W[i], A[i] - B[i]));
ansBase += B[i];
}
sort(art.begin(), art.end());
vector<long long> R;
for (int D : E)
{
long long ans = ansBase;
for (int i = 0; i < N; )
{
int j = i + 1;
while (j < N && art[j].first - art[j - 1].first <= D)
j++;
if ((j - i) & 1)
{
int mn = art[i].second;
for (int x = 0; i + x < j; x++)
if (~x & 1 || art[i + x + 1].first - art[i + x - 1].first <= D)
mn = min(mn, art[i + x].second);
ans += mn;
}
i = j;
}
R.push_back(ans);
}
return R;
}
# | 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... |