2023年9月12日
今天太开心了。但是下午配置环境和写博客浪费太多时间了。
ACWING5219 猜测短跑运动员
题目理解
这个,用pair
存下来,然后排序,遍历就行了,取最大值。
代码实现
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
const int N = 1e5 + 10;
pair<double, double> p[N];
int main()
{
int n;
cin >> n;
for(int i = 1; i <= n; i++)
cin >> p[i].first >> p[i].second;
double res = 0;
double lt = p[1].first, now = p[1].second;
sort(p + 1, p + n + 1);
for(int i = 2; i <= n; i++)
{
res = max(res, (abs(p[i].second - now) / (p[i].first - lt)));
lt = p[i].first;
now = p[i].second;
}
printf("%.1lf", res);
return 0;
}