Advertisement
Saleh127

CF 1399C

Aug 6th, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. ios_base::sync_with_stdio(0);
  6. cin.tie(0);cout.tie(0);
  7.  
  8. int t;
  9. cin>>t;
  10. while(t--)
  11. {
  12. int a[10000],c,d,e=0,f,i,j,k,l,sum;
  13. cin>>c;
  14. for(i=1;i<=c;i++)
  15. {
  16. cin>>a[i];
  17. }
  18. sort(a+1,a+c+1);
  19. for(sum=2;sum<=100;sum++)
  20. {
  21. f=0;
  22. for(i=1,j=c;i<j;)
  23. {
  24. if(a[i]+a[j]>sum) j--;
  25. else if(a[i]+a[j]<sum) i++;
  26. else
  27. {
  28. f++;
  29. i++;
  30. j--;
  31. }
  32. }
  33. e=max(e,f);
  34. }
  35. cout<<e<<endl;
  36. }
  37. return 0;
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement