Advertisement
Farjana_akter

Untitled

Mar 13th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int t,i,j,k,l,m,a[3000],b,c,d,e;
  7. cin>>t;
  8. for(m=1;m<=t;m++)
  9. {
  10. cin>>b;
  11. for(i=0;i<b;i++)
  12. cin>>a[i];
  13. sort(a,a+b);
  14. int count=0;
  15. for(i=0;i<b-2;i++)
  16. {
  17. for(j=i+1;j<b-1;j++)
  18. {
  19. for(k=j+1;k<b;k++)
  20. {
  21. if(a[k]<a[i]+a[j])
  22. count++;
  23. }
  24. }
  25. }
  26. cout<<"Case "<<m<<": "<<count<<endl;
  27. }
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement