fork download
  1. #include <iostream>
  2. using namespace std;
  3. void inp_mas (int m[])
  4. {
  5. int N;
  6. N=0;
  7. while(cin>>m[N])
  8. N++;
  9. }
  10. void bubble(int m[], int N)
  11. {
  12. for(int i=0;i<N+1; i++)
  13. for(int j=0; j<N; j++)
  14. if(m[j]>m[j+1])
  15. swap(m[j],m[j+1]);
  16. }
  17.  
  18. bool checker(int m[], int N)
  19. {
  20. int diff;
  21. diff=m[1]-m[0];
  22. for(int i=0;i<N;i++)
  23. {
  24. if((m[i+1]-m[i])!=diff)
  25. return false;
  26. }
  27. return true;
  28. }
  29. int m[100000];
  30. int main()
  31. {
  32. int N;
  33. inp_mas(m);
  34. bubble(m,N);
  35. if(checker(m,N))
  36. cout<<"YES";
  37. else cout<<"NO";
  38. return 0;
  39. }
Success #stdin #stdout 0.01s 5420KB
stdin
80 50 10 30 70 40 20 60 91
stdout
YES