Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. #define N 100000007
  4. using namespace std;
  5. int main()
  6. {
  7. int n;
  8. cin>>n;
  9. int arr[N];
  10. int flag=2,temp=2;
  11. for(int i=0;i<n;i++){
  12. cin>>arr[i];
  13. }
  14. for(int i=2;i<n;i++){
  15. if(arr[i]==arr[i-1]+arr[i-20]){
  16. flag++;
  17. }
  18. else{
  19. flag=2;
  20. }
  21. temp=max(flag,temp);
  22. }
  23. if(n<=2){
  24. cout<<n<<endl;
  25. }
  26. else{
  27. cout<<temp<<endl;
  28. }
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement