Misaka_Azusa @ 2018-02-01 08:47:24
using namespace std; struct apple{ int h,w; }a[100010]; long long ans=0,n,s,desk,hand,taotao; int cmp(apple a,apple b) { a.w<b.w; } int main() { scanf("%d%d%d%d",&n,&s,&desk,&hand); for(int i=1;i<=n;i++) scanf("%d%d",&a[i].h,&a[i].w);
taotao=desk+hand;
sort(a+1,a+1+n,cmp);
for(int i=1;i<=n;i++)
{
if(a[i].h<=taotao&&(s-a[i].w)>=0)
{
ans++;
s-=a[i].w;
}
}
printf("%d",ans);
using namespace std; int h[50001],w[50001]; int ans=0,n,s,desk,hand,taotao; int main() { cin>>n>>s>>desk>>hand; int k=0,x; taotao=desk+hand; for(int i=1;i<=n;i++) { cin>>h[i]>>x; if(h[i]<=taotao) { w[k]=x; k++; } }
sort(w,w+k);
for(int i=1;i<=k;i++)
{
if((s-w[i])>=0)
{
ans++;
s-=w[i];
}
}
cout<<ans;
return 0;
by zhaomingrui @ 2018-02-01 09:12:47
哪道题啊?