作者:
4_3
,
2022-01-13 22:46:44
,
所有人可见
,
阅读 20
#include <iostream>
#include <cstring>
#include <algorithm>
#define x first
#define y second
using namespace std;
typedef pair<int, int> PII;
const int N = 40010;
PII ps[N];
int n, X, Y, Z, ans;
int main()
{
scanf("%d%d%d%d", &n, &X, &Y, &Z);
for (int i = 1; i < n * 2; i += 2)
{
int a, b;
scanf("%d%d", &a, &b);
ps[i] = {a, Y - X};
ps[i + 1] = {b + 1, Z - Y};
}
sort(ps + 1, ps + n * 2 + 1);
int res = n * X;
for (int i = 1; i <= n * 2; i ++)
{
res += ps[i].y;
ans = max(ans, res);
}
printf("%d", ans);
return 0;
}