10611 - The Playboy Chimp

All about problems in Volume CVI. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Postby arsalan_mousavian » Tue Sep 26, 2006 10:40 pm

try this input :
Code: Select all
5 1
5 5 5 5 5
5

the output should be :
Code: Select all
X X

Hope it Helps . . .
In being unlucky I have the record.
User avatar
arsalan_mousavian
Experienced poster
 
Posts: 111
Joined: Mon Jan 09, 2006 6:19 pm
Location: Tehran, Iran

WHY P.E. ?

Postby nymo » Thu Dec 14, 2006 7:11 pm

I think, arsalan_mousavian wished to say:
Code: Select all
5
5 5 5 5 5
1
5


... anyway, I am getting P.E. on this problem, What is the expected format?
I tried:
Code: Select all
      if(!lower)
         printf("%c ", 'X');
      else
         printf("%ld ", lower);
      if(!higher)
         printf("%c", 'X');
      else
         printf("%ld", higher);


... and I 've tried both with printing newline after the last case and without it.
regards,
nymo
nymo
Experienced poster
 
Posts: 149
Joined: Sun Jun 01, 2003 8:58 am
Location: :)

Re: WHY P.E. ?

Postby helloneo » Thu Dec 14, 2006 7:27 pm

nymo wrote:... anyway, I am getting P.E. on this problem, What is the expected format?


What I did was pretty much like this..

Code: Select all
   while (qn--) {

      if(!lower)
         printf("%c ", 'X');
      else
         printf("%ld ", lower);
      if(!higher)
         printf("%c", 'X');
      else
         printf("%ld", higher);
      printf("\n");
   }
helloneo
Guru
 
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Thanks :)

Postby nymo » Fri Dec 15, 2006 12:26 pm

Thanks helloneo, I get ACC. As far as I recall, I pretty much did the same thing and got P.E. and then I changed to different formats... Don't know what is changed... anyway, ACC now and thanks.
regards,
nymo
nymo
Experienced poster
 
Posts: 149
Joined: Sun Jun 01, 2003 8:58 am
Location: :)

Postby turcse143 » Thu Feb 21, 2008 12:06 pm

Sanjana look it.
this is the sample input:
Code: Select all
4
1 4 5 7
4
4 6 8 10

1
1
1
1

3
1 3 3
2
1
3

5
5 5 5 5 5
1
5

output:
1 5
5 7
7 X
7 X
X X
X 3
1 X
X X

hope it helps.
''I want to be most laziest person in the world''
turcse143
Learning poster
 
Posts: 81
Joined: Wed May 09, 2007 9:59 pm
Location: (CSE,DU) Dhaka,Bangladesh

Re: 10611 - The Playboy..(WA)works well for all input in board.

Postby kbr_iut » Fri May 02, 2008 11:51 pm

code deleted after AC
Last edited by kbr_iut on Wed Sep 10, 2008 9:55 am, edited 1 time in total.
It is tough to become a good programmer.
It is more tough to become a good person.
I am trying both...............................
User avatar
kbr_iut
Experienced poster
 
Posts: 103
Joined: Tue Mar 25, 2008 11:00 pm
Location: IUT-OIC, DHAKA, BANGLADESH

Re: 10611 - The Playboy Chimp

Postby Jan » Sat May 03, 2008 2:12 pm

Why 25003? Read the description again.
Ami ekhono shopno dekhi...
HomePage
Jan
Guru
 
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh

Re: 10611 - The Playboy Chimp(array size changed but now TLE)

Postby kbr_iut » Sat May 03, 2008 6:43 pm

sorry ,,,,,for array size..
but when i increased array size i got TLE...pliz tell me,is my proceed is right?
I used binary search method to find where start==end...then i evaluate the greatest but smaller than the number and smallest and the greater than the number.
i took consider when there is repeated number.
pliz tell me......
It is tough to become a good programmer.
It is more tough to become a good person.
I am trying both...............................
User avatar
kbr_iut
Experienced poster
 
Posts: 103
Joined: Tue Mar 25, 2008 11:00 pm
Location: IUT-OIC, DHAKA, BANGLADESH

Re: 10611 - The Playboy Chimp

Postby Jan » Sun May 04, 2008 12:56 am

'Binary search' is enough for solving this problem. However, check the boundary cases carefully.
Ami ekhono shopno dekhi...
HomePage
Jan
Guru
 
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh

Re: 10611 - The Playboy Chimp

Postby kbr_iut » Sun May 04, 2008 8:10 am

thanx via.Now AC...
It is tough to become a good programmer.
It is more tough to become a good person.
I am trying both...............................
User avatar
kbr_iut
Experienced poster
 
Posts: 103
Joined: Tue Mar 25, 2008 11:00 pm
Location: IUT-OIC, DHAKA, BANGLADESH

Re: 10611 - The Playboy Chimp

Postby fido19 » Fri Aug 01, 2008 12:31 am

hi guys i was wondering if this problem is solvable in python language if anyone knows this could they post the code as my code doesent work and i have no idea how to solve it please someone out there who knows it can help me
fido19
New poster
 
Posts: 1
Joined: Fri Aug 01, 2008 12:27 am

It`s not Impossible

Postby vahid sanei » Mon Feb 09, 2009 10:33 am

i solved this problem with cin and cout in 0.430 sec
and with scanf and printf in 0.060 sec
how can i reduce time of my algorithm? ( i use Binary search for this pb)
thanks in advance :wink:
Impossible says I`m possible
User avatar
vahid sanei
Learning poster
 
Posts: 84
Joined: Fri Jan 09, 2009 4:37 pm
Location: IRAN

Re: 10611 - The Playboy Chimp

Postby shaon_cse_cu08 » Thu Jun 23, 2011 8:56 pm

I have modified my binary search algorithm...that is even if it can't find the data it always return nearest location.... I got it AC in 0.036 s .... Plz be careful using this code...Coz the nearest location can be either smaller or the greater one....

Code: Select all
long b_src(long a[],long n,long x)      //a[] is the array...it can be made global...   
{                        //n is the total elements....x is what i m looking for..      
   int ini,end,mid;

   ini=0;
   end=n-1;

   while(ini<=end)
   {
      mid=(ini+end)/2;

      if(x==a[mid])
         return (mid);            
      
      else if(x>a[mid])
         ini=mid+1;
      
      else
         end=mid-1;
   }

return mid;                                     //it always returns something (In case of binary search 'return 0')
}
It's not who i m inside me... But what i do, that defines me...:)
shaon_cse_cu08
New poster
 
Posts: 46
Joined: Tue May 25, 2010 9:10 am

Previous

Return to Volume CVI

Who is online

Users browsing this forum: No registered users and 0 guests