179.LK's problem
来源:互联网 发布:综漫 收集数据做主神 编辑:程序博客网 时间:2024/06/06 07:09
LK's problem
时间限制:3000 ms | 内存限制:65535 KB难度:1- 描述
- LK has a question.Coule you help her?It is the beginning of the day at a bank, and a crowd of clients is already waiting for the entrance door to open. Once the bank opens, no more clients arrive, and tellerCount tellers begin serving the clients. A teller takes serviceTime minutes to serve each client. clientArrivals specifies how long each client has already been waiting at the moment when the bank door opens. Your program should determine the best way to arrange the clients into tellerCount queues, so that the waiting time of the client who waits longest is minimized. The waiting time of a client is the sum of the time the client waited outside before the bank opened, the time the client waited in a queue once the bank opened until the service began, and the service time of the client. Return the minimum waiting time for the client who waits the longest.
- 输入
- The input will consist of several test cases. For each test case, one integer N (1<= N <= 100) is given in the first line. Second line contains N integers telling us the time each client had waited.Third line contains tow integers , teller's count and service time per client need. The input is terminated by a single line with N = 0.
- 输出
- For each test of the input, print the answer.
- 样例输入
21 21 10110 50 500
- 样例输出
2160
- 来源
- TOPCODER
- 上传者
- iphxer
LK's problem
时间限制:3000 ms | 内存限制:65535 KB
难度:1
LK has a question.Coule you help her?
It is the beginning of the day at a bank, and a crowd of clients is already waiting for the entrance door to open.
Once the bank opens, no more clients arrive, and tellerCount tellers begin serving the clients. A
teller takes serviceTime minutes to serve each client. clientArrivals specifies how long each client has already been waiting at the moment when the bank door opens. Your program should determine the best way to arrange the clients into tellerCount queues, so that the waiting time of the client who waits longest is minimized. The waiting time of a client is the sum of the time the client waited outside before the bank opened, the time the client waited in a queue once the bank opened until the service began, and the service time of the client. Return the minimum waiting time for the client who waits the longest.
- 输入
- The input will consist of several test cases. For each test case, one integer N (1<= N <= 100) is given in the first line. Second line contains N integers telling us the time each client had waited.Third line contains tow integers , teller's count and service time per client need. The input is terminated by a single line with N = 0.
- 输出
- For each test of the input, print the answer.
- 样例输入
21 21 10110 50 500
- 样例输出
2160
- 来源
- TOPCODER
- 上传者
- iphxer
思路:按等待时间从大到小进行排列,再依次加上服务时间(等待时间长的先开始被服务),求出每个客户所需时间(其中有些明显时间更短者不被记录),再排序输出时间最大的那个即可。
#include<iostream>#include<algorithm>using namespace std;int main() { int N; while(cin >> N && N) { int a[105]={0}, b[105]={0}; for(int z = 0; z < N; z++) cin >> a[z]; sort(a, a+N); int x, y, i, j; cin >> x >> y; //x表示的是出纳员的人数 for(i = N-1, j = 0; i >= 0; i=i-x, j++) { b[j] = a[i]+y*(j+1); } sort(b, b+j, greater<int>() ); cout << b[0] << endl; }}
阅读全文
0 0
- 179.LK's problem
- LK's problem 05
- NYOJ 179 LK's problem
- NYOJ 179 LK's problem
- NYOJ 179 LK's problem ......
- NYOJ 179题 LK's problem
- NYOJ 179 LK's problem【贪心】
- NYOJ 179-LK's problem【模拟】
- NYOJ 179 LK's problem (排序模拟)
- NYOJ 179 LK‘problem
- LK ARM64 start.S处理
- LK ARM64 asm.S处理
- LK源码解析 1 crt0.s
- LK源码解析 8 exceptions.S
- LK
- lk
- Problem S
- Problem-S
- java公平锁源码解读
- 深度学习最全优化方法总结比较(SGD,Adagrad,Adadelta,Adam,Adamax,Nadam)
- 翻转单词顺序列
- 2017.9.3
- [BZOJ]5000: OI树 倍增
- 179.LK's problem
- 指针和数组与sizeof运算符(嵌入式笔试必考题)
- 面试技巧,如何通过索引说数据库优化能力,内容来自Java web轻量级开发面试教程
- SER2016 DIV1 B, K 题解
- Java IO : 流,以及装饰器模式在其上的运用
- HDU
- JS函数与获取本地时间与倒计时
- Singing-Voice Separation from Monaural Recordings using Deep Recurrent Neural Networks论文笔记
- EasyUI之data-options