Write a function to optimize a specific task relevant to Ryan Companies US.
Implement optimize_tasks(tasks) using weighted interval scheduling. Each task is represented as [start, end, value]. Return the maximum total value from a subset of non-overlapping tasks. A task ending at time t may be followed by a task starting at time t.
The input is a list of integer triplets, and the output is an integer. Return 0 when the list is empty.
def optimize_tasks(tasks):