#include #include using namespace std;

double cal(int n, int d[], int m[]) { double time = 0; pair<int, int> road[n]; for (int i = 0; i < n; i++) { road[i].first = m[i]; road[i].second = d[i]; } sort(road, road + n); for (int i = n - 1; i >= 0; i--) { time += 30 * road[i].first + 0.9 * road[i].second; } return time; }

/Program int main() { int n = 3; int d[] = {180, 225, 270}; int m[] = {4, 5, 3}; cout << cal(n, d, m) << endl; return 0; } End

现在有n条道路需要士兵去排查地雷每条道路长度不同且埋藏有不同数量的地雷。假设道路长度为d_i米士兵行进速度为09米秒道路中地雷数量为m_i个平均排雷时间为30秒个。注意:n条道路的排雷任务同步进行。问题:排查完全部地雷共需要多长时间单位:秒?例如:有3条道路长度分别为180米、225米和270米道路上分别有4、5、3颗地雷则排查完全部地雷共需要400秒。请完成以下函数功能:double calin

原文地址: https://www.cveoy.top/t/topic/hbCV 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录