Optimal paths in weighted timed automata