Advertisement
esraa_syam

Untitled

Sep 3rd, 2022
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <limits.h>
  3. #include <algorithm>
  4. #include <math.h>
  5. #include <cctype>
  6. #include <cmath>
  7. #include <bits/stdc++.h>
  8. #include <string>
  9. #include <utility>
  10. #include<vector>
  11. #define ll long long
  12. #define ull unsigned long long
  13. #define fixed(n) fixed << setprecision(n)
  14. //#define ceil(n, m) (((n) / (m)) + ((n) % (m) ? 1 : 0))
  15. #define sz(x) int(x.size())
  16. #define charToInt(s) (s - '0')
  17. #define Num_of_Digits(n) ((int)log10(n) + 1)
  18. #define fi first
  19. #define se second
  20. #define number_line iota(all(vec) , 1)
  21. #define nl "\n"
  22. #define pi 3.14159
  23. #define all(s) s.begin(), s.end()
  24. #define rall(v) v.rbegin() , v.rend()
  25. #define Mod 1'000'000'007
  26. #define INF 2'000'000'000
  27. #define Upper(s) transform(all(s), s.begin(), ::toupper);
  28. #define Lower(s) transform(all(s), s.begin(), ::tolower);
  29. using namespace std;
  30. void esraa()
  31. {
  32. ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  33. // freopen("func.in" , "r" , stdin);
  34. #ifndef ONLINE_JUDGE
  35. freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  36. #endif
  37. }
  38. void solve(){
  39. ll n , m;
  40. cin >> n >> m;
  41. vector < int > vec(n) ;
  42. for(auto & i : vec) cin >> i;
  43. ll l = 0 , r = 0;
  44. deque < char >dq;
  45. while(r - l + 1 != m){
  46. dq.emplace_back(vec[r++]);
  47. }
  48. ll maxi = LLONG_MIN , sum = 0;
  49. for( ; r < sz(vec) ; r++){
  50. dq.emplace_back(vec[r]);
  51. for(int i = 0 ; i < sz(dq) ; i++){
  52. sum += (dq[i] * (i + 1));
  53. maxi = max(maxi , sum);
  54. }
  55. sum = 0;
  56. dq.pop_front();
  57. }
  58. cout << maxi << nl;
  59. }
  60. int main()
  61. {
  62. esraa();
  63. int t = 1;
  64. //cin >> t;
  65. while(t--)
  66. solve();
  67. return 0;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement