No, You should write Case #N: IMPOSSIBLE

(Where N is your case number.)



On Tue, Jan 22, 2013 at 5:50 PM, mandeep <[email protected]> wrote:

> If it is impossible to make a profit given the market trends, you should
> output IMPOSSIBLE.
>
>
>
> On 22 January 2013 17:36, Satyajit Bhadange 
> <[email protected]>wrote:
>
>> if(min>m)
>>     {
>>         System.out.println("IMPOSSIBLE");
>>     }
>>
>> for which case ?
>>
>>
>> On Tue, Jan 22, 2013 at 5:25 PM, mandeep khatkar <[email protected]>wrote:
>>
>>> someone plz modify this code i am getting an error "your output should
>>> start with Case #1:"
>>> and here is the link to problem
>>> http://code.google.com/codejam/contest/837485/dashboard#s=p1
>>> and below is my solution...thanks in advance...
>>>
>>> package chef;
>>>
>>> import java.io.BufferedReader;
>>> import java.io.IOException;
>>> import java.io.InputStreamReader;
>>> import java.util.StringTokenizer;
>>>
>>> /*
>>>  * To change this template, choose Tools | Templates
>>>  * and open the template in the editor.
>>>  */
>>>
>>> /**
>>>  *
>>>  * @author Pardeep
>>>  */
>>> public class chefworld {
>>>     static int len=12;
>>>
>>>     static BufferedReader br=new BufferedReader(new
>>> InputStreamReader(System.in));
>>>
>>>     static StringTokenizer st;
>>>
>>>     public static void main(String a[]) throws IOException
>>>    {
>>>     int n=Integer.parseInt(br.readLine());
>>>
>>>     for(int j=1;j<=n;j++)
>>>     {
>>>            int m=Integer.parseInt(br.readLine());
>>>     //System.out.println("value of m is:"+m);
>>>     int max,min,minpos=0,maxpos=0;
>>>     int arr[]=new int[len];
>>>     int profit=0;
>>>     st=new StringTokenizer(br.readLine());
>>>     for(int i=0;st.hasMoreTokens();i++)
>>>     {
>>>         arr[i]=Integer.parseInt(st.nextToken());
>>>        // System.out.println(i+"element is"+arr[i]);
>>>     }
>>>     min=(max=arr[0]);
>>>     //System.out.println(min+" "+max);
>>>     //max=min;
>>>     for(int i=1;i<len-1;i++)                             //to find max
>>> element and it's position
>>>     {
>>>         if(max<=Math.max(arr[i], arr[i+1]))
>>>         {
>>>             max=Math.max(arr[i], arr[i+1]);
>>>             if(max==arr[i])
>>>             {
>>>                 maxpos=i;
>>>             }
>>>             else
>>>             {
>>>                 maxpos=i+1;
>>>             }
>>>         }
>>>
>>>     }
>>>     for(int i=0;i<maxpos;i++)                           //to find
>>> minimum element and its position
>>>     {
>>>         if(min>=Math.min(arr[i], arr[i+1]))
>>>         {
>>>             min=Math.min(arr[i], arr[i+1]);
>>>             if(min==arr[i])
>>>             {
>>>                 minpos=i;
>>>             }
>>>             else
>>>             {
>>>                 minpos=i+1;
>>>             }
>>>         }
>>>     }
>>>     if(min>m)
>>>     {
>>>         System.out.println("IMPOSSIBLE");
>>>     }
>>>     else
>>>     {
>>>         int d=m/arr[minpos];
>>>         profit=d*(arr[maxpos]-arr[minpos]);
>>>         System.out.println("Case #"+j+": "+(minpos+1)+" "+(maxpos+1)+"
>>> "+" "+profit);
>>>     }
>>>     }
>>>     //System.out.println("min is: "+min+"pos is:"+minpos+" "+"max is
>>> "+max+"pos is"+maxpos);
>>>    System.exit(0);
>>>
>>>    }
>>> }
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Google Code Jam" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msg/google-code/-/V2VzTzS8YCUJ.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>
>>
>> --
>>
>> Thanks & Regards,
>> *Satyajit Bhadange
>> Software Programmer*
>>
>> *Problems & Solutions* <http://www.satyajit-algorithms.com>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google Code Jam" 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 https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Google Code Jam" 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 https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" 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 https://groups.google.com/groups/opt_out.


Reply via email to