Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int t,i;
- scanf("%d",&t);
- for(i=1;i<=t;i++){
- int n,x,j,k;
- long long int cnt;
- scanf("%d",&n);
- vector<int>vt;
- for(j=0;j<n;j++){
- scanf("%d",&x);
- vt.push_back(x);
- }
- cnt=0;
- sort(vt.begin(),vt.end());
- for(j=0;j<n-2;j++){
- for(k=j+1;k<n-1;k++){
- int l=upper_bound(vt.begin(),vt.end(),vt[j]+vt[k]-1)-vt.begin()-1;
- cnt=cnt+l-k;
- }
- }
- printf("Case %d: %lld\n",i,cnt);
- vt.clear();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement