답안 #1051038

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1051038 2024-08-09T18:42:40 Z Itamar Sky Walking (IOI19_walk) C++14
33 / 100
215 ms 31184 KB
using namespace std;
#include<vector>
#include<map>
#include<set>
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define pi pair<ll,ll>
#include<cmath>
#define vi vector<int>
#include<algorithm>
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 g) {
	int n = x.size(), m = l.size();
    if(n==1)return 0;
    vector<vi> in(2e5+2);
    vector<vi> out(2e5+2);
    map<ll,ll> dp;
    multiset<ll> se;
    se.insert(1e18+1);
    se.insert(-1e18-1);
    dp[1e18+1]=1e18;
    dp[-1e18-1]=1e18;
    for(int i = 0; i < m;i++){
        dp[y[i]]=1e18;
        in[l[i]].push_back(y[i]);
        out[r[i]].push_back(y[i]);
    }
    out[0].push_back(0);
    dp[0]=0;
    se.insert(0);
    for(int i = 0; i < n; i++){

        for(ll t : in[i])se.insert(t);
        for(ll t : out[i]){
            if(i == n-1){
                dp[0] = min(dp[0], dp[t]+t);
            }
            se.erase(se.find(t));
        }
        for(ll t : out[i]){
            auto it1 = se.lower_bound(t), it2 = se.upper_bound(t);
            it2--;
            dp[*it1] = min(dp[*it1],dp[t]+abs((*it1)-t));
            dp[*it2] = min(dp[*it2],dp[t]+abs((*it2)-t));
        }
        for(ll t : out[i])if(se.find(t) == se.end())dp[t] = 1e18;
    }
    
    if(dp[0] == 1e18)return -1;
    return dp[0]+x[n-1]-x[0];
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 9820 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 9820 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 12100 KB Output is correct
2 Correct 167 ms 19836 KB Output is correct
3 Correct 175 ms 22352 KB Output is correct
4 Correct 193 ms 28096 KB Output is correct
5 Correct 212 ms 30960 KB Output is correct
6 Correct 204 ms 29712 KB Output is correct
7 Correct 87 ms 21524 KB Output is correct
8 Correct 126 ms 30032 KB Output is correct
9 Correct 192 ms 31100 KB Output is correct
10 Correct 93 ms 25940 KB Output is correct
11 Correct 8 ms 11356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 12100 KB Output is correct
2 Correct 167 ms 19836 KB Output is correct
3 Correct 175 ms 22352 KB Output is correct
4 Correct 193 ms 28096 KB Output is correct
5 Correct 212 ms 30960 KB Output is correct
6 Correct 204 ms 29712 KB Output is correct
7 Correct 87 ms 21524 KB Output is correct
8 Correct 126 ms 30032 KB Output is correct
9 Correct 192 ms 31100 KB Output is correct
10 Correct 93 ms 25940 KB Output is correct
11 Correct 8 ms 11356 KB Output is correct
12 Correct 171 ms 22504 KB Output is correct
13 Correct 188 ms 27988 KB Output is correct
14 Correct 209 ms 30852 KB Output is correct
15 Correct 100 ms 23636 KB Output is correct
16 Correct 95 ms 23892 KB Output is correct
17 Correct 105 ms 23708 KB Output is correct
18 Correct 94 ms 23632 KB Output is correct
19 Correct 97 ms 23632 KB Output is correct
20 Correct 88 ms 21536 KB Output is correct
21 Correct 16 ms 13404 KB Output is correct
22 Correct 120 ms 24116 KB Output is correct
23 Correct 113 ms 24528 KB Output is correct
24 Correct 120 ms 25900 KB Output is correct
25 Correct 115 ms 25116 KB Output is correct
26 Correct 105 ms 28928 KB Output is correct
27 Correct 211 ms 30804 KB Output is correct
28 Correct 170 ms 27668 KB Output is correct
29 Correct 190 ms 29864 KB Output is correct
30 Correct 89 ms 21416 KB Output is correct
31 Correct 215 ms 31184 KB Output is correct
32 Correct 65 ms 23380 KB Output is correct
33 Correct 67 ms 24660 KB Output is correct
34 Correct 95 ms 24912 KB Output is correct
35 Correct 80 ms 23632 KB Output is correct
36 Correct 63 ms 22504 KB Output is correct
37 Correct 41 ms 20560 KB Output is correct
38 Correct 44 ms 23120 KB Output is correct
39 Correct 130 ms 26828 KB Output is correct
40 Correct 54 ms 22612 KB Output is correct
41 Correct 45 ms 21076 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 9820 KB Output isn't correct
2 Halted 0 ms 0 KB -