原贴
又看了一遍,发现
sort(a+1,a+n+1); w=min(w,a[n]); for(int i=1;i<=n-1;i++) if(ans<=w) ans+=a[i]; else { cout<<i-2<<endl; return 0; }
这也能AC?