#include "walk.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll , ll> ii;
#define ff first
#define ss second
#define pb push_back
#define in insert
const ll N = 2e5 + 5;
vector < ll > L[N], R[N];
ll ans[N]; ll dp[N];
long long min_distance(std::vector<int> x, std::vector<int> h, std::vector<int> l, std::vector<int> r, std::vector<int> y, int S, int E) {
ll m = l.size();
for(ll i = 0; i < m; i++){
L[l[i]].pb(i);
R[r[i] + 1].pb(i);
ans[i] = 1e18;
}
set < ii > s;
for(auto i : L[0]){
s.in({y[i], i});
dp[i] = y[i];
}
ll n = x.size();
for(ll j = 1; j < n; j++){
for(auto i : R[j]){
s.erase({y[i], i});
}
if(s.size() == 0) return -1;
for(auto i : L[j]){
auto itr = s.lower_bound(make_pair(y[i], 0));
if(itr != s.end()){
auto [X, Y] = *itr;
ans[i] = min(ans[i], ans[Y] + abs(X - y[i]));
}
if(itr != s.begin()){
itr--;
auto [X, Y] = *itr;
ans[i] = min(ans[i], ans[Y] + abs(X - y[i]));
}
}
}
ll res = 1e18;
for(auto [x, y] : s){
res = min(res, ans[y] + x);
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
9684 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
9684 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
25 ms |
13604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
25 ms |
13604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
9684 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |