题目描述
Problem Description
There are $ N $ oranges, numbered $1,\ 2,\ ...,\ N$. Each orange has exactly $ A $ or exactly $ B $ segments.
For these oranges' segment counts, the following is known:
- For each $ i $ ($1\ \leq\ i\ \leq\ M$), the oranges numbered from $ L_i $ to $ R_i $ have exactly $ A $ segments each.
Find the maximum possible total number of segments among the $ N $ oranges.
Input Format
The input is given from the standard input in the following format:
$ N $ $ M $ $ A $ $ B $ $ L_1 $ $ R_1 $ $ L_2 $ $ R_2 $ $ : $ $ L_M $ $ R_M $
Output Format
Output the answer.
Sample Input and Output
Sample Input #1
5 2 6 7
2 3
3 4
Sample Output #1
32
Sample Input #2
10 3 20 30
1 6
2 7
3 10
Sample Output #2
200
Sample Input #3
100 5 12 34
6 8
81 81
26 26
90 91
49 50
Sample Output #3
3202
Notes/Hints
Constraints
- $1\ \leq\ N\ \leq\ 100$
- $1\ \leq\ M\ \leq\ 100$
- $1\ \leq\ A\ <\ B\ \leq\ 100$
- $1\ \leq\ L_i\ \leq\ R_i\ \leq\ N$ ($1\ \leq\ i\ \leq\ M$)
- All input values are integers.
Sample Explanation 1
The segment counts of each orange are as follows, which maximizes the total number of segments:
- Oranges $2,\ 3,\ 4$ have $A\ =\ 6$ segments each.
- Oranges $1,\ 5$ have $B\ =\ 7$ segments each.
The total number of segments is $6\ \times\ 3\ +\ 7\ \times\ 2\ =\ 32$.
Sample Explanation 2
All oranges have $A\ =\ 20$ segments.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分