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 "nile.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<long long> calculate_costs(vector<int> W, vector<int> A, vector<int> B, vector<int> E) {
int Q = (int)E.size(), n = (int)A.size();
vector<long long> R(Q, 0);
vector<array<int, 3> > a(n+1);
for(int i=1; i<=n; i++) a[i] = { W[i-1], A[i-1], B[i-1] };
sort(a.begin()+1, a.end());
for(int t=0; t<Q; t++) {
vector<ll> dp(n+1, 1e18); dp[0] = 0;
for(int i=1; i<=n; i++) {
dp[i] = dp[i-1] + a[i][1];
if(i > 1 && a[i][0] - a[i-1][0] <= E[t])
dp[i] = min(dp[i], dp[i-2] + a[i-1][2] + a[i][2]);
if(i > 2 && a[i][0] - a[i-2][0] <= E[t])
dp[i] = min(dp[i], dp[i-3] + a[i-2][2] + a[i-1][1] + a[i][2]);
}
R[t] = dp[n];
}
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... |