(I7
I122
I149
(dp0
Vmetro.%l
p1
(Vmetro.cpp
p2
S'#include <bits/stdc++.h>\r\nusing namespace std;\r\n\r\nint a, b;\r\nint n, m;\r\nbool isbig[10000];\r\nint big[10000], lbig, rbig;\r\nint pos;\r\nlong long cost;\r\n\r\nint main() {\r\n    cin >> n >> m;\r\n    for (int i = 0; i < m; ++ i) {\r\n        cin >> big[i];\r\n        isbig[big[i]] = true;\r\n    }\r\n    cin >> a >> b;\r\n    pos = a;\r\n    int i;\r\n    for (i = 0; big[i] <= a; ++ i) {}\r\n    rbig = i;\r\n    lbig = i - 1;\r\n    while(pos != b) {\r\n        if (pos < b) {\r\n            if (isbig[pos]) {\r\n                if (big[rbig] < b) {\r\n                    lbig ++;\r\n                    pos = big[rbig];\r\n                    rbig ++;\r\n                    cost += 2;\r\n                } else {\r\n                    if (b - pos < 2 + big[rbig] - b) {\r\n                        cost += b - pos;\r\n                        pos = b;\r\n                    } else {\r\n                        cost += 2 + big[rbig] - b;\r\n                        pos = b;\r\n                    }\r\n                }\r\n            } else {\r\n                if (big[rbig] < b) {\r\n                    cost += big[rbig] - pos;\r\n                    pos = big[rbig];\r\n                    rbig ++;\r\n                    cout << big[rbig] << endl;\r\n                } else {\r\n                    if (b - pos < pos - big[lbig] + 2 + big[rbig] - b) {\r\n                        cost += b - pos;\r\n                        pos = b;\r\n                    } else {\r\n                        cost += pos - big[lbig] + 2 + big[rbig] - b;\r\n                        pos = b;\r\n                    }\r\n                }\r\n            }\r\n        } else {\r\n            if (isbig[pos]) {\r\n                if (big[lbig] > b) {\r\n                    rbig --;\r\n                    pos = big[lbig];\r\n                    lbig --;\r\n                    cost += 2;\r\n                } else {\r\n                    if (pos - b < 2 + b - big[lbig]) {\r\n                        cost += pos - b;\r\n                        pos = b;\r\n                    } else {\r\n                        cost += 2 + b - big[lbig];\r\n                        pos = b;\r\n                    }\r\n                }\r\n            } else {\r\n                if (big[rbig] < b) {\r\n                    pos = big[rbig];\r\n                    rbig ++;\r\n                    cost += big[rbig] - pos;\r\n                } else {\r\n                    if (b - pos < pos - big[lbig] + 2 + big[rbig] - b) {\r\n                        cost += b - pos;\r\n                        pos = b;\r\n                    } else {\r\n                        cost += pos - big[lbig] + 2 + big[rbig] - b;\r\n                        pos = b;\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    }\r\n    cout << cost << endl;\r\n    return 0;\r\n}\r\n'
p3
tp4
stp5
.