365 - Welfare Reform

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

Moderator: Board moderators

Post Reply
Darko
Guru
Posts: 580
Joined: Fri Nov 11, 2005 9:34 am
Location: Calgary, Canada

365 - Welfare Reform

Post by Darko » Wed May 10, 2006 10:10 pm

This one seems easy, but I can't get it right.

I checked for blank lines, there were none.

I dealt with 0's (income, children). I used integers-only and/or doubles and I even used 64-bit integers (who knows, maybe one of those names is Gates).

It looks straight-forward, but I am missing some weird case... any hints?

mamun
A great helper
Posts: 286
Joined: Mon Oct 03, 2005 1:54 pm
Location: Bangladesh
Contact:

Post by mamun » Thu May 11, 2006 8:03 pm

This really looks simple but very less number of acceptance and so is its rate. I was trying it just now and already got 4 WA.

Where is the trick? Does name of family contain whitespace? I tried that also.
Children in the same family will not share birthdays.
Doesn't that intend to mean there will be no children with same age? If there is, then what to do if more than one child have the minimum age?

What's the age of following children?
9 1 95
9 2 95
8 30 95
8 31 95

Darko
Guru
Posts: 580
Joined: Fri Nov 11, 2005 9:34 am
Location: Calgary, Canada

Post by Darko » Thu May 11, 2006 10:00 pm

Thanks mamun for the hint :)

My WA gave 4 zeros to those, and when I changed it so the first one was 1, it got accepted :)

I considered names to contain (and start/end with) spaces, but I am not sure if there are such cases.

Make sure you handle k=0 case and that you didn't mix < and <=.

Btw, that "no children will share..." means that there must be the youngest child.

mamun
A great helper
Posts: 286
Joined: Mon Oct 03, 2005 1:54 pm
Location: Bangladesh
Contact:

Post by mamun » Thu May 11, 2006 10:51 pm

Nice to see my hint helped you to get AC. :D
Darko wrote:My WA gave 4 zeros to those, and when I changed it so the first one was 1, it got accepted
So you mean it is 1, 0, 1, 1?

For k=0, I don't print anything but a blank line. And if income is 0 then it is not a special case.

Can anybody provide with some test cases?

Darko
Guru
Posts: 580
Joined: Fri Nov 11, 2005 9:34 am
Location: Calgary, Canada

Post by Darko » Thu May 11, 2006 11:04 pm

Yes, that is what I meant, sorry.

Try those border cases, that's all I can think of (replace 28000 in the sample input with one of the values in the column 5 and see if you get a fee in the previous row)

And yes - I thought at the time that income 0 was special, but it's not.

mamun
A great helper
Posts: 286
Joined: Mon Oct 03, 2005 1:54 pm
Location: Bangladesh
Contact:

Post by mamun » Sat May 13, 2006 11:43 am

Darko wrote:replace 28000 in the sample input with one of the values in the column 5 and see if you get a fee in the previous row
I should get the fee in the same row, isn't it? For example, if i replace 28000 by 29222 then I get
Smith 16 0.00
Smith 6 3.60
Smith 5 3.60
Smith 4 3.60
Smith 2 7.20

Can there be any precision problem? The only floating point values are the fees. I'm using double for them and dividing the value with 2.0 for halfing it.

I've really run out of ideas. :cry:

Darko
Guru
Posts: 580
Joined: Fri Nov 11, 2005 9:34 am
Location: Calgary, Canada

Post by Darko » Sat May 13, 2006 12:52 pm

Sorry, that's what I meant - I should stop doing that and just say "check border cases" :)

I am not sure, I just checked a couple of things:
- names don't start or end with whitespace, not sure if they contain any, I just consider the line to be a name.
- 32-bit ints are OK (I guess there is no Gates family after all)

I use double for fees and I divide by 2 as well.

It is probably one of those border cases, you probably covered them all, but I'll ask anyway - How do you check the range? If income is greater than the value in the last row it works? And - fee is paid for children 12 and younger, not 13. (I think I got that one right :))

I can't think of anything else :(

mamun
A great helper
Posts: 286
Joined: Mon Oct 03, 2005 1:54 pm
Location: Bangladesh
Contact:

Post by mamun » Sat May 13, 2006 5:18 pm

This is how I check the range

Code: Select all

double search(int k,int salary){
	for(int i=ROW-1;i>=0;i--)
		if(salary>=table[i][k])
			return fee[i];
}
Value of ROW is 12 of course and k is number of children - 1.

This is the first line for outputting

Code: Select all

if(age[i]>=13)	printf("%s %d 0.00\n",name,age[i]);
I've used 32 bit signed integers and double only for the fees.

Really no idea. :evil: Very frustrating.

x140l31
Learning poster
Posts: 69
Joined: Tue Jan 30, 2007 12:51 am

Post by x140l31 » Thu Mar 27, 2008 2:42 pm

I will response at me....

Hello,

can anyone help me :P

Code: Select all

removed get AC
if there's a family with 0 children? what I have to write? a blank line?

Leave a blank line after the output for each family.


YES

metaphysis
Experienced poster
Posts: 139
Joined: Wed May 18, 2011 3:04 pm

Re: 365 - Welfare Reform

Post by metaphysis » Fri Jul 08, 2016 12:04 pm

For guys who want to solve this problem:
(1)family name contain none space.
(2)there are test data which some children's age are same but with difrrent birthday, you should choose the "max" birthday as youngest, for example, there are three children with birthday(in real life, it seems impossible for a single monther family):
9 10 95
9 20 95
9 30 95
they are all 0 ages, but the third child is youngest.

Post Reply

Return to “Volume 3 (300-399)”