@MAYANK your output format is wrong.use printf("\nScenario #%d:\n",(i+1));
and
if(sum <sta)
On Thu, Jun 21, 2012 at 12:34 PM, Mayank Singh
<[email protected]>wrote:

> here is my code
> /*#include<stdio.h>
> #include<conio.h>
>
> int main()
> {
>     int cand,sum;
>     int T,N,i,j,temp[100000];
>     scanf("%d",&T);
>
>     sum = 0;
>     for(i=0;i<T;i++)
>     {
>         scanf("%d",&N);
>         for(j=0;j<N;j++)
>         {
>             scanf("%d",&cand);
>             sum = (sum+cand)%N;
>         }
>         if(sum == 0)
>             temp[i]=1;
>         else
>             temp[i]=0;
>     }
>     for(i=0;i<T;i++)
>     {
>         if(temp[i]==1)
>             printf("YES\n");
>         else
>             printf("NO\n");
>     }
>     return 0;
> }*/
>
> #include<stdio.h>
> #include<stdlib.h>
>
> int main()
> {
>     int t,frd,i,j,arr[10000],sum,k,arr1[100000],p;
>     scanf("%d",&t);
>     long int sta;
>     for(i=0;i<t;i++)
>     {
>         scanf("%ld",&sta);
>         scanf("%d",&frd);
>         for(j=0;j<frd;j++)
>         {
>             scanf("%d",&arr[j]);
>         }
>         for(j=0;j<frd;j++)
>         {
>               for(k=0;k<frd-1;k++)
>             {
>                     if(arr[k]<arr[k+1])
>                   {
>                           sum = arr[k];
>                         arr[k] = arr[k+1];
>                         arr[k+1] = sum;
>                   }
>             }
>         }
>
>         sum = 0;
>         p=0;
>         for(k=0;k<frd;k++)
>         {
>             if(sum <= sta)
>             {
>                 sum = sum+arr[k];
>                 p++;
>             }
>             else
>                 break;
>         }
>         if(sum < sta)
>             arr1[i] = 0;
>         else
>             arr1[i] = p;
>     }
>     for(i=0;i<t;i++)
>     {
>         printf("\nScenario #%d\n:",(i+1));
>         if(arr1[i] == 0)
>             printf("impossible\n");
>         else
>             printf("%d\n",arr1[i]);
>     }
>     return 0;
> }
>
> i am getting WA . plz help me...
>
>   thanx
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
pardeep kumar

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to