OK, let me get this straight. She dumps you. When you try to talk to her, she blocks your number so you can't text or call her. She blocks you on Facebook. It's pretty much over, no?
So you follow her home from the gym and visit her in her apartment, alone. Just to prove that you were there, you leave evidence of your presence.
You are lucky that all you got was an accusation of trespass. She could have claimed you tried to rape her, and her friend would probably have backed her up. How would a sex offence record look on your CV?
STAY CLEAR OF HER. Really, are you self-destructive? Are you autistic? Don't ever try to contact her again. Don't ever be seen anywhere near her again. Don't ever leave anything for her again. Change your gym. Don't go to court; just pay the fine and make this thing go away as soon as possible and stay out of her life, and keep her out of yours.