Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <bits/stdc++.h>
  3.  
  4. #define all(x) begin(x), end(x)
  5. #define rall(x) rbegin(x), rend(x)
  6.  
  7. #define file ""
  8.  
  9. using namespace std;
  10. using ll = long long;
  11. using ull = unsigned long long;
  12. using str = string;
  13. using srt = short;
  14.  
  15. const int INF = (int)1e9 + 7;
  16. const int mod = 998244353;
  17. const ll inf = (ll)1e18;
  18. const ull oo = 1000000000000001;
  19. const int N = 200005;
  20.  
  21. signed main()
  22. {
  23.     //freopen("input.txt", "r", stdin);
  24.     //freopen("output.txt", "w", stdout);
  25.     ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr); //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
  26.  
  27.     int n, a, b, x;
  28.     cin >> n >> a >> b >> x;
  29.     vector<int> dp(n + 2), arr(n);
  30.     for (auto& it : arr)
  31.     {
  32.         cin >> it;
  33.         it = (it + x - 1) / x;
  34.     }
  35.     int ans = 0;
  36.     for (int i = n; i > 0; --i)
  37.     {
  38.         dp[i] += dp[i + 1];
  39.         arr[i - 1] += dp[i];
  40.         ans += max(0, arr[i - 1]);
  41.         dp[i] -= arr[i - 1];
  42.         dp[max(0, i - b - a - 1)] += arr[i - 1];
  43.     }
  44.     cout << ans << endl;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement