You want to form as many octets and have as many elements with a formal charge of 0 as possible. Generally, octets first come. There are cases where you cannot have all elements with a stable octet. For period 1 and 2 elements, though, you should never go above 8 electrons. (just like for H, you would never go over 2 electrons). The solution given will satisfy the octet requirement for all elements, although it will introduce formal charges. The solution you give violates the octet rule in a way that N will have 10 electrons around it, which is not possible.