#include "nile.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
vector<ll> calculate_costs(vector<int> W, vector<int> A, vector<int> B, vector<int> E) {
int Q = (int)E.size();
int N = (int)W.size();
ll sum = 0;
for (int i = 0; i < N; i++) sum += A[i];
vector<ll> R(Q, sum);
vector<pll> C;
for (int i = 0; i < N; i++) C.push_back({W[i], A[i]-B[i]});
sort(C.begin(), C.end());
for (int t = 0; t < Q; t++) {
ll D = E[t];
int st = 0;
while (st < N) {
for (int i = st+1; i <= N; i++) {
if (i == N || C[i].first - C[i-1].first > D) {
R[t] -= (i-st)/2*2;
st = i;
break;
}
}
}
}
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... |