Submission #590422

# Submission time Handle Problem Language Result Execution time Memory
590422 2022-07-05T23:08:54 Z farhan132 Sky Walking (IOI19_walk) C++17
33 / 100
182 ms 28764 KB
#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], -1));
			dp[i] = 1e18;
			if(itr != s.end()){
				auto [X, Y] = *itr;
				dp[i] = min(dp[i], dp[Y] + abs(X - y[i]));
			}
			if(itr != s.begin()){
				itr--;
				auto [X, Y] = *itr;
				dp[i] = min(dp[i], dp[Y] + abs(X - y[i]));
			}
			s.in({y[i], i});
		}
	}
	ll res = 1e18;
	for(auto [x, y] : s){
		res = min(res, dp[y] + x);
	}
	return res + x[n - 1] - x[0];
}
# 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 Correct 32 ms 13544 KB Output is correct
2 Correct 86 ms 16328 KB Output is correct
3 Correct 106 ms 18656 KB Output is correct
4 Correct 123 ms 21636 KB Output is correct
5 Correct 152 ms 26572 KB Output is correct
6 Correct 163 ms 24012 KB Output is correct
7 Correct 72 ms 18080 KB Output is correct
8 Correct 82 ms 23328 KB Output is correct
9 Correct 142 ms 27356 KB Output is correct
10 Correct 119 ms 25640 KB Output is correct
11 Correct 14 ms 11220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 13544 KB Output is correct
2 Correct 86 ms 16328 KB Output is correct
3 Correct 106 ms 18656 KB Output is correct
4 Correct 123 ms 21636 KB Output is correct
5 Correct 152 ms 26572 KB Output is correct
6 Correct 163 ms 24012 KB Output is correct
7 Correct 72 ms 18080 KB Output is correct
8 Correct 82 ms 23328 KB Output is correct
9 Correct 142 ms 27356 KB Output is correct
10 Correct 119 ms 25640 KB Output is correct
11 Correct 14 ms 11220 KB Output is correct
12 Correct 95 ms 18812 KB Output is correct
13 Correct 76 ms 22572 KB Output is correct
14 Correct 160 ms 28764 KB Output is correct
15 Correct 132 ms 23548 KB Output is correct
16 Correct 102 ms 23784 KB Output is correct
17 Correct 111 ms 23768 KB Output is correct
18 Correct 111 ms 23516 KB Output is correct
19 Correct 108 ms 23852 KB Output is correct
20 Correct 75 ms 19120 KB Output is correct
21 Correct 27 ms 13284 KB Output is correct
22 Correct 90 ms 21336 KB Output is correct
23 Correct 98 ms 21696 KB Output is correct
24 Correct 97 ms 23148 KB Output is correct
25 Correct 87 ms 21444 KB Output is correct
26 Correct 112 ms 25420 KB Output is correct
27 Correct 147 ms 27892 KB Output is correct
28 Correct 75 ms 22556 KB Output is correct
29 Correct 182 ms 25940 KB Output is correct
30 Correct 64 ms 19052 KB Output is correct
31 Correct 137 ms 27384 KB Output is correct
32 Correct 78 ms 23976 KB Output is correct
33 Correct 85 ms 25060 KB Output is correct
34 Correct 88 ms 24320 KB Output is correct
35 Correct 96 ms 23632 KB Output is correct
36 Correct 79 ms 23080 KB Output is correct
37 Correct 87 ms 22260 KB Output is correct
38 Correct 89 ms 24464 KB Output is correct
39 Correct 100 ms 26176 KB Output is correct
40 Correct 78 ms 23992 KB Output is correct
41 Correct 73 ms 22652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 9684 KB Output isn't correct
2 Halted 0 ms 0 KB -