966 - Lost Inheritances

All about problems in Volume 9. 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
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

966 - Lost Inheritances

Post by brianfry713 » Fri May 16, 2014 1:16 am

I generated a dataset and emailed the admins.
Check input and AC output for thousands of problems on uDebug!

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 966 - Lost Inheritances

Post by brianfry713 » Sun May 18, 2014 10:08 pm

I followed the problem statement.

There is only one test case in the judge's input. N <= 10000, all years are between 1 and 50000, all values fit inside a 32-bit signed int.
Marriages are monogamous and there are no divorces. If a parent is listed with a spouse, they will be listed together with all their children. Both parents are alive when their children are born. Widows and widowers do not remarry.
There will only be one death per year and no one is born on a year that someone dies.

Remainders go to neither state nor the descendants.

If the spouse is alive they get half or all of the money if there is no one else to share it with. Each child branch with a living descendant (or descendant's spouses) gets their equal share and division is preformed. Should the closest descendant still be alive the money goes to him/her, otherwise it is shared as if he/she had just died and division will be preformed again.

Explanation of the first sample input:
1: 1900 1950 0 0 1, saves 50
2: 1910 2000 0 0 2, saves 180
3: 1940 1992 1 2 10, saves 520
4: 1940 1990 1 2 2, saves 100
5: 1944 1981 1 2 1, saves 37
6: 1946 2020 0 0 0, saves 0
7: 1962 2030 4 0 5, saves 340
8: 1980 2040 5 6 5, saves 300

1950 1 dies had 50, leaves 25 to 2 and 8 each to 3 and 4 and 5.
1981 5 dies had 45, leaves 22 to 6 and 22 to 8
1990 4 dies had 108, leaves 108 to 7
1992 3 dies had 528, leaves 528 to state
2000 2 dies had 205, leaves 102 each to 4 and 5 branch
4 is already dead so 102 goes to 7
5 is already dead so 51 goes to 6 and 51 to 8
2020 6 dies had 73, 73 goes to 8
2030 7 dies had 550, 550 goes to state
2040 8 dies had 446, 446 goes to state

state gets 1524, everyone is dead.
Check input and AC output for thousands of problems on uDebug!

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 966 - Lost Inheritances

Post by brianfry713 » Tue Jul 29, 2014 8:56 pm

This was recently changed to a multiple input problem.
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 9 (900-999)”