The mell hell
%lld & %llu

Description

In Uniquity is insured by the given data.
 

Input

There are multiple test cases.
For each case, the first line contains one integer N(intergers B[i](0<B[i]<10).
(B[i] < 10 < A[i]*b[i])   (Please pay attention to the range, it is useful on this problem)
 

Output

You are asked to output the original location in the queue of the person who will cost the longest time under optimal solution. 
Uniquity is insured by the given data.
 

Sample Input

3
15  20  25
1  3  2

Sample Output

2


题目有个巨大的陷阱,其实不是用动态规划做的。m(i)=A[1]*A[2]*…A[i-1]/B[i] ,只要A[i]*B[i]最大,那么他就一定排在最后一位,而最后一位等
待的时间最长,所以若要最小化等待时间最长的人的时间,一定要最大化A[i]*B[i]的值
其实也应该早注意到题目中的一句话“(B[i] < 10 < A[i]*b[i]) (Please pay attention to the range, it is useful on this problem)”

 其实不用排序的,只要找到最大值就好了,我只是讲错误的代码改的时候方便了下,这样还是很耗时的==

 1 # include<stdio.h>
 2 # include<stdlib.h>
 3 int n;
 4 struct node{
 5     int x,y,num;
 6     int f;
 7 }s[1005];
 8 int cmp(const void *a,const void *b)
 9 {
10     struct node * aa =(node *)a;
11     struct node * bb=(node *)b;
12         return bb->f - aa->f;
13 }
14 int main()
15 {
16     int i;
17     while(scanf("%d",&n)!=EOF)
18     {
19         for(i=0;i<n;i++)
20             scanf("%d",&s[i].x);
21         for(i=0;i<n;i++)
22         {
23             scanf("%d",&s[i].y);
24             s[i].f=s[i].x*s[i].y;
25             s[i].num=i+1;
26         }
27         qsort(s,n,sizeof(s[0]),cmp);
28         printf("%d\n",s[0].num);
29     }
30     return 0;
31 }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-01
  • 2021-08-20
  • 2022-03-05
  • 2022-01-11
猜你喜欢
  • 2022-01-16
  • 2022-12-23
  • 2021-12-08
  • 2022-02-11
  • 2022-01-28
相关资源
相似解决方案