According to the wiki, on flat ground you can space powered rails every 38 rails and maintain optimum speed. Going uphill, you need one power rail every 4 rails. So I'm assuming that if you have a combination of flat and uphill, you would treat the uphill sections as approximately 9 flat sections (4x=38, rounded down) and keep going until the next rail placement would put you past counting to 38 (and then put a powered rail and start over counting). However, this is not working very well at all. I'm just not making it up the hill. The other problem... I can't find anything in the wiki that confirms this, but it sure seems like going around a corner causes the minecart to slow down much more than it would if it were going straight. When I run through sections that have a lot of wiggles in the path, it very quickly comes to almost a stop. This is strange because the wiki suggests that diagonal sections should actually give you a bonus in how far you can go between powered rails.
powered rail problems