Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Bismillahir Rahmanir Rahim */
- /*Coder: Ahmad Faiyaz*/
- #include <algorithm>
- #include <cctype>
- #include <cmath>
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <iostream>
- #include <map>
- #include <queue>
- #include <set>
- #include <sstream>
- #include <stack>
- #include <string>
- #include <vector>
- # define FOR(i, a, b) for (int i=a; i<b; i++)
- # define REP(i, a) FOR(i,0,a)
- #define EPS 1e-11
- #define inf ( 1LL << 31 ) - 1
- #define LL long long
- #define abs(x) (((x)< 0) ? (-(x)) : (x))
- #define all(x) (x).begin(), (x).end()
- #define ms(x, a) memset((x), (a), sizeof(x))
- # define VI vector<int>
- # define VS vector<string>
- # define VC vector<char>
- #define mp make_pair
- #define pb push_back
- #define sz(k) (int)(k).size()
- #define FORIT(i,m) for(__typeof((m).begin()) i=(m).begin();i!=(m).end();i++)
- #define vlong long long
- using namespace std;
- long long v [2005];
- int main(){
- int t,chk=1,n;
- scanf("%d",&t);
- while(t--){
- scanf("%d",&n);
- //vector<long long int>::iterator low,up;
- int low,up;
- for(int i=0;i<n;i++){
- scanf("%lld",&v[i]);
- }
- sort(v,v+n);
- int count=0;
- for(int i=0;i<n;i++){
- for(int j=i+1;j<n;j++){
- // low=lower_bound(v,v+n,sum);
- // up=upper_bound(v,v+n,v[j]);
- // int c=int(low-v.begin());
- // int d=int(up-v.begin());
- count+=(lower_bound(v,v+n,v[i]+v[j])-upper_bound(v,v+n,v[j]));
- }
- }
- printf("Case %d: %d\n",chk++,count);
- }
- }
Add Comment
Please, Sign In to add comment