Lucian_Adrian

#277 Varfuri

Oct 5th, 2021
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main ()
  4. {
  5. int n;
  6. cin >> n;
  7. int a,b,s=0;
  8. cin >> a >> b;
  9. int c;
  10. for (int i = 3 ; i <= n; ++i)
  11. {
  12. cin >> c;
  13. if (a<b && b>c)
  14. s+=b;
  15. a=b;
  16. b=c;
  17. }
  18. cout << s;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment