You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
617 B
C++
27 lines
617 B
C++
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
typedef long long ll;
|
|
const int N = 105;
|
|
int L[N], R[N];
|
|
int main()
|
|
{
|
|
int T;
|
|
scanf("%d", &T);
|
|
for (int t = 1; t <= T; t++)
|
|
{
|
|
int n, a, b, l;
|
|
scanf("%d%d%d%d", &n, &a, &b, &l);
|
|
for (int i = 0; i < n; i++)
|
|
scanf("%d%d", L + i, R + i);
|
|
ll cur = 0, ans = 0;
|
|
int pos = 0;
|
|
for (int i = 0; i < n; i++)
|
|
{
|
|
cur += b * (L[i] - pos) - a * (R[i] - L[i]);
|
|
ans = max(ans, -cur);
|
|
pos = R[i];
|
|
}
|
|
printf("Case #%d: %lld\n", t, ans);
|
|
}
|
|
return 0;
|
|
} |