先從大到小sort
s=重量總和,g計錄前一次的位置
long long s=0;
int g=-1;
for(int b=0;b<m;b++){
for(int d=g+1;d<n;d++){
if(c[b]>=w[d]){
s+=w[d];
g=d;
break;
}
}
}