tije
2025-11-07 21:09:28
发布于:安徽
9阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int main(){
// 读取五道菜的制作时间
vector<int> times(5);
for (int i = 0; i < 5; ++i) {
cin >> times[i];
}
// 初始化最小时间为最大值
int min_total = INT_MAX;
// 生成所有可能的点菜顺序(全排列)
sort(times.begin(), times.end());
do {
int current_time = 0;
for (int t : times) {
// 计算当前订单的下单时间(向上取整到最近的10的倍数)
if (current_time % 10 != 0) {
current_time = (current_time / 10 + 1) * 10;
}
// 计算送达时间
current_time += t;
}
// 更新最小的最终送达时间
if (current_time < min_total) {
min_total = current_time;
}
} while (next_permutation(times.begin(), times.end()));
cout << min_total << endl;
return 0;
}
全部评论 1
求点赞
2025-11-07 来自 安徽
1

有帮助,赞一个