社区讨论
谁能帮我看看玄学代码
P1417烹调方案参与者 2已保存回复 5
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 5 条
- 当前快照
- 1 份
- 快照标识符
- @lo8pv40o
- 此快照首次捕获于
- 2023/10/27 22:36 2 年前
- 此快照最后确认于
- 2023/10/27 22:36 2 年前
CPP
#include<bits/stdc++.h>
#include <math.h>
#define pr(x) cerr<<#x<<"="<<(x)<<endl
#define pri(x,lo) {cerr<<#x<<"={";for (int ol=0;ol<=lo;ol++)cerr<<x[ol]<<",";cerr<<"}"<<endl;}
#define ll long long
using namespace std;
const int Inf=1e5+1;
ll a[Inf],f[Inf],V,n;
struct E{
ll a,b,c;
}e[Inf];
bool cmp(E x,E y){
return y.b*x.c>x.b*y.c;
}
int main(){
scanf("%lld%lld",&V,&n);
for(int i=1;i<=n;i++){
scanf("%lld",&e[i].a);
}
for(int i=1;i<=n;i++){
scanf("%lld",&e[i].b);
}
for(int i=1;i<=n;i++){
scanf("%lld",&e[i].c);
}
sort(e+1,e+n+1,cmp);
for(int i=1;i<=n;i++){
for(ll j=V;j>=e[i].c;j--){
f[j]=max(f[j],f[j-e[i].c]+e[i].a-(V-(j-e[i].c))*e[i].b);
}
}
printf("%lld",f[V]);
return 0;
}
/*
1:bycx
2:bxcy
*/
回复
共 5 条回复,欢迎继续交流。
正在加载回复...