Advertisement
Josif_tepe

Untitled

Mar 16th, 2024
461
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <vector>
  4. using namespace std;
  5. typedef long long ll;
  6. int main() {
  7.     int n, k, s;
  8.     cin >> n >> k >> s;
  9.  
  10.     int niza[n];
  11.     for(int i = 0; i < n; i++) {
  12.         cin >> niza[i];
  13.     }
  14.  
  15.     ll sum = 0;
  16.     for(int i = 0; i < k - 1; i++) {
  17.         sum += niza[i];
  18.     }
  19.     int i = 0;
  20.  
  21.     for(int j = k - 1; j < n; j++) {
  22.         sum += niza[j];
  23.         cout << sum << " ";
  24.         sum -= niza[i];
  25.         i++;
  26.     }
  27.     return 0;
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement