题解:P11112 [ROI 2024 Day 1] 机器人物流
思路
我们可以先算出每个派送窗口所需要的最小克隆数量
至于
那么考虑贪心,我们按照
code
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
constexpr int N = 1e5 + 10;
long long a[N], tot, s;
int32_t main(){
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
long long n, m, c, p, x, y;
cin >> n >> m >> c >> p;
for(int i = 1; i <= n + m; i++){
cin >> x >> y;
if(x == 1)s += y;
else a[++tot] = y + s - 1;
}
sort(a + 1, a + 1 + tot);
long long ans = 0;
for(int i = 1; i <= tot; i++)
ans = max(ans, p * i - a[i] * c);
cout << ans << endl;
return 0;
}