NYOJ 179题 LK's problem
来源:互联网 发布:华东理工大学网络 编辑:程序博客网 时间:2024/06/06 12:29
总的时间包括三部分:开门前的等待时间+排队的时间+teller服务的时间。
题目中: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 即 “你的程序应该决定安排clients进入tellerCount queues队的最好方法,使得 等待最长的client的等待时间是最小的” ;Return the minimum waiting time for the client who waits the longest 即 返回等待时间最长的人的 最小时间。
源代码:
#include<stdio.h>
int main()
{
int n;
while(scanf("%d", &n), n != 0)
{
int i,j,sum;
int a[200], t;
for(i = 1; i <= n; i ++)
scanf("%d", &a[i]);
for(i = 1; i < n; i++)//使用选择排序,注意起点改变了吗
for(j = i + 1; j < n+1; j ++)
if (a[i] < a[j])
{
t = a[i];
a[i] = a[j];
a[j] = t;
}
int tcount, servtim, num, m;
scanf("%d %d", &tcount, &servtim);
num = n / tcount;
m = n % tcount;
if(m == 0)
sum = a[(num-1)*tcount+1] + num * servtim;//这里需注意一下;
else
sum = a[1 + num * tcount] + (num + 1) * servtim;//这里也是;
printf("%d\n", sum);
}
return 0;
}
- 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
- NYOJ 179 LK's problem (排序模拟)
- LK's problem 05
- 179.LK's problem
- nyoj 291-LK的数学题
- NYOJ 291 LK的数学题
- nyoj-291-LK的数学题
- LK ARM64 start.S处理
- LK ARM64 asm.S处理
- LK源码解析 1 crt0.s
- LK源码解析 8 exceptions.S
- NYOJ---150题Train Problem I
- linux wget
- WebDriver拾级而上·之十八 设置元素焦点
- 有关C#抽象类
- 读书笔记:分布式敏捷开发 - Distributed Agile Development at Microsoft patterns & practices
- Problem 2:Even Fibonacci numbers
- NYOJ 179题 LK's problem
- Xmodem协议
- jquery选择器总结
- [完善]Android Push Notification实现信息推送使用
- javaScript学习笔记概述
- Android常用控件的基本使用方法
- 内核模块编程之模块工具的使用
- Java读取properties文件的简单方法
- Linux Init, Getty, Login