crsandu

Pbinfo - Paralele

Nov 1st, 2016
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <algorithm>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7.  
  8. ifstream fin("paralele.in");
  9. ofstream fout("paralele.out");
  10.  
  11. int a[1000000], p = 0;
  12. int v[10000], n;
  13.  
  14. /*
  15. Io, Miholca Ionela (si o prietena de-a mea) daclar pe propia raspundere ca am preluat aceasta
  16. rezolvarea de la maretul SANDU CRISTIAN.
  17. Rezolvare: Sandu Cristian
  18. Coordonator: Sandu Cristian
  19. */
  20. int main()
  21. {
  22.     fin >> n;
  23.     for (int i=1; i<=n; i++)
  24.     {
  25.         fin >> v[i];
  26.     }
  27.     for (int i=1; i<=n-1; i++)
  28.     {
  29.         for (int j=i+1; j<=n; j++)
  30.         {
  31.             a[p] = abs(v[j] - v[i]);
  32.             p++;
  33.         }
  34.     }
  35.     sort(a, a+p);
  36.     int best = -1, k = 1;
  37.     for (int i = 0; i<p-1; i++)
  38.     {
  39.         if (a[i] == a[i+1])
  40.         {
  41.             k++;
  42.         }
  43.         else
  44.         {
  45.             if (k > best)
  46.             {
  47.                 best = k;
  48.             }
  49.             k = 1;
  50.         }
  51.     }
  52.     fout << best;
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment