func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename G, typename H>   struct triple {     G first, second, T;     triple(G x, G y, G z) : first(x), second(y), T(z) {}     triple() : first(0), second(0), T(0) {}     bool operator<(const triple<G, H> other) const { return first > other.first; }   };   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, m;     cin >> n >> m;     vector<int> v(m);     for (auto &i : v) cin >> i;     sort(v.begin(), v.end());     int g, r;     cin >> g >> r;     int oo = 2e9;     vector<vector<int>> dp(m, vector<int>(g + 1, oo));     dp[0][g] = 0;     deque<pair<int, int>> pq;     pq.push_back({0, g});     while (!pq.empty()) {       pair<int, int> t = pq.front();       pq.pop_front();       if (t.second == 0 && dp[t.first][g] > dp[t.first][t.second] + 1) {         dp[t.first][g] = dp[t.first][t.second] + 1;         pq.push_back({t.first, g});       }       if (t.second != 0) {         int i = t.first, j = t.second;         if (i > 0) {           int w = v[i] - v[i - 1];           if (w <= j && dp[i - 1][j - w] > dp[i][j]) {             dp[i - 1][j - w] = dp[i][j];             pq.push_front({i - 1, j - w});           }         }         if (i < m - 1) {           int w = v[i + 1] - v[i];           if (w <= j && dp[i + 1][j - w] > dp[i][j]) {             dp[i + 1][j - w] = dp[i][j];             pq.push_front({i + 1, j - w});           }         }       }     }     int ans = oo;     for (int i = 0; i <= g; i++)       if (dp[m - 1][i] != oo) ans = min(ans, dp[m - 1][i] * (r + g) + g - i);     if (ans == oo) ans = -1;     cout << ans <<   n ;     return 0;   }   