#include "nile.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define TIME (1.0* clock()/CLOCKS_PER_SEC)
#define eb emplace_back
#define id1 (id<<1)
#define id2 (id<<1)|1
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int>>
#define vl vector<long long>
#define vll vector <pair<ll,ll>>
#define li pair<long long,int>
#define vil vector <pair<int,ll>>
#define db double
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define FOR(i, a, b) for (int i = (a); i <=(b); i++)
#define F0R(i, a) FOR(i, 0, a-1)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define rep(a) F0R(_, a)
#define each(a, x) for (auto &a : x)
#define ALL(x) (x).begin(),(x).end()
#define pq priority_queue <li, vector <li>, greater <li>>
using namespace std;
vector<ll> calculate_costs(vector<int> W, vector<int> A, vector<int> B, vector<int> E) {
int n = W.size();
vector<vector<ll>> v;
F0R(i, n) {
v.pb({(ll)W[i], (ll)A[i], (ll)B[i]});
}
vector<ll> ans;
sort(all(v));
for (auto d : E) {
ll dp[n];
F0R(i, n) dp[i] = 1e18;
dp[0] = v[0][1];
FOR(i, 1, n-1) {
dp[i] = min(dp[i], dp[i-1] + v[i][1]);
if (abs(v[i-1][0] - v[i][0]) <= d) {
dp[i] = min(dp[i], (i >= 2 ? dp[i-2] : 0LL) + v[i-1][2] + v[i][2]);
}
if (i >= 2 && abs(v[i-2][0] - v[i][0]) <= d) {
dp[i] = min(dp[i], (i >= 3 ? dp[i-3] : 0LL) + v[i-2][2] + v[i][2] + v[i-1][1]);
}
}
ans.pb(dp[n-1]);
}
return ans;
}
# | 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... |