fork download
  1. #include <bits/stdc++.h>
  2.  
  3. #define ll long long
  4. #define el cout << '\n'
  5.  
  6. using namespace std;
  7.  
  8. const int maxn = 1e3;
  9.  
  10. int n, k, m;
  11. ll a[maxn + 10], b, r, a_cop[maxn + 10], ans = 0;
  12.  
  13. void cop()
  14. {
  15. for (int i = 1; i <= n; i++)
  16. a_cop[i] = a[i];
  17. }
  18.  
  19. int main()
  20. {
  21. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  22. if (fopen("FERTILIZE.INP", "r"))
  23. {
  24. freopen("FERTILIZE.INP", "r", stdin);
  25. freopen("FERTILIZE_TRAU.OUT", "w", stdout);
  26. }
  27.  
  28. cin >> n >> k >> m >> b >> r;
  29. for (int i = 1; i <= n; i++)
  30. cin >> a[i];
  31. for (int i = 1; i <= n - m + 1; i++)
  32. {
  33. cop();
  34. for (int j = i; j <= i + m - 1; j++)
  35. a_cop[j] += b + (j - i) * r;
  36. // for (int j = 1; j <= n; j++)
  37. // cout << a_cop[j] << ' ';
  38. sort(a_cop + 1, a_cop + n + 1, greater<ll>());
  39. // el;
  40. ans = max(ans, a_cop[k]);
  41. }
  42. cout << ans;
  43. }
  44.  
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
Standard output is empty