rengetsu

Timus_1910

Jul 21st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. //Timus 1910
  2. #include <iostream>
  3. using namespace std;
  4. int main()
  5. {
  6.     int n, nn[1001], sr, sum, max=0;
  7.     cin >> n;
  8.     for(int i=0;i<n;i++)
  9.     {
  10.         cin >> nn[i];
  11.     }
  12.     for(int i=0;i<n-2;i++)
  13.     {
  14.         sum = nn[i] + nn[i+1] + nn[i+2];
  15.         if(sum>max){max=sum;sr=i+2;}
  16.     }
  17.     cout << max << " " << sr;
  18.     return 0;
  19. }
Add Comment
Please, Sign In to add comment