CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • February CookOff
    • February Long Contest
    • January CookOff
  • DISCUSS
    • Wiki
    • Forums
    • Blog
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
    • Event Calendar
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Ranks
    • Tutorials
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Compete » November 2009 (Contest X) » Help the DJ

Help the DJ

Problem code: JX

  • All Submissions

All submissions for this problem are available.

DJ N3xt0r could hardly sleep last night. He thought he was doing his job so well, but it seems like the dancers at the disco are looking for a whole different kind of music these days and the place has become nearly empty. Being the best DJ ever, he would not let that happen again. So he pulled some strings and gathered valuable information regarding the musical preferences of the dancers expected to attend the disco tonight. By 8.00PM, DJ N3xt0r has a file with the following info:

  • The number of dancers (D) expected to attend tonight.
  • The number of songs (S) on his laptop media library.
  • The boredom factor (B) of the dancers: the number of songs disliked by a dancer that will play before he gets bored and leaves the disco.
  • The musical preferences of the dancers represented by a D-row S-column matrix (M). If Mij = 1 then dancer i likes song j. If Mij = 0 he does not like the song.

He wants to build a playlist such that the number of dancers present when the party ends is maximized. Desperate, DJ N3xt0r seeks for your help. He will make you a VIP member of the disco if you write a program that performs the task. Notice that, as the playlist will be projected on a screen, dancers who don't see any song they like will leave immediately.

Input

Input starts with two integers (1 <= D, S <= 500) separated by a single space. The next line contains the boredom factors of the dancers (1 <= B1, B2…, BD <= S) separated by single spaces. The next D lines describe the M matrix. Each line represents the musical preferences of a dancer, and will consist of S binary integers (0, 1) separated by single spaces.

Output

Print the number of songs selected (P) for the playlist on a single line. Then print P integers, each one on a single line, indicating the songs selected, in any order. Notice that selecting a song more than once is not something a self-respecting DJ would ever do, so this will lead to Wrong Answer. The song numbers start from 0, i.e., print 0 when selecting the first song and S-1 when selecting the last.

Scoring

Points scored for a single test will equal the number of dancers present when the party ends according to your playlist. The total score of the program is the sum of points scored in all tests.

Example

Input:
4 5
2 3 3 4
1 0 0 0 0
0 0 1 0 0
1 1 1 0 1
0 1 0 0 0
Output:
3
0
4
1
Scoring:

2

Date: 2009-10-15
Time limit: 15s
Source limit: 50000
Languages: C C99 strict C++ PAS gpc PAS fpc JAVA NICE JAR C# C#2 NEM ST ASM D FORT ADA BASH PERL PYTH RUBY LUA ICON PIKE PHP SCM guile SCM qobi LISP sbcl LISP clisp SCALA HASK CAML CLPS PRLG WSPC BF ICK TEXT JS


  • Submit

Comments

  • Login or Register to post a comment.

In the example mentioned, if

abhinava.srivastava @ 1 Nov 2009 03:39 PM

In the example mentioned, if the DJ shows only one song in the playlist either  0,1 or 2, the score would be 2.

So do we need to maximize the number of songs as well...?

Should I take the last

Kiscsirke @ 1 Nov 2009 04:58 PM

Should I take the last sentence:

"Notice that, as the playlist will be projected on a screen, dancers who don't see any song they like will leave immediately."

to mean that if a dancer has a boredom factor of, say, 100, and we only play 90 songs, but he likes none of those songs, he still leaves (even though we played less "boring" songs to him then his boredom factor)? So in other words does that mean that for every dancer we should play at least one song he/she likes?

Wouldn't it be more optimal

dejandenib @ 1 Nov 2009 05:53 PM

Wouldn't it be more optimal if we choose only the first two songs? That way 3 people will stay all the time, the score will be 3. If we choose the first two songs the first dancer we like the first song, but not the second, but his boredom factor is hign enough for him to stay.There will be no songs for  the second dancer so he would be the only one to leave. The third dancer will like the first two , but he won't hear the third and the fifth that he likes, but his boredom factor is hign enough for him to stay at the party. And last, the fourth dancer, he will like the second song, but not the first, and that is enough for him to stay

@Abhinava The scoring for the

admin @ 1 Nov 2009 06:05 PM

@Abhinava The scoring for the problem doesn't include the number of songs being played, it depends on the number of dancers left at the end of the party.

@Eisenberger Yes, what is mentioned in the problem statement is correct.

If number of songs being

abhinava.srivastava @ 1 Nov 2009 06:37 PM

If number of songs being played is not considered, there would be more than one slutions as I mentioned in my previous post...

The solution which has the

admin @ 1 Nov 2009 06:41 PM

The solution which has the most number of people left at the end would be most optimal.

sir i don't understand what u

crazyforlove @ 2 Nov 2009 02:48 AM


sir i don't understand what u want to say so please be clear

As discussed after the last

triplem @ 2 Nov 2009 10:00 AM

As discussed after the last contest, will the input be generated uniformly randomly within the constraints?

In the example, the scoring

ToX BoT @ 2 Nov 2009 10:59 AM

