General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
134781728 Practice:
SourabhCh
1495A - 15 C++14 (GCC 6-32) Time limit exceeded on test 4 1000 ms 3776 KB 2021-11-09 20:00:02 2021-11-09 20:00:03
→ Source
#include <bits/stdc++.h>
using namespace std;
/*---------------------------------------------------------------------------------------------*/
#define input(arr,n)       for(int i=0;i<n;++i) cin>>arr[i];
#define output(arr,n)      for(int i=0;i<n;++i){cout<<arr[i]<<" ";}cout<<"\n";         
#define sz(x)              ((int)(x).size())
#define all(x)             (x).begin(),(x).end()
#define pb(a)              push_back(a)
#define mp(a,b)            make_pair(a,b)
#define put(a)             cout<<a<<'\n'
#define rev                greater<int>()
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
const ll inf=1e18;
const int mod = 1e9 + 7;
/*----------------------------------------------------------------------------------------------*/
ll power(ll x, ll y){ll result = 1;while(y>0){if (y % 2 == 0){x = x * x;y = y / 2;}else{result = result * x;y = y - 1;}}return result;}
bool isPowerof2(ll n){if(n==0) return 0;if(n==1) return 0;return ((n&(~(n-1)))==n);}
bool isPrime(ll n){for(ll i=2;(i*i)<=n;++i) if(n%i==0) return 0;return 1;}
ll lcm(ll a,ll b){return(ll)((a*b)/__gcd(a,b));}
ll sumTillN(ll n){return(n*(n+1))>>1;}
/*----------------------------------------------------------------------------------------------*/
//1. 1ll<<x is same as pow(2,x)
//2. 1<<i refering to ith pos in a number's binary rep
// eg.  n&(1<<i)

void solve(){
    int n;cin>>n;
    vector<double> m,d;
    double x,y;
    for(int i=0;i<(n<<1);++i){
        cin>>x>>y;
        if(x==0) m.pb(abs(y));
        else d.pb(abs(x));
    }
    sort(all(m)),sort(all(d));
    double ans=0.0;

    for(int i=0;i<n;++i){
        ans+=(sqrt((m[i]*m[i])+(d[i]*d[i])));
    }

    cout<<fixed<<setprecision(15)<<ans<<'\n';
}

int main(){   
    /* fast Input-Output  */
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    /* Test Cases  */
    ll t;cin>>t;
    while(t--)
        solve();
}

// Hello, my name is gotya....
// nice to meet ya....
//    __          __
//    \ \        / /
//     \ \      / /
//     (```````````)
//    /(  ^  _  ^  )\
//   //(___________)\\
//  //   | |    | |  \\
//       |_|    |_|
//       \_\    /_/
//    
// since you are checking my master's solution
// if you have any doubts then help yourself..
// kidding, he is always ready to help...feel free to ask :)
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details