Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. const int N=1e4+1;
  6. int ans=-1;
  7. int x;
  8. int q;
  9. int a[7];
  10.  
  11. int main () {
  12.     int n;
  13.     cin >> n;
  14.     for (int i=1; i<=7; ++i) {
  15.         cin >> x;
  16.         a[i%7]=x;
  17.     }
  18.     for (int i=8; i<=n; ++i) { ;
  19.         cin >> x;
  20.         if (a[i%7]>q){
  21.             q=a[i%7];
  22.         }
  23.         if (x+q>ans){
  24.             ans=x+q;
  25.         }
  26.         a[i%7]=x;
  27.     }
  28.     cout << ans;
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement