Files
python/TangDou/LanQiaoBei/LanQiao14STEMA202211/3.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

43 lines
1.1 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
/*
测试用例I:
7
3 5 2 4 7 1 6
整体时长
10 12 6
答案:6
--------
测试用例II:
2
1 100
期望答案:0
*/
using namespace std;
int a[4]; //每个窗口的工作累加时长
int n, b[60]; // n:客户个数,b[i]:i这个客户办理业务需要的时长
int p; //现在该轮到哪个用户办理了
int main() {
cin >> n;
for (int i = 1; i <= n; i++) cin >> b[i];
// 1、计时器,不喜欢while(true),用for循环替代
for (int t = 0;; t++) {
// 2、哪个窗口办理完毕
for (int i = 1; i <= 3; i++) {
if (a[i] == t) { //如果累计时长等于当前时长,说明现在正好办理完毕
a[i] += b[++p]; //将i窗口安排上++p这个客户,增加b[++p]的时长
if (p > n) { //到当前窗口时,没有客户了,说明当前窗口是最早结束任务的,直接输出当前的时间
cout << t << endl;
return 0;
}
}
}
}
return 0;
}