Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <bits/stdc++.h>
- #define all(x) begin(x), end(x)
- #define rall(x) rbegin(x), rend(x)
- #define file ""
- using namespace std;
- using ll = long long;
- using ull = unsigned long long;
- using str = string;
- using srt = short;
- const int INF = (int)1e9 + 7;
- const int mod = 998244353;
- const ll inf = (ll)1e18;
- const ull oo = 1000000000000001;
- const int N = 200005;
- signed main()
- {
- //freopen("input.txt", "r", stdin);
- //freopen("output.txt", "w", stdout);
- ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr); //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
- int n, a, b, x;
- cin >> n >> a >> b >> x;
- vector<int> dp(n + 2), arr(n);
- for (auto& it : arr)
- {
- cin >> it;
- it = (it + x - 1) / x;
- }
- int ans = 0;
- for (int i = n; i > 0; --i)
- {
- dp[i] += dp[i + 1];
- arr[i - 1] += dp[i];
- ans += max(0, arr[i - 1]);
- dp[i] -= arr[i - 1];
- dp[max(0, i - b - a - 1)] += arr[i - 1];
- }
- cout << ans << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement