| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 776 人关注过本帖
标题:求指点??????????????????????
只看楼主 加入收藏
天天涯涯
Rank: 4
等 级:业余侠客
帖 子:215
专家分:267
注 册:2011-10-17
结帖率:94.74%
收藏
已结贴  问题点数:10 回复次数:10 
求指点??????????????????????
程序代码:
#include
double del(double a[],double time,int n)
{
  double minimum;
  int i,j;
  minimum=a[0]+n*time;
  for(i=1;i<N;I++)
    if(minimum<=a[i]+(n-i)*time)
      minimum=a[i]+(n-i)*time;
  return minimum;
}
int main()
{
  int i,n,j,count=0;
  double c[100],a[100],temp,b[2];
  scanf("%d",&n);
  while(n)
  {
     for(i=0;i<N;I++)
       scanf("%lf",&a[i]);
     for(i=0;i<2;i++)
       scanf("%lf",&b[i]);
     for(i=0;i<N;I++)
       for(j=0;j<N-1-I;J++)
      if(a[j]>=a[j+1])
      {
        temp=a[j];
        a[j]=a[j+1];
        a[j+1]=temp;
      }
     c[count]=del(a,b[1],n);
     count++;
     scanf("%d",&n);
  }
  for(i=0;i<COUNT;I++)
    printf("%g\n",c[i]);
  return 0;
}
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.
样例输入
2
1 2
1 10
1
10
50 50
0
************
上面代码的思路有没有错误???给点意见。。
搜索更多相关主题的帖子: minimum 
2011-12-17 13:44
天天涯涯
Rank: 4
等 级:业余侠客
帖 子:215
专家分:267
注 册:2011-10-17
收藏
得分:0 
谁有测试数据给点
2011-12-17 14:47
czz5242199
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:4
帖 子:660
专家分:2400
注 册:2011-10-26
收藏
得分:0 
看的有点绕,求解释下大概意思
2011-12-17 15:10
czz5242199
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:4
帖 子:660
专家分:2400
注 册:2011-10-26
收藏
得分:0 
哦,懂了,不用解释了。原来如此
2011-12-17 15:15
z364172655
Rank: 2
等 级:论坛游民
帖 子:22
专家分:38
注 册:2011-12-8
收藏
得分:1 
强烈要求LZ检查大小写!
2011-12-17 15:29
czz5242199
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:4
帖 子:660
专家分:2400
注 册:2011-10-26
收藏
得分:9 
你也没写你自己什么思路,我说一下我的思路吧,看是不是一样,就是对于机器从大到小排序,然后依次放在当前时间最小的人手上,可以用数组处理,考虑到每个人都一样,所以可以直接m个人一次循每人修一天机器转。
程序代码:
#include<stdio.h>

int n,a[110];

int main()
{
    while (scanf("%d",&n),n!=0)
    {
          int i,j,k,t,m,p,ans;
          for (i=1; i<=n; i++) scanf("%d",a+i);
          for (i=1; i<n; i++)
          {
              j=i;
              for (k=i+1; k<=n; k++)
                if (a[k]>a[j]) j=k;
              t=a[i]; a[i]=a[j]; a[j]=t;
          }
          scanf("%d%d",&m,&p);
          ans=0;
          for (i=1; i<=n; i++)
            if (ans<((i-1)/m+1)*p+a[i]) ans=((i-1)/m+1)*p+a[i];
          printf("%d\n",ans);
    }
    return 0;
}

2011-12-17 15:31
天天涯涯
Rank: 4
等 级:业余侠客
帖 子:215
专家分:267
注 册:2011-10-17
收藏
得分:0 
大小写没有问题,粘贴的时候出问题了。
2011-12-17 18:55
天天涯涯
Rank: 4
等 级:业余侠客
帖 子:215
专家分:267
注 册:2011-10-17
收藏
得分:0 
思路是先把数据从小到大排序,遵循先来后到的原则,计算每个人从来到走所用的时间。
2011-12-17 18:59
天天涯涯
Rank: 4
等 级:业余侠客
帖 子:215
专家分:267
注 册:2011-10-17
收藏
得分:0 
回复 6楼 czz5242199
结果是21   60,能不能你把你的思路再说清楚一点。
2011-12-17 19:43
czz5242199
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:4
帖 子:660
专家分:2400
注 册:2011-10-26
收藏
得分:0 
贪心算法,就是把数据先从大到小排序,然后每次找到当前时间最小的人,就把这个client给这个人修理,同时更新这个人的当前时间,但是这个题目也有特殊性,就是每个人都是无区别的,利用这一点可以稍加优化一个时间复杂度
2011-12-17 20:10
快速回复:求指点??????????????????????
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016816 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved