i am getting 1.....room pe aa btata hun..

On Sat, Mar 12, 2011 at 9:25 AM, UTKARSH SRIVASTAV
<[email protected]>wrote:

> then what should be the answer of the test case 1 3 5 . i am getting 2 as
> answer
>
>
> On Sat, Mar 12, 2011 at 2:22 AM, Balaji Ramani 
> <[email protected]>wrote:
>
>> Try with trees at 1 3 and 5. Gives wrong output: http://ideone.com/KHUdT
>>
>> And after you fix that if you still get TLE, there is a simpler way to
>> solve this.
>>
>> Thanks,
>> Balaji.
>>
>>
>> On Sat, Mar 12, 2011 at 12:55 AM, UTKARSH SRIVASTAV <
>> [email protected]> wrote:
>>
>>> CAN ANYONE PLEASE TELL ME WHICH TEST CASE IS WRONG .................
>>>  PROBLEM:    https://www.spoj.pl/problems/STREETR/
>>> #include<stdio.h>
>>> main()
>>> {
>>>     long long int n,i,ans,k,flag,m,a[100100],d;
>>>     scanf("%lld",&n);
>>>     for(i=0;i<n;i++)
>>>     {
>>>         scanf("%lld",&a[i]);
>>>     }
>>>     d=a[1]-a[0];
>>>     m=1;
>>>     while(d>0)
>>>     {
>>>         m=1;
>>>         ans=0;
>>>         flag=1;
>>>         for(i=1;i<n;i++)
>>>         {
>>>             if((a[i]-a[0])%d==0)
>>>             {
>>>             k=(a[i]-a[0])/d+1;
>>>             ans=ans+(k-m-1);
>>>             m=k;
>>>             }
>>>             else
>>>             {
>>>             flag=0;
>>>             break;
>>>             }
>>>         }
>>>         if(flag==0||ans==0)
>>>         d=d-1;
>>>         else
>>>         {
>>>     //        h=0;
>>>             break;
>>>         }
>>>     }
>>>     printf("%lld\n",ans);
>>>     return 0;
>>> }
>>>
>>>
>>>
>>>
>>> --
>>> UTKARSH SRIVATAV
>>> CSE-3
>>> B-TECH 2nd YEAR
>>> MNNIT ALLAHABAD
>>>
>>>  --
>>> 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.
>>>
>>
>>  --
>> 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.
>>
>
>
>
> --
> UTKARSH SRIVATAV
> CSE-3
> B-TECH 2nd YEAR
> MNNIT ALLAHABAD
>
>  --
> 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.
>

-- 
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