-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathc.cpp
More file actions
30 lines (27 loc) · 692 Bytes
/
c.cpp
File metadata and controls
30 lines (27 loc) · 692 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <bits/stdc++.h>
#define endl "\n"
#define eat cin
#define moo cout
using namespace std;
int T, N;
vector<double> m, d;
int32_t main(){
eat.tie(0) -> sync_with_stdio(0);
eat >> T;
while(T--){
m.clear(), d.clear();
eat >> N;
for(int i = 0; i < 2 * N; i++){
int x, y; cin >> x >> y;
if(x == 0) m.push_back(abs(y));
else d.push_back(abs(x));
}
sort(m.begin(), m.end());
sort(d.begin(), d.end());
long double ans = 0;
for(int i = 0; i < N; i++){
ans += sqrt(m[i] * m[i] + d[i] * d[i]);
}
moo << fixed << setprecision(15) << ans << endl;
}
}