mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-27 20:16:29 +00:00
P5143 攀爬者
R38821808
This commit is contained in:
parent
7eab5ffb7f
commit
aa89a19d58
37
problem/P5143/P5143.cpp
Normal file
37
problem/P5143/P5143.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
// R38821808
|
||||
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct node {
|
||||
int x, y, z;
|
||||
|
||||
node() {
|
||||
x = y = z = 0;
|
||||
}
|
||||
};
|
||||
|
||||
double ed(node a, node b) {
|
||||
return sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2) + pow(a.z - b.z, 2));
|
||||
}
|
||||
|
||||
bool cmp(node a, node b) {
|
||||
return a.z <= b.z;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int n;
|
||||
node a[50005];
|
||||
double ans = 0.000;
|
||||
scanf("%d", &n);
|
||||
for(int i = 0 ; i < n ; i++) {
|
||||
scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].z);
|
||||
}
|
||||
sort(a, a+n, cmp);
|
||||
for(int i = 1 ; i < n ;i++) {
|
||||
ans += ed(a[i-1], a[i]);
|
||||
}
|
||||
printf("%.3lf", ans);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user