Advertisement
noshin98

uva 11900

Feb 5th, 2017
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int c,n,p,q,b,i,j,a[30],sum;
  5. while(scanf("%d",&c)==1)
  6. {
  7. for(j=1;j<=c;j++)
  8.  {
  9.  b=0;
  10.  sum=0;
  11.  scanf("%d%d%d",&n,&p,&q);
  12.  for(i=0;i<n;i++)
  13.   {scanf("%d",&a[i]);}
  14.  if(p>n)
  15.   {p=n;}
  16.  for(i=0;i<p;i++)
  17.   {sum=sum+a[i];}
  18.  for(i=sum;i>q;i=i-a[p-b])
  19.   {b=b+1;}
  20.  printf("Case %d: %d\n",j,p-b);
  21.  }
  22. }
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement