Submission #1058590

# Submission time Handle Problem Language Result Execution time Memory
1058590 2024-08-14T11:21:38 Z Unforgettablepl Sky Walking (IOI19_walk) C++17
33 / 100
89 ms 21592 KB
#include "walk.h"
#include <bits/stdc++.h>
using namespace std;

const long long INF = 1e15;

long long min_distance(vector<int> x,vector<int> h,vector<int> l,
					   vector<int> r,vector<int> y,int s,int g){
	int n = x.size();
	int m = l.size();
	vector<vector<int>> starters(n);
	vector<vector<int>> ends(n);
	for(int i=0;i<m;i++) {
		starters[l[i]].emplace_back(y[i]);
		ends[r[i]].emplace_back(y[i]);
	}
	multiset<pair<int,long long>> offers;
	ends[0].emplace_back(0);
	offers.emplace(0,0);
	for(int i=0;i<n-1;i++) {
		for(int&ht:starters[i]) {
			auto iter = offers.lower_bound({ht,0});
			long long bestopt = INF;
			if(iter!=offers.end()) {
				// try
				bestopt=min(bestopt,iter->first-ht + iter->second);
			}
			if(iter!=offers.begin()) {
				--iter;
				// try
				bestopt=min(bestopt,ht-iter->first+iter->second);
			}
			offers.emplace(ht,bestopt);
		}
		for(int&ht:ends[i]) {
			offers.erase(offers.lower_bound({ht,0}));
		}
	}
	if(offers.empty())return -1;
	long long ans = x[g]-x[s]+offers.begin()->second+offers.begin()->first;
	if(ans>=INF)return -1;
	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 3676 KB Output is correct
2 Correct 42 ms 5488 KB Output is correct
3 Correct 48 ms 7312 KB Output is correct
4 Correct 69 ms 17236 KB Output is correct
5 Correct 89 ms 21592 KB Output is correct
6 Correct 82 ms 19540 KB Output is correct
7 Correct 35 ms 13660 KB Output is correct
8 Correct 43 ms 19292 KB Output is correct
9 Correct 76 ms 21060 KB Output is correct
10 Correct 49 ms 19036 KB Output is correct
11 Correct 7 ms 4188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 3676 KB Output is correct
2 Correct 42 ms 5488 KB Output is correct
3 Correct 48 ms 7312 KB Output is correct
4 Correct 69 ms 17236 KB Output is correct
5 Correct 89 ms 21592 KB Output is correct
6 Correct 82 ms 19540 KB Output is correct
7 Correct 35 ms 13660 KB Output is correct
8 Correct 43 ms 19292 KB Output is correct
9 Correct 76 ms 21060 KB Output is correct
10 Correct 49 ms 19036 KB Output is correct
11 Correct 7 ms 4188 KB Output is correct
12 Correct 48 ms 7260 KB Output is correct
13 Correct 77 ms 17488 KB Output is correct
14 Correct 88 ms 21588 KB Output is correct
15 Correct 53 ms 16972 KB Output is correct
16 Correct 54 ms 17236 KB Output is correct
17 Correct 55 ms 17224 KB Output is correct
18 Correct 54 ms 17012 KB Output is correct
19 Correct 55 ms 17380 KB Output is correct
20 Correct 38 ms 13660 KB Output is correct
21 Correct 14 ms 8540 KB Output is correct
22 Correct 47 ms 14932 KB Output is correct
23 Correct 48 ms 15188 KB Output is correct
24 Correct 45 ms 17068 KB Output is correct
25 Correct 44 ms 15184 KB Output is correct
26 Correct 49 ms 19160 KB Output is correct
27 Correct 83 ms 21076 KB Output is correct
28 Correct 58 ms 16724 KB Output is correct
29 Correct 84 ms 19540 KB Output is correct
30 Correct 38 ms 13652 KB Output is correct
31 Correct 77 ms 20940 KB Output is correct
32 Correct 44 ms 16976 KB Output is correct
33 Correct 45 ms 18732 KB Output is correct
34 Correct 51 ms 17752 KB Output is correct
35 Correct 54 ms 16936 KB Output is correct
36 Correct 39 ms 16208 KB Output is correct
37 Correct 41 ms 14704 KB Output is correct
38 Correct 40 ms 18260 KB Output is correct
39 Correct 53 ms 19956 KB Output is correct
40 Correct 47 ms 17420 KB Output is correct
41 Correct 36 ms 15700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -