#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int cases;
cin >> cases;
for(int count = 0; count < cases; count++) {
int persons, floors, boxLeft;
cin >> persons >> floors >> boxLeft;
int time[persons];
for(int i = 0; i < persons; i++) {
int tmp1, tmp2;
cin >> tmp1 >> tmp2;
if(tmp2) {
time[i] = 3 * floors - tmp1;
}
else {
time[i] = floors + tmp1;
}
}
sort(time, time+persons);
int totalTimeLeft;
if(boxLeft % persons) {
totalTimeLeft = boxLeft / persons * 2 * floors + time[boxLeft % persons - 1];
}
else {
totalTimeLeft = (boxLeft / persons - 1) * 2 * floors + time[persons - 1];
}
cout << totalTimeLeft << endl;
}
return 0;
}
1193. Up the Stairs
最新推荐文章于 2025-12-18 17:00:31 发布
本文介绍了一个楼层疏散模拟算法,该算法通过输入人员数量、楼层高度和剩余箱子数等参数,计算出最佳疏散策略及所需时间。算法首先获取每个人员到达顶层的时间,并对其进行排序,然后根据剩余箱子数计算出总疏散时间。
953

被折叠的 条评论
为什么被折叠?



