There is probably no 'set' formula for this question. It's an exercise in logic.
If a system does work or expels heat, it is losing energy.
If a system gets work done on it or is absorbing heat, it is gaining energy.
If the surroundings are doing work, or are expelling heat, the surroundings are losing energy == the system is GAINING energy
If the surroudings are getting work done on it or is absorbing heat, then the surroundings are gaining energy == the system is lowing energy.
You just have to know what energy quantities are being added and subtracted from the initial energy.
Only problem is you're not given an initial energy (in the question you gave us anyways)...so this is where 'arbitrary zero' comes in, I bet. Try a google search, and hopefully everything will piece together.