Autox笔试笔记(键盘距离&追车问题)

本文记录了Autox笔试中遇到的两个技术问题:追车问题和键盘数字问题。追车问题涉及动态规划和速度计算,而键盘数字问题探讨了计算按键之间距离的策略。通过分析和解决这些问题,展示了c++在算法实现上的应用。
摘要由CSDN通过智能技术生成

追车问题:

//追车问题
#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
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值