Statement
Agent Han is a brilliant programmer renowned for his exceptional problem-solving skills. One day, while diligently solving problems, he encounters a particularly difficult problem that he cannot solve. Fortunately, he learns that a sheet of paper containing the solution is hidden somewhere inside a university in the Sinchon area. Determined to obtain the solution, Agent Han decides to infiltrate the university and steal it.
Anticipating that someone might attempt to steal the solution, the university has installed extensive security measures along the \(N\) passageways connecting its \(N+1\) buildings. The buildings are numbered from \(1\) to \(N+1\), and for each \(1 \le i \le N\), the \(i\)-th passageway connects building \(i\) to building \(i+1\).
Agent Han starts at building \(1\) and must reach building \(N+1\), where the solution is hidden. To avoid being detected by the security guards, he can traverse each passageway using one of the following three methods:
- Move stealthily: Traverse the \(i\)-th passageway without making any noise. This takes \(s_i\) seconds and does not risk detection.
- Move noisily: Traverse the \(i\)-th passageway quickly, making noise in the process. This takes \(l_i\) seconds. However, if Agent Han makes noise more than \(W\) times in total, an alarm will be triggered, and his mission will fail.
- Teleport: Instantly travel from building \(i\) to building \(i+1\), taking \(0\) seconds without making any noise. However, teleportation consumes a significant amount of energy, so Agent Han can use it at most \(T\) times in total.
Once Agent Han reaches building \(N+1\), he can obtain the solution instantly, requiring no additional time.
Determine the minimum total time required for Agent Han to reach building \(N+1\) and obtain the solution without triggering the alarm, using teleportation at most \(T\) times.
Input
The first line contains three space-separated integers \(N\), \(W\), and \(T\), representing the number of passageways, the maximum number of times Agent Han can make noise, and the maximum number of teleports he can use, respectively. (\(1 \le N \le 3 \times 10^5\); \(0 \le W, T \le N\))
Each of the next \(N\) lines contains two space-separated integers \(s_i\) and \(l_i\), representing the time, in seconds, required to traverse the \(i\)-th passageway stealthily and noisily, respectively. (\(1 \le s_i, l_i \le 10^{12}\))
Output
Print a single integer representing the minimum time, in seconds, required for Agent Han to obtain the solution.
Since Agent Han is also an expert at escaping, the time required to leave the university does not need to be considered.