The points winner is determined by points earned for each stage placing much like a series race. The King of the Mountain is determined by points earned from sprints at the top of significant climbs. The Stage Winner is the first rider to complete that stage. The Team GC is determined by the cumulative times of the first three to five riders on a team to finish in each stage. They don't have to be the same three to five riders for every stage.
Stage races are contests of energy expenditure efficiency.
Then you have to determine the stages where you feel your team can gain the best ground. You ride those stages to gain ground and ride the rest of the stages trying not to lose ground. This is why stage racing requires a combination of offensive and defensive strategies. On either individual or team GC, you will gain the most ground for the amount of energy expended on climbs and time trials. In the flatter stages, you ride for damage control.