There are ten prisoners on death row, but the warden gets bored one day and tells them they can play a game for their freedom. In this game, he'll line the prisoners up single-file (the one at the front of the line is called the 1st prisoner, the one at the end of the line is the 10th prisoner) and place a hat on each of their heads. The prisoner won't be told which color the hat on their head is, all they know is that there's two colors of hats: Red and Blue. When they're lined up, they won't be able to look behind them, just at the people in front of them (so, prisoner 1 can't see anybody, prisoner 10 can see 1 through 9).
The procedure of the game is that the warden lines the prisoners up, puts the random blue/red hats on their head, and then goes to the 10th prisoner. This prisoner is allowed to say either "Red" or "Blue", and if they're correct, they will be saved. Otherwise, they die. Either way, once the 10th prisoner answers, the warden will go to the 9th prisoner and repeat the process.
The warden gives them ten minutes to come up with a plan to save as many of themselves in the game as possible. What's the maximum number of lives that can be guaranteed, and how is it accomplished?
edit: Also, don't take into account prisoners backstabbing each other
