?究极缝合怪
2024-07-17 19:51:28
发布于:广东
2阅读
0回复
0点赞
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int a[100005], b[100005], c[100005], dp[100005];
int n, m, k, r;
int find(int left, int right, int val){
if(dp[left] > val || dp[right] < val) return -1;
if(left == right) return dp[left];
int mid = (left + right) >> 1;
return max(find(left, mid, val), find(mid + 1, right, val));
}
int main(){
cin >> n >> m >> k >> r;
for(int i = 1; i <= n; i++){
cin >> a[i];
}
for(int i = 1; i <= m; i++){
cin >> b[i];
}
for(int i = 1; i <= m; i++){
cin >> c[i];
}
for(int i = 1; i <= m; i++){
for(int j = r; j >= b[i]; j--){
dp[j] = max(dp[j], dp[j - b[i]] + c[i]);
}
}
int ct = r - find(1, r, k);
sort(a + 1, a + n + 1);
int ctt = 0;
for(int i = 1; i <= n; i++){
if(ct < a[i]){
cout << ctt;
return 0;
}
ctt++, ct -= a[i];
}
cout << ctt;
return 0;
}
这里空空如也
有帮助,赞一个