案例过了,但是全WA
  • 板块P5143 攀爬者
  • 楼主34adaw_a
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/3/1 17:35
  • 上次更新2024/3/1 17:38:03
查看原帖
案例过了,但是全WA
1011774
34adaw_a楼主2024/3/1 17:35
#include <bits/stdc++.h>
using namespace std;
int n;
struct location
{
    int x;
    int y;
    int z;
}lt[50001];

bool cmp(location& lt1,location& lt2)
{
    return lt1.z<lt2.z;
}

int main()
{
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin>>lt[i].x>>lt[i].y>>lt[i].z;
    }
    sort(lt,lt+n-1,cmp);
    double ans=0;
    for(int i=0;i<n-1;i++)
    {
        ans+=sqrt(pow(lt[i].x-lt[i+1].x,2)+pow(lt[i].y-lt[i+1].y,2)+pow(lt[i].z-lt[i+1].z,2));
    }
    printf("%.3f",ans);

    return 0;
}

2024/3/1 17:35
加载中...