In the example, the scoring is 2 but if we select songs 0 2 1, this will not let dancer 1 to leave the floor, so thats an better answer than the one in current example.

If we go for songs 0 4 1, then dancer 1 will leave the floor immediately, otherwise taking songs 0 2 1, he wouldn't leave considering the boredom factor (B) = 3. So, the party will end up with 3 dancers scoring better than whats given in the example.

Please correct me if I've mistaken anything :)

@Sumit Re-read the problem

admin @ 2 Nov 2009 01:56 PM

@Sumit Re-read the problem statement.

@stephen Yes, we have tried our best to keep it random

@Vipul The example is just that - an example. This is a challenge problem. The better your score, the higher your rank.

Something is wrong with the

triplem @ 3 Nov 2009 03:03 AM

Something is wrong with the display of scores in the submissions section. I accidentally submitted the same solution twice, the first one said 2040 [0.99 points], and the second 2040 [1.185 points]. Doesn't seem to affect the scoreboard though.

Dear Admin, I am slightly

pathaksandeep @ 3 Nov 2009 06:42 AM

Dear Admin,

I am slightly confused. You said that the scoring does not depend on the number of songs played. I can always chose 1 song so that no one leaves. What is wrong with that? If I do that then my score is extremely low. Can you specify how is scoring done?

 

Sandeep

Read the problem

triplem @ 3 Nov 2009 07:23 AM

Read the problem statement:

Notice that, as the playlist will be projected on a screen, dancers who don't see any song they like will leave immediately.

Thanks Stephen! I noticed

pathaksandeep @ 3 Nov 2009 07:46 AM

Thanks Stephen! I noticed that but I am still missing something!

Well, that immediately

triplem @ 3 Nov 2009 09:28 AM

Well, that immediately implies what you said is wrong.

When does a dancer leave? In

geekoo @ 3 Nov 2009 09:31 AM

When does a dancer leave?

In the above example, say, I play songs in the order 2 1 0, with dancer 1 liking the 0th song and having boredom of 2. Will he stay on to hear song #0, which is the 3rd song of the night. Or will he leave after hearing song #1, which is the 2nd song of the night, as his boredom factor would have gone on to zero?

 

@ Prashanth Read this

srirams @ 3 Nov 2009 12:01 PM

@ Prashanth

Read this carefully : -

Notice that, as the playlist will be projected on a screen, dancers who don't see any song they like will leave immediately.

So a person with boredom factor b will leave if there occurs a sequence of b  consecutive songs in the play list, none of which he likes.

Correct me if wrong.

Print the number of songs

kschetan @ 3 Nov 2009 08:54 PM

Print the number of songs selected (P) for the playlist on a single line. Then print P integers, each one on a single line, indicating the songs selected, in any order. Notice that selecting a song more than once is not something a self-respecting DJ would ever do, so this will lead to Wrong Answer. The song numbers start from 0, i.e., print 0 when selecting the first song and S-1 when selecting the last.

not able to understand the output please help me

@sriram: dont confuse the two

geekoo @ 3 Nov 2009 09:14 PM

@sriram: dont confuse the two statements. If there is no song that a dancer likes, he will leave immediately without listening to even one. period.

My confusion is, say there are two songs - S0 and S1. Dancer is A, who likes S1. Boredom factor of Dancer A = 1.

If my playlist is S0, my score is 0. If my playlist is S1, my score is 1. This is understood. But if my playlist is S0 S1, then what will my score be? Simple.

Mods, could you please answer this? Its not a test case, it is just that I am trying to understand the problem statement. I want to know at which point the boredom factor make a dance leave the disco. Sorry if am missing something or unable to understand the problem statement.

I have given correct solution

shadow @ 3 Nov 2009 10:45 PM

I have given correct solution for Help The DJ then why have I not got the points for it? My score is still 0

Does length of solution

pmnox @ 4 Nov 2009 03:13 AM

Does length of solution matter?

@ Prashanth The score will be

triplem @ 4 Nov 2009 12:08 PM

@ Prashanth

The score will be 0, as Dancer A will leave after hearing the 1 song he doesn't like.

@ sriram

The order of the playlist is completely irrelevant, a dancer will leave after hearing B songs they don't like regardless of whether they are consecutive or not.

@ Piotr

That has been answered already; the score solely depends on the number of dancers remaining.

In the example mentioned, if

vasudk2009 @ 4 Nov 2009 06:47 PM

In the example mentioned, if the DJ shows only one song in the playlist either  0,1 or 2, the score would be 2.

So do we need to maximize the number of songs as well...?

what is the length of the

vasudk2009 @ 4 Nov 2009 06:50 PM

what is the length of the playlist for a solution?

 

It would be really nice to

jdmetz @ 5 Nov 2009 06:57 AM

It would be really nice to know the random distributions used for the B's (is every B uniformly and randomly chosen from [1,S]?) and the M's (does every person have a 50% chance of liking each song, or are there some people that like 90% of the songs and others who like 10%?).

@Josh we will include

admin @ 5 Nov 2009 04:49 PM

@Josh we will include distribution of test data for all future contest challenge problems.  if you have any other feedback please let us know ~amit

please post the

abhinava.srivastava @ 5 Nov 2009 05:00 PM

please post the testcases...

You are telling runtime error but have no clue why...

@Stephen,   How do you see

innocentboy @ 6 Nov 2009 02:58 AM

@Stephen,

 

How do you see the order to be relevant, as in Prashanth's question.

If the playlist is S0 S1, then the score is 0, and if the playlist is S1 S0, then the score is 1. Isnt it ?

By my understanding,

triplem @ 6 Nov 2009 12:28 PM

By my understanding, regardless of the order, dancer one will leave after hearing the song he doesn't like. Ie the order isn't important, only the number of songs on the list that each person doesn't like.

How would the program take

Triguna @ 7 Nov 2009 12:38 AM

How would the program take inputs? As command line arguments or through some text file input? I will be writing C# file so generating an exe would be fine for submission? Or I need to generate a dll?

There is something wrong with

nadeemoidu @ 7 Nov 2009 05:31 PM

There is something wrong with the scoring. I am not getting any score for some of my submissions. It just says correct. Not even 0.

The time limit says 15s. If I

triplem @ 8 Nov 2009 08:17 AM

The time limit says 15s. If I submit a program which does nothing for 5 seconds then quits, I get time limit exceeded. What is the correct time limit? (If there are different time limits for different inputs, we need to know precisely which time limits apply to which inputs).

Thanks - I thought I was

jdmetz @ 9 Nov 2009 08:17 AM

Thanks - I thought I was going crazy, as my time limit checking code was working fine locally, but I kept getting TLE on submit, even when I reduced the limit to 5s.

It is a major frustration to have one time limit in the problem statement and another for submissions.

+1 It happened with me too.

innocentboy @ 9 Nov 2009 12:00 PM

+1

It happened with me too.

why does it give runtime

anujjamwal @ 9 Nov 2009 04:08 PM

why does it give runtime error for the code when its running on my pc?

Time limit is 2-15 seconds.

admin @ 9 Nov 2009 07:32 PM

Time limit is 2-15 seconds.

What does that mean? We need

triplem @ 10 Nov 2009 02:06 AM

What does that mean? We need to know which cases have a time limit of what otherwise the whole point of a time limit is kind of ruined.. and that is the most important part of a challenge problem.

We will try including this

admin @ 10 Nov 2009 03:46 AM

We will try including this information from the next contest along with the distribution of data.

but how many songs should I

devwebcl @ 10 Nov 2009 07:29 PM

but how many songs should I put in the list ?

 

Hi, Can anyone tell me where

saty @ 10 Nov 2009 11:37 PM

Hi,

Can anyone tell me where to find details about Tie Breaker problems?

The questions i have are like

1. Will my solution be accpedted if it solves all the test cases correctly or it will accept the solution anywyas but scoring will be = no of test cases passed?

2. IS scoring based on correct soluton*rel performance?

 

I guess it will be better if i can get some link where these kind of info regarding tie breaker probs are present?

 

Thanks

It was mentioned by

saty @ 10 Nov 2009 11:49 PM

It was mentioned by Aniruddha(Codechef) that time limit is 2-15sec in comments but in problem statement, it clearly says that its 15 sec?

And how to know what score I

saty @ 11 Nov 2009 12:15 AM

And how to know what score I received? In problem page in recent activity, it just shows whether accepted or not for me but fr others it shows scores?

Wow, 2157!  I'm impressed. 

ploh @ 11 Nov 2009 09:02 AM

Wow, 2157!  I'm impressed.  Josh, I think you can go to bed. :)  (I concede, in any case.)

I was surprised, too.  Of

jdmetz @ 11 Nov 2009 09:32 AM

I was surprised, too.  Of course, I was surprised when you got 2155, and then again when I got 2156.  I'm done now, though.

1. Will my solution be

admin @ 11 Nov 2009 02:12 PM

1. Will my solution be accpedted if it solves all the test cases correctly or it will accept the solution anywyas but scoring will be = no of test cases passed?

You need to pass all test cases, else you will get a WA.

2. IS scoring based on correct soluton*rel performance?

I don't quite get what you mean by the *, but yes, the performance is relative to the best score on the problem.

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Programming Competition Fetching successful submissions
Directi Go for Gold
CodeChef is a global programming communityCodeChef hosts online programming competitions
CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of computer programming. At CodeChef we work hard to revive the geek in you by hosting programming contests on a monthly basis. We also aim to have training sessions and events related to online programming for programmers around the world. Apart from providing a platform for programming competitions, CodeChef also has various tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our judge accepts solutions in over 35+ programming languages. Online programming was never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming competitions that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly programming contests and the shorter format Cook-off programming contests. Put yourself up for recognition and win great prizes. Prizes worth up to Rs.20,000 and $700 are up for grabs every month along with lots more CodeChef goodies.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be part of CodeChefs Forums and interact with all our programmers love helping out other programmers and share their ideas.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. Be a part of the CodeChef community through CodeChef meetups and techtalks. You can also host a programming contest for your institute on CodeChef and be a guest author on our blog.

Domain Name Registration, Web hosting, and Website Design provided by BigRock.com