Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- // ----------- define --------------
- #define int long long
- #define vi vector<int>
- #define ii pair<int,int>
- #define fi first
- #define sc second
- #define mp make_pair
- #define pb push_back
- #define pqueue priority_queue
- #define popcnt __builtin_popcount
- #define getBit(x, k) ((x >> k) & 1)
- #define xorBit(x, k) (x ^ (1 << k))
- #define siz(x) (int)((x).size())
- #define all(x) (x).begin(),(x).end()
- // ---------------------------------
- void Main() {
- int l1, l2, l3, c1, c2, c3;
- cin >> l1 >> l2 >> l3 >> c1 >> c2 >> c3;
- int n, s, f;
- cin >> n >> s >> f;
- vector<int> a(n + 1);
- for (int i = 2; i <= n; i++) {
- cin >> a[i];
- }
- vector<int> dp(n + 1, 1e15);
- dp[s] = 0;
- int p1 = s, p2 = s, p3 = s;
- for (int i = s + 1; i <= f; i++) {
- while (a[i] - a[p1] > l1) p1++;
- while (a[i] - a[p2] > l2) p2++;
- while (a[i] - a[p3] > l3) p3++;
- int t1 = dp[p1] + c1;
- int t2 = dp[p2] + c2;
- int t3 = dp[p3] + c3;
- dp[i] = min(t1, min(t2, t3));
- }
- cout << dp[f] << '\n';
- }
- signed main() {
- #ifdef _DEBUG
- // freopen("in" , "r", stdin );
- cerr << "- ---- -- ----- <3\n";
- #endif
- cin.tie(0)->sync_with_stdio(0);
- int T = 1;
- // cin >> T;
- while (T--) Main();
- }
Advertisement
Add Comment
Please, Sign In to add comment