67 条题解
-
2jerryzheng2005 LV 10 @ 2017-03-28 21:00:51
//p1407 #include<iostream> using namespace std; int n,m,name[3],c[3],v[3],b[128],z[128],w[128],p[128],x[128][32768]; int f(int x) { if (x==name[0]) return 0; else if (x==name[1]) return 1; else return 2; } int main() { int i,j; cin>>n>>m>>name[0]>>c[0]>>v[0]>>name[1]>>c[1]>>v[1]>>name[2]>>c[2]>>v[2]; for (i=1;i<=n;i++) cin>>b[i]>>z[i]; for (i=1;i<=n;i++) p[i]=b[i]*c[f(z[i])],w[i]=b[i]+b[i]*v[f(z[i])]; for (i=1;i<=n;i++) for (j=1;j<=m;j++) if (j>=w[i]) x[i][j]=x[i-1][j-w[i]]+p[i]>x[i-1][j]?x[i-1][j-w[i]]+p[i]:x[i-1][j]; else x[i][j]=x[i-1][j]; cout<<x[n][m]<<endl; return 0; }
-
12016-05-06 21:07:20@
注意作品体积=布体积+花纹体积!!!
注意作品体积=布体积+花纹体积!!!
注意作品体积=布体积+花纹体积!!! -
02018-10-30 20:07:30@
#include <iostream> #include <algorithm> using namespace std; int n, m; long long idx[3], c[3], v[3]; long long b[100], z[100]; long long maxbeauty[8000]; struct INF { long long b, z, cap, beauty; }dat[101]; int f(long long x) { if (x == idx[0]) return 0; if (x == idx[1]) return 1; if (x == idx[2]) return 2; } int main() { int i, j; cin >> n >> m; for (i = 0; i < 3; i++) cin >> idx[i] >> c[i] >> v[i]; for (i = 1; i <=n; i++) { cin >> dat[i].b >> dat[i].z; dat[i].cap = dat[i].b + v[f(dat[i].z)] * dat[i].b; dat[i].beauty = c[f(dat[i].z)] * dat[i].b; } for (i = 1; i <= n; i++) for (j = m; j >= dat[i].cap; j--) maxbeauty[j] = max(maxbeauty[j], maxbeauty[j - dat[i].cap] + dat[i].beauty); cout << maxbeauty[m] << endl; system("pause"); return 0; }
-
02017-08-18 22:33:28@
#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<map> using namespace std; long long n,m,dp[8004],x,y,z,ans; struct node{ long long c,v; }; map<int,node>p; int main(){ cin>>n>>m; for(int i=1;i<=3;i++){ cin>>x>>y>>z; p[x].c=y; p[x].v=z; } for(int i=1;i<=n;i++){ cin>>x>>y; z=p[y].c*x; x=p[y].v*x+x; for(int j=m;j>=x;j--){ dp[j]=max(dp[j],dp[j-x]+z); ans=max(ans,dp[j]); } } cout<<ans; return 0; }
-
02016-08-11 17:33:00@
不同种类的花纹竟然是一样的编号,害得我交了7次才AC,,,,,
-
02016-01-15 19:45:27@
评测结果
编译成功foo.cpp: In function 'int find(int)':
foo.cpp:18:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
测试数据 #0: Accepted, time = 0 ms, mem = 3512 KiB, score = 9
测试数据 #1: Accepted, time = 0 ms, mem = 3504 KiB, score = 9
测试数据 #2: Accepted, time = 0 ms, mem = 3508 KiB, score = 9
测试数据 #3: Accepted, time = 0 ms, mem = 3508 KiB, score = 9
测试数据 #4: Accepted, time = 15 ms, mem = 3504 KiB, score = 9
测试数据 #5: Accepted, time = 15 ms, mem = 3504 KiB, score = 9
测试数据 #6: Accepted, time = 7 ms, mem = 3504 KiB, score = 9
测试数据 #7: Accepted, time = 0 ms, mem = 3508 KiB, score = 9
测试数据 #8: Accepted, time = 0 ms, mem = 3508 KiB, score = 9
测试数据 #9: Accepted, time = 0 ms, mem = 3504 KiB, score = 9
测试数据 #10: Accepted, time = 0 ms, mem = 3504 KiB, score = 10
Accepted, time = 37 ms, mem = 3512 KiB, score = 100
代码
#include <stdio.h>
#include <algorithm>
using namespace std;
int z[4];
int c[4];
int v[4];
int dp[101][8001];
int way[8001];
int vv[8001];
int k[8001];
int find(int x)
{
for(int i=1;i<=3;i++)
{
if(x==z[i])
return i;
}
}
int main()
{
int n,m;
scanf("%d%d",&n,&m);
for(int i=1;i<=3;i++)
scanf("%d%d%d",&z[i],&c[i],&v[i]);
for(int i=1;i<=n;i++)
{
scanf("%d%d",&vv[i],&way[i]);
k[i]=find(way[i]);
}
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
int tmp=k[i];
if(j-vv[i]*v[tmp]-vv[i]>=0)
dp[i][j]=max(dp[i-1][j],dp[i-1][j-vv[i]*v[tmp]-vv[i]]+vv[i]*c[tmp]);
else
dp[i][j]=dp[i-1][j];
}
printf("%d",dp[n][m]);
} -
02015-12-19 11:10:05@
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
using namespace std;
#define ll long long int
struct flower{
int z,c,v; //编号 美观度 体积
};
flower z[5]={};
ll b[105]={},bh[105]={},mg[105]={},f[10005]={};
//bh 编号 mg 美观度
int main(){
int n,m;
cin>>n>>m;
for(int i=1;i<=3;i++)
scanf("%d%d%d",&z[i].z,&z[i].c,&z[i].v);
for(int i=1;i<=n;i++)
scanf("%d%d",&b[i],&bh[i]);
for(int i=1;i<=n;i++)
{
for(int j=1;j<=3;j++)
{
if(z[j].z==bh[i])
{
mg[i]=z[j].c*b[i];
b[i]+=b[i]*z[j].v;
}
}
}
for(int i=1;i<=n;i++)
{
for(int j=m;j>=b[i];j--)
{
f[j]=max(f[j],f[j-b[i]]+mg[i]);
}
}
cout<<f[m]<<endl;return 0;
} -
02015-12-02 21:21:09@
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long LL;
const int N = 8000 + 24;
int n,m,t;
int dp[N];
struct node
{
int ID,c,v;
}s[4];
int main()
{
while(~scanf("%d%d",&n,&m))
{
memset(dp,0,sizeof(dp));
for(int i = 0; i < 3; i++)
{
scanf("%d%d%d",&s[i].ID,&s[i].c,&s[i].v);
}
for(int i = 0; i < n; i++)
{
int a,b;
scanf("%d%d",&a,&b);
for(int j = 0; j < 3; j++)
if(s[j].ID == b)
{
for(int z = m; z >= s[j].v * a + a; z--)
dp[z] = max(dp[z],dp[z-(s[j].v * a + a)] + a * s[j].c);
}
}
printf("%d\n",dp[m]);
}
} -
02015-08-06 17:36:17@
program sss;
var
i,j,k,l,n,m,ii,jj,kk,ll:longint;
a:array[0..3,0..3]of longint;
f:array[0..1000000]of longint;
x,y:array[0..100]of longint;
function max(x,y:longint):longint;
begin
if x>y then exit(x) else exit(y);
end;
begin
readln(n,m);
for i:=1 to 3 do
begin
for j:=1 to 3 do
read(a[i,j]);
readln;
end;
for i:=1 to n do
begin
readln(x[i],k);
for j:=1 to 3 do
if k=a[j,1] then
begin
y[i]:=a[j,2]*x[i];
x[i]:=x[i]*a[j,3]+x[i];
end;
end;
for i:=1 to n do
for j:=m downto x[i] do
f[j]:=max(f[j],f[j-x[i]]+y[i]);
k:=0;
for i:=1 to m do
if f[i]>k then k:=f[i];
writeln(k);
end. -
02015-06-25 15:13:46@
#include<iostream>
#include<cstdio>
#define ll long long int
using namespace std;
struct flower{
int z,c,v;//编号 美观度 体积
};
flower z[4];
ll n,m,b[101],bh[101],mg[101],f[10000];//bh 编号。mg 美观度
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=3;i++)
scanf("%d%d%d",&z[i].z,&z[i].c,&z[i].v);
for(int i=1;i<=n;i++)
scanf("%d%d",&b[i],&bh[i]);
for(int i=1;i<=n;i++)
for(int j=1;j<=3;j++)
if(z[j].z==bh[i]){
mg[i]=z[j].c*b[i];
b[i]+=b[i]*z[j].v;
}
for(int i=1;i<=n;i++)
for(int v=m;v>=b[i];v--)
f[v]=max(f[v],f[v-b[i]]+mg[i]);
cout<<f[m];
} -
02015-01-22 13:00:50@
#include <iostream>
#include <algorithm>
using namespace std;
#define MAXL 30001struct xiu
{
int num;
int beau;
int v;
};int dp[MAXL], V, n, w, num, p;
xiu xi[3];void ZeroOnePack(int w, int p);
int main()
{
cin >> n >> V;
for (int i = 0; i < 3; i++)
cin >> xi[i].num >> xi[i].beau >> xi[i].v;
for (int i = 1; i <= n; i++)
{
cin >> w >> num;
for (int j = 0; j < 3; j++)
{
if (xi[j].num == num)
{
p = w * xi[j].beau;
w = w + w * xi[j].v;
break;
}
}
ZeroOnePack(w, p);
}
cout << dp[V] << endl;
return 0;
}void ZeroOnePack(int w, int p)
{
for (int i = V; i >= w; i--)
dp[i] = max(dp[i - w] + p, dp[i]);
}
这是一道语文题。。。 -
02015-01-02 00:13:21@
#include <stdio.h>
int pattern[3][3]; //code, value, volume
int cloth[101][2]; //code, volume
int dp[8001];
int indexof(int code){
int i;
for(i=0;code!=pattern[i][0];i++);
return i;
}
int main(){
int num,capacity;
int i,k,cost,value;
scanf("%d%d",&num,&capacity);
for(i=0;i<3;i++){
for(k=0;k<3;k++)
scanf("%d",&pattern[i][k]);
}
for(i=1;i<=num;i++){
scanf("%d%d",&cloth[i][1],&cloth[i][0]);
cloth[i][0]=indexof(cloth[i][0]);
}
for(i=0;i<=num;i++)
dp[i]=0;
for(i=1;i<=num;i++){
for(k=capacity;k>0;k--){
cost=cloth[i][1]+pattern[cloth[i][0]][2]*cloth[i][1];
value=pattern[cloth[i][0]][1]*cloth[i][1];
if(k-cost>=0 && dp[k]<dp[k-cost]+value)
dp[k]=dp[k-cost]+value;
}
}
printf("%d\n",dp[capacity]);
return 0;
}太阴险了。第一次做的时候,我还以为对于一匹布,可以织其体积以下的任意多花纹呢,后来删掉了那一层循环就过了。题目表述实在太差劲了。
-
02014-12-13 14:41:50@
#include<stdio.h>
int main()
{
int n,m,huawen[4],beauty[4],v[4],record[8005]={0},vbu[105]={0},yongbu[105]={0},bumei[105]={0};
scanf("%d%d",&n,&m);//n为布的匹数,m为包的容量
int i,a,b,c;
for(i=1;i<=3;i++)
scanf("%d%d%d",&huawen[i],&beauty[i],&v[i]);// huawen是花纹种类的编号,beauty是每一体积布上这种花纹的美观度,v是每一体积布上绣的这种花纹的体积
for(i=1;i<=n;i++)
scanf("%d%d",&vbu[i],&yongbu[i]);//vbu是布的体积,yongbu是这匹布上所绣花纹的种类编号
for(i=1;i<=n;i++)
{
if(yongbu[i]==huawen[1])
{
bumei[i]=vbu[i]*beauty[1];
vbu[i]=vbu[i]+v[1]*vbu[i];
continue;
}
if(yongbu[i]==huawen[2])
{
bumei[i]=vbu[i]*beauty[2];
vbu[i]=vbu[i]+v[2]*vbu[i];
continue;
}
if(yongbu[i]==huawen[3])
{
bumei[i]=vbu[i]*beauty[3];
vbu[i]=vbu[i]+v[3]*vbu[i];
}
}
for(a=1;a<=n;a++)
for(b=m;b>=1;b--)
{
if(b<vbu[a])
continue;
if(record[b]<record[b-vbu[a]]+bumei[a])
record[b]=record[b-vbu[a]]+bumei[a];
}
printf("%d",record[m]);
return 0;
} -
02014-12-10 18:08:33@
program _1407guyun;
var n,v0,z,i,j,temp:longint;
a,Beauty0,Volume0:array[1..3]of longint;
Volume,Beauty:array[1..100]of longint;
f:array[0..8000]of longint;
function max(a,b:longint):longint;
begin
if a>b then exit(a)
else exit(b);
end;function tran(x:longint):longint;
var ii:integer;
begin
for ii:=1 to 3 do
if x=a[ii] then exit(ii);
end;procedure DP;
begin
fillchar(f,sizeof(f),0);
for i:=1 to n do
for j:=v0 downto Volume[i] do
f[j]:=max(f[j],f[j-Volume[i]]+Beauty[i]);
writeln(f[v0]);
end;begin
read(n,v0);
for i:=1 to 3 do
read(a[i],Beauty0[i],Volume0[i]);
for i:=1 to n do
begin
read(Volume[i],temp);
Beauty[i]:=Volume[i]*Beauty0[tran(temp)];
Volume[i]:=Volume[i]*(1+Volume0[tran(temp)]);
end;
DP;
end.
program _1407guyun;
var n,v0,z,i,j,temp:longint;
a,Beauty0,Volume0:array[1..3]of longint;
Volume,Beauty:array[1..100]of longint;
f:array[0..8000]of longint;
function max(a,b:longint):longint;
begin
if a>b then exit(a)
else exit(b);
end;function tran(x:longint):longint;
var ii:integer;
begin
for ii:=1 to 3 do
if x=a[ii] then exit(ii);
end;procedure DP;
begin
fillchar(f,sizeof(f),0);
for i:=1 to n do
for j:=v0 downto Volume[i] do
f[j]:=max(f[j],f[j-Volume[i]]+Beauty[i]);
writeln(f[v0]);
end;begin
read(n,v0);
for i:=1 to 3 do
read(a[i],Beauty0[i],Volume0[i]);
for i:=1 to n do
begin
read(Volume[i],temp);
Beauty[i]:=Volume[i]*Beauty0[tran(temp)];
Volume[i]:=Volume[i]*(1+Volume0[tran(temp)]);
end;
DP;
end.
program _1407guyun;
var n,v0,z,i,j,temp:longint;
a,Beauty0,Volume0:array[1..3]of longint;
Volume,Beauty:array[1..100]of longint;
f:array[0..8000]of longint;
function max(a,b:longint):longint;
begin
if a>b then exit(a)
else exit(b);
end;function tran(x:longint):longint;
var ii:integer;
begin
for ii:=1 to 3 do
if x=a[ii] then exit(ii);
end;procedure DP;
begin
fillchar(f,sizeof(f),0);
for i:=1 to n do
for j:=v0 downto Volume[i] do
f[j]:=max(f[j],f[j-Volume[i]]+Beauty[i]);
writeln(f[v0]);
end;begin
read(n,v0);
for i:=1 to 3 do
read(a[i],Beauty0[i],Volume0[i]);
for i:=1 to n do
begin
read(Volume[i],temp);
Beauty[i]:=Volume[i]*Beauty0[tran(temp)];
Volume[i]:=Volume[i]*(1+Volume0[tran(temp)]);
end;
DP;
end. -
02014-08-17 21:08:48@
题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题
题题题题题题题题题题题题题题题题题题题题题题题题题题题题水水水水题题题题题
题题题题题题题题题题题题题题题题题题题题题题题题水水水水水水水水水题题题题
题题题题题题题题题题题题题题题题题题水水水水水水水水水水水水水水水题题题题
题题题题题题题题题题题题题题题题水水水水水水水水水水水水水水水题题题题题题
题题题题题题题题题题题水水水水题水水水水水水水水水水水题题题题题题题题题题
题题题题题题题题水水水水水水水题水水水题题水水水水水题题题题题题题题题题题
题题题水水水水水水水水水水水水题题题题题题水水水水题题题题题题题题题题题题
题水水水水水水水水水水水水水水题题题题题题水水水水题题题题题题题题题题题题
题水水水水水水水水水水水水题题题题题题题水水水水水水水水水水水题题题题题题
题水水水水水水水水水水水水题题题题题题水水水水水水水水水水水水水水题题题题
题题水水水水水水水水水水题题题题题水水水水水水题题题水水水水水水水题题题题
题题题题题题题题水水水水题题题题题水水水水题题题题题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题题水水题题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题题水水水水题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题题水水水水题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题题水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题题水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题水水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题水水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题水水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题水水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水题题水水水水题题水水水水水题题题题题
题题水水题题题水水水水水题题题题水水水题题水水水题题题水水水水水题题题题题
题题水水水水水水水水水水题题题题题水水题题水水题题题题水水水水水题题题题题
题题题水水水水水水水水水题题题题题题题题水水水题题题题水水水水题题题题题题
题题题题题水水水水水水水题题题题题题题题水水水题水水水水题题题题题题题题题
题题题题题题水水水水水水题题题题题题题水水水水题题水水水水题题题题题题题题
题题题题题题题题题水水水题题题题题题水水水水水题题题水水水水水水水题题题题
题题题题题题题题题题题题题题题题水水水水水水题题题题题水水水水水水题题题题
题题题题题题题题题题题题题题题水水水水水水题题题题题题水水水水水水水题题题
题题题题题题题题题题题题题题水水水水水题题题题题题题题题水水水水水水题题题
题题题题题题题题题题题题题水水水水水题题题题题题题题题题题水水水水题题题题
题题题题题题题题题题题题水水水题题题题题题题题题题题题题题题水水水题题题题
题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题
外加 题意看不懂0.0 -
02013-11-01 08:35:16@
题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题
题题题题题题题题题题题题题题题题题题题题题题题题题题题题水水水水题题题题题
题题题题题题题题题题题题题题题题题题题题题题题题水水水水水水水水水题题题题
题题题题题题题题题题题题题题题题题题水水水水水水水水水水水水水水水题题题题
题题题题题题题题题题题题题题题题水水水水水水水水水水水水水水水题题题题题题
题题题题题题题题题题题水水水水题水水水水水水水水水水水题题题题题题题题题题
题题题题题题题题水水水水水水水题水水水题题水水水水水题题题题题题题题题题题
题题题水水水水水水水水水水水水题题题题题题水水水水题题题题题题题题题题题题
题水水水水水水水水水水水水水水题题题题题题水水水水题题题题题题题题题题题题
题水水水水水水水水水水水水题题题题题题题水水水水水水水水水水水题题题题题题
题水水水水水水水水水水水水题题题题题题水水水水水水水水水水水水水水题题题题
题题水水水水水水水水水水题题题题题水水水水水水题题题水水水水水水水题题题题
题题题题题题题题水水水水题题题题题水水水水题题题题题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题题水水题题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题题水水水水题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题题水水水水题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题题水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题题水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题水水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题水水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题水水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题水水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水题题水水水水题题水水水水水题题题题题
题题水水题题题水水水水水题题题题水水水题题水水水题题题水水水水水题题题题题
题题水水水水水水水水水水题题题题题水水题题水水题题题题水水水水水题题题题题
题题题水水水水水水水水水题题题题题题题题水水水题题题题水水水水题题题题题题
题题题题题水水水水水水水题题题题题题题题水水水题水水水水题题题题题题题题题
题题题题题题水水水水水水题题题题题题题水水水水题题水水水水题题题题题题题题
题题题题题题题题题水水水题题题题题题水水水水水题题题水水水水水水水题题题题
题题题题题题题题题题题题题题题题水水水水水水题题题题题水水水水水水题题题题
题题题题题题题题题题题题题题题水水水水水水题题题题题题水水水水水水水题题题
题题题题题题题题题题题题题题水水水水水题题题题题题题题题水水水水水水题题题
题题题题题题题题题题题题题水水水水水题题题题题题题题题题题水水水水题题题题
题题题题题题题题题题题题水水水题题题题题题题题题题题题题题题水水水题题题题
题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题外加 题意看不懂0.0
-
02013-07-20 21:36:00@
总结一下这道题
1.总体积=布体积+布体积*绣体积
2.总价值=布价值*绣价值
3.数组一定要开大!!!!我的18分27分都是从这来的!!!!
4.好吧 就是个01背包。。 -
02009-11-06 08:24:52@
。。巨水无比。。
交了2遍=.=
体积忘记把布本身的体积加上。。
晕菜。。O.O
-
02009-11-05 14:24:36@
看不懂题,悲剧!
-
02009-10-29 15:16:05@
01背包
就是题意有点绕..
多看题吧编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
├ 测试数据 11:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms