Saleh127

LO 1307

Jul 25th, 2020
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define fellow_junior ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. int main()
  7. {
  8. fellow_junior
  9.  
  10. ll t,k;
  11. cin>>t;
  12. for(k=1;k<=t;k++)
  13. {
  14. ll a[20000],c,d,e=0,f,i,j,l;
  15. cin>>c;
  16. for(i=0;i<c;i++)
  17. {
  18. cin>>a[i];
  19. }
  20. sort(a,a+c);
  21. for(i=0;i<c-2;i++)
  22. {
  23. for(j=i+1;j<c-1;j++)
  24. {
  25. d=upper_bound(a,a+c,a[i]+a[j]-1)-a-j-1;
  26. e+=d;
  27. }
  28. }
  29. printf("Case %lld: %lld\n",k,e);
  30. }
  31. return 0;
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment