追车问题:
//追车问题
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
// Complete the MaximumArriveAtSameTime function below.
class Solver{
public:
static bool compare(const pair<double, double>& left, const pair<double, double>& right) {
return left.first > right.first;
}
int MaximumArriveAtSameTime(vector<double>& speed, vector<double>& location, double destination) {
int n = location.size();
//计算每个车到达终点所需时间
vector<double> times(n, 0);
for (int i = 0; i < n; i++) {
double time = (destination - location[i]) / speed[i];
times[i] = time;
}
//根据位置对时间进行排序
vector<pair<double