If there is a minimum time requirement and you need to reach it + pass tests then understandably the teacher has the right to fail you if you're not doing it. But this is coming from my experience when it comes to education in Poland. I too had great grades but I sucked when it came to math and physics. I was bad with both, but I passed physics because I was at least trying to be there and listen. I failed nearly every single exam, but the teacher gave me the minimum pass mark just for attendance and my attitude - she understood I was more into biology and languages, she knew physics are not going to be my chosen subject in Uni.
On the other had my math teacher failed me because I was not even trying, I was skipping her classes. I passed some exams, failed others, but overall grade was given based on attendance as well as grades. I didn't quite hit the mark because most of the time I wasn't even in the classroom. In the end I just had to do a week of 'intensive math camp' in summer and pass the last exam, which at that point was not as bad because the teacher took the whole lot of us and prepared us specifically for that test.
You mentioned your teacher said you're not putting enough time into it- if it's the same for you as it was for me in Poland I'd suggest you talk to the teacher and ask what the expectations are moving forward and what can you do to fix this problem. And then step by step just do it. This has nothing to do with teacher being a bad person, they can be the sweetest person on this planet, but if you're not doing what you're asked to do and don't communicate with the teacher they have every right to fail you.
If you're struggling with the subject, tell the teacher. If it's too fast for you - tell them. If you need recaps - tell them. If you don't they will likely assume you just don't care.