Mobile edge computing (MEC) is a recent technology that intends to free mobile devices from computationally intensive workloads by offloading them to a nearby resource-rich edge architecture. It helps to reduce network traffic bottlenecks and offers new opportunities regarding data and processing privacy. Moreover, MEC-based applications can achieve lower latency level compared to cloud-based ones. However, in a multitask multidevice context, the decision of the part to offload becomes critical. Actually, it must consider the available communication resources, the resulting delays that have to be met during the offloading process, and particularly, both local and remote energy consumption. In this paper, we consider a multitask multidevice scenario where smart mobile devices retain a list of heavy offloadable tasks that are delay constrained. Therefore, we formulated the corresponding optimization problem, and we derive an equivalent multiple-choice knapsack problem formulation. Because of the short decision time constraint and the NP-hardness of the obtained problem, the optimal solution implementation is infeasible. Hence, we propose a solution that provides, in pseudopolynomial time, the optimal or near-optimal solutions depending on the problem's settings. In order to evaluate our solution, we carried out a set of simulation experiments to evaluate and compare the performances of the different components of this solution. Finally, the obtained results in terms of execution's time as well as energy consumption are satisfactory and very encouraging.