My advice would be to:
1. Using lastb get the last users to login to the server, it's upto you how you use this data (print $1 would give you the user name, but you'd get duplicates).
2. Stick this in a for loop and do for user in `the query above which shows only the usernames`; do cat /home/$user/.bash_history; done;
3. Don't get this. I'm not writing the script for you though, I'll help with anything you've wrote so far, but I think it's unfair to come here just demanding code also - it sounds like homework.
I'm sure there are better more intelligent ways of achieving the same thing anyway.