답안 #590356

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
590356 2022-07-05T21:24:36 Z Soumya1 Sky Walking (IOI19_walk) C++17
0 / 100
173 ms 36140 KB
#include "walk.h"
#include <bits/stdc++.h>
#ifdef __LOCAL__
	#include <debug_local.h>
#endif
using namespace std;
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 = y.size();
	multiset<pair<int, long long>> st;
	vector<int> add[n], rem[n];
	for (int i = 0; i < m; i++) {
		add[l[i]].push_back(i);
		rem[r[i]].push_back(i);
	}
	vector<long long> ans(m);
	for (int i = 0; i < n; i++) {
		vector<pair<int, int>> nw;
		for (int j : add[i]) {
			if (i == 0) nw.push_back({y[j], y[j]}), ans[j] = y[j];
			else {
				long long v = 1e18;
				auto up = st.upper_bound({y[j], -5});
				if (up != st.end()) v = min(v, (*up).first - y[j] + (*up).second); 
				auto down = st.lower_bound({y[j], -5});
				if (!st.empty() && up == down && down != st.begin()) {
					down--;
				  v = min(v, y[j] - (*down).first + (*down).second); 
				}
				ans[j] = v;
				nw.push_back({y[j], ans[j]});
			}
		}
		for (auto x : nw) st.insert(x);
		for (int j : rem[i]) st.erase(st.find({y[j], ans[j]}));
	}
	long long ret = 1e18;
	for (int i = 0; i < m; i++) {
		if (r[i] == n - 1) ret = min(ret, ans[i] + y[i] + x[n - 1] - x[0]);
	} 
	if (ret == 1e18) ret = -1;
	return ret;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 4084 KB Output is correct
2 Correct 84 ms 5544 KB Output is correct
3 Correct 103 ms 8032 KB Output is correct
4 Correct 146 ms 17968 KB Output is correct
5 Correct 173 ms 22324 KB Output is correct
6 Correct 163 ms 20412 KB Output is correct
7 Correct 78 ms 13984 KB Output is correct
8 Runtime error 87 ms 36140 KB Execution killed with signal 6
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 4084 KB Output is correct
2 Correct 84 ms 5544 KB Output is correct
3 Correct 103 ms 8032 KB Output is correct
4 Correct 146 ms 17968 KB Output is correct
5 Correct 173 ms 22324 KB Output is correct
6 Correct 163 ms 20412 KB Output is correct
7 Correct 78 ms 13984 KB Output is correct
8 Runtime error 87 ms 36140 KB Execution killed with signal 6
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -