Do I have any chance to apply to a graduate school after a bad junior year? I am a senior at a top 15 public university in the states and planning to apply for graduate school in mathematics. Having been a top 100 Putnam performer and won a couple of medals at IMO in my high school, I believe I have a strong enough mathematical background to be a competent student at a top 5-10 graduate program. However, my application will not be stellar. 

In the beginning of my junior year, I got severely addicted to a computer game and my grades suffered from it. Now I have one C in an economics class and an F in summer English class as well as two B's in upper level maths classes. Luckily, I have completely recovered now and performing very well in all of my current classes.

On one hand, my addiction problem in the past would certainly make it look like I am not strong enough to get through long and hard five years of a maths PhD student. But I do know that a researcher in pure maths will be my career and is what I am passionate about the most. 

On the other hand, my adviser at the current university believes that I belong to a top school. He said:


  ...a student of your talent really needs to go to one of the best maths programs...


Now I am taking a second course in complex analysis with him and he seems to like me. 

Because of my financial problem, I can apply to at most a dozen schools and want to make the best out of it. I thought that top 20-40 is my reach and top 40+ is my safety range. I had completely ruled of the idea to apply to a top 20 program. But what my adviser told me made me confused.

So my question is will it make sense for me to apply to a top 20 school? I have a really tight budget and do not want to waste spot for a school that I do not have a shot at.
I think you should not worry about the 'junior' days. You are now equipped to apply anywhere.  If you are concerned about not making at the top schools, also apply at say five second choices.  If you get accepted at one or more top schools, you can pass the others. Get best testimonials in your hand so you are ready for the next move up.  Best of luck.