By allowing users to specify multiple execution versions of a task with different amounts of worst-case execution time and costs, this paper explores how to minimize of the overall system cost under the timing constraints for sporadic real-time tasks. One specific application is to minimize the requirement scratchpad memory size (system cost) to meet the timing constraint, while the worst-case execution time of a task depends on its allocated scratchpad memory size. This paper shows that the problem is N P-hard for approximation, if speed augmentation is not allowed. The algorithms proposed in this paper are analyzed based on (α, β)-approximation, in which a β speed augmentation factor is allowed and the system cost is at most α times of the optimal solution. For tasks with constrained deadlines, an efficient (1, 2 1−η )-approximation algorithm based on dynamic programming is proposed for deadline-monotonic (DM) scheduling, where 0 < η < 1 is a user-defined parameter for the rounding precision in dynamic programming. This is further extended to a (1, 1.6322 1−η )-approximation algorithm for earliest-deadline-first (EDF) scheduling. A polynomialtime (1 + , 1 + η)-approximation scheme is also developed for EDF scheduling by considering 0 < , 0 < η < 1 when the ratio of the maximum relative deadline to the minimum relative deadline of tasks is a constant. This paper is concluded by considering the dual problem to maximize of the system profit by selecting execution versions with different amounts of worst-case execution time.