社区讨论
求调,玄关
P1064[NOIP 2006 提高组] 金明的预算方案参与者 1已保存回复 0
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @m1nogi4t
- 此快照首次捕获于
- 2024/09/29 22:29 去年
- 此快照最后确认于
- 2024/09/30 12:54 去年
啊啊啊啊 调了几个小时,帮帮我吧
本人获得了30分,第一个WA的点是#3
#3数据如下:
输入 #3
CPP4500 12
100 3 0
400 5 0
300 5 0
1400 2 0
500 2 0
800 2 4
1400 5 4
300 5 0
1400 3 8
500 2 0
1800 4 0
440 5 10
正确输出 #3
CPP16700
我的输出 #3
CPP18200
我的代码:
CPP#include<iostream>
#include<algorithm>
#define maxm 65
#define maxn 32005
using namespace std;
int maxx(int x1,int x2,int x3,int x4,int x5){
return max(x1,max(x2,max(x3,max(x4,x5))));
}
int n,m,cost[maxm],w[maxm],f[maxn],c[maxm][3]; //n:volume m:num
int main(){
cin>>n>>m;
n=n/10;
for(int i=1;i<=m;i++){
int temp;
cin>>temp;
cost[i]=temp/10;
cin>>temp;
w[i]=temp*cost[i];
cin>>temp;
c[temp][++c[temp][0]]=i;
}
for(int i=1;i<=c[0][0];i++)
for(int j=n;j>=cost[c[0][i]];j--){
f[j]=maxx(f[j],(j-cost[c[0][i]])>=0?f[j-cost[c[0][i]]]+w[c[0][i]]:0,(j-cost[c[c[0][i]][1]]-cost[c[0][i]])>=0?f[j-cost[c[c[0][i]][1]]-cost[c[0][i]]]+w[c[c[0][i]][1]]+w[c[0][i]]:0,(j-cost[c[c[0][i]][2]]-cost[c[0][i]])>=0?f[j-cost[c[c[0][i]][2]]-cost[c[0][i]]]+w[c[c[0][i]][2]]+w[c[0][i]]:0,(j-cost[c[c[0][i]][1]]-cost[c[c[0][i]][2]]-cost[c[0][i]])>=0?f[j-cost[c[c[0][i]][1]]-cost[c[c[0][i]][2]]-cost[c[0][i]]]+w[c[c[0][i]][1]]+w[c[c[0][i]][2]]+w[c[0][i]]:0);
}
for(int i=1;i<=n;i++)cout<<f[i]<<" ";
cout<<endl;
cout<<(f[n]*10);
return 0;
}
回复
共 0 条回复,欢迎继续交流。
正在加载回复...