大疆创新笔试(2019-08-04)
- 第一题
#include <iostream>
#include <vector>
using namespace std;
//喝咖啡提高效率,可以将其等效为在原始工作效率下工作了更长时间
//可以认为刚开始在咖啡的加持下一直高效率工作,将8小时分为两段,一段高效率,一段正常效率。
int min_time(vector<int> bug_time, int efficient, int coffee_num){
int total_time = 0; // 总的解bug需要的时间
if(coffee_num > 8) // 咖啡数量大于8,按照8杯算
coffee_num = 8;
for (int bug_t : bug_time)
total_time += bug_t;
int time_spend = 0; // 已经花费的时间
// 每喝一杯咖啡,工作一小时相当于 efficient * 60 分钟的工作量
while (coffee_num && total_time){
total_time -= 60 * efficient;
coffee_num--;
time_spend += 60;
}
// 如果剩余时间太长了,认为不能完成
if (coffee_num == 0 && total_time > (8*60 - time_spend))
return 0;
// 要求最少花费