I once got the highest test score in high school math class. However it was still a failing grade. I didn't know if I should have celebrated or be ashamed.
What grade did you finally get in math?
My math teacher wanted to punish me. I ended up with a B+ on my report card.
While it was good that you received the best test score in your math class, it still isn't appropriate to do poorly in your studies and receive a failing grade on a test. Even if others do poorly, it isn't an excuse to not master the materials that you are supposed to learn in class.
I think it was unfair. I'm thinking of doing something to embarrass my teacher in front of the class.
Doing that will only make things worse, and you'll get in trouble. It's better to just move on and do the best you can in the class